http://blog.csdn.net/u014419512/article/details/25693425
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Directory (?) [+]
- Environment
- Installation
- Start
- Debugging
- Java calls
- Background process
- More information
Environment
Rhlinux-6.4-64-en, Red Hat 6.4 64-bit, English official release
Installation
The installation is simple, download the Redis package first, see here, then copy to your Linux machine, then execute the following command.
123 |
$ tar xzf redis-2.6.14.tar.gz$ cd redis-2.6.14$ make
|
Start
Debugging
Execute the redis-cli script under the SRC directory, which is the client for Redis.
123)45 |
$ src/redis-cliredis> set foo barOKredis> get foo"bar"
|
Java calls
- Redis More famous Java client is Jedis, first download Jedis jar package, can go to Maven library search Jedis can download to, source code is on GitHub: Https://github.com/xetorthio/jedis.
- Simply write a main method to invoke it.
123456 |
PublicStaticvoidMain(String[]Args){ JedisJedis=NewJedis("10.20.8.39");IP for Redis server, port default 6379 Jedis.Set("Foo","Bar"); StringValue=Jedis.Get("Foo"); System. out. println(value); }
|
Background process
The previous startup method is not the background process mode, the terminal shut down the service will stop, you can use the following command to start Redis as a background process, and add to the system startup naming.
12 |
$ cd redis-2.6.14/utils$./install_server
|
After executing the command, you will be prompted to answer a few questions, you can return to the past, select the default settings.
123456789 |
PleaseSelect the Redis portFor this instance:[6379]Selecting default:6379PleaseSelect the Redis config file name[/etc/redis/6379.conf]Selected Default-/etc/redis/6379.confPleaseSelect the Redis log file name[/var/log/redis_6379.log]Selected Default-/var/log/redis_6379.logPleaseSelect the Data directoryfor This instance [/var/lib/redis/6379]selected Default-/var/lib/redis/6379please select the Redis executable Path [/usr/local/bin/redis-server]
|
PS: After I execute the install_server script, I find that the service is not up, see/etc/init.d/redis_6379 This file finds that the newline symbol is replaced with a /n
symbol, and manually replace the symbols with a newline.
Preliminary Introduction to Redis