1. First download the Redis compact package on the official website
Redis-3.2.0.tar.gz
2. Unzip to the current folder (where you can unzip to a random location)
Tar zvxf redis-3.2.0.tar.gz
3. Switch to the redis-3.2.0 directory
CD redis-3.2.0 and then perform the compilation and installation
Make and make install command
4. When the installation is complete, the execution file defaults to the/etc/local/bin directory
[Email protected]:/usr/local/bin$ ls
Idea Redis-check-aof Redis-cli Redis-server
Redis-benchmark Redis-check-rdb Redis-sentinel
5. Start the server side, client test
Executes the command./redis-server
#检测后台进程是否存在 ps-ef |grep redis 6379
[Email protected]:/usr/local/bin$ ls
Idea Redis-check-aof Redis-cli Redis-server
Redis-benchmark Redis-check-rdb Redis-sentinel
[Email protected]:/usr/local/bin$ redis-cli
127.0.0.1:6379> Key *
(Error) ERR unknown command ' key '
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> set Key "Hello word"
Ok
127.0.0.1:6379> Get key
"Hello word"
127.0.0.1:6379>
6. Start with a configuration file
The specified configuration file can be started for the Redis service, and the configuration file is redis.conf
under the Redis root directory .
No 6379 "/home/mars/logs/redis.log" #配置持久化文件存放位置 dir/home/mars/data/redisdata
Setting up configuration files at startup
Redis-server./redis.conf #如果更改了端口, you also need to specify a port when using the ' redis-cli ' client connection, for example: Redis-cli-p 6380
7. Use the Redis startup script to set up boot
It is recommended that you start the Redis service in a production environment using startup scripting. The startup script redis_init_script
is located in the Redis /utils/
directory:
#大致浏览下该启动脚本, it is found that Redis habitually uses the port name of the listener as the configuration file, and we follow this convention later. #redis服务器监听的端口 redisport=6379 #服务端所处位置, the default is stored with '/usr/local/bin/redis-server ' after make install, if not Install will need to modify the path, the same. Exec=/usr/local/bin/redis-server #客户端位置 cliexec=/usr/local/bin/redis-cli #Redis的PID文件位置 pidfile=/var/run/ Redis_${redisport}.pid #配置文件位置, need to modify conf="/etc/redis/${redisport}.conf"
<1> according to the startup script requirements, copy the modified configuration file to the specified directory as a port name. Need to use root user.
sudo mkdir/etc/redis sudo cp redis.conf/etc/redis/6379.conf
<2> Copy the startup script to the/ETC/INIT.D directory, this example names the startup script REDISD (usually ending with D as the background self-starting service).
CP REDIS_INIT_SCRIPT/ETC/INIT.D/REDISD
<3> set to boot from:
[Email protected]:/etc/init.d$ sudo chmod +x./REDISD
[Email protected]:/etc/init.d$ sudo update-rc.d REDISD defaults
#启动服务
[Email protected]:/etc/init.d$ service REDISD start
Starting Redis Server ...
#停止服务
[Email protected]:/etc/init.d$ service REDISD Stop
Installing Redis under Ubuntu14.04