下載地址:http://redis.io/download
1、將下載好的redis復制到:/opt/software/redis-4.0.9.tar.gz
2、在/opt/software/目錄下執行命令:tar -zxvf redis-4.0.9.tar.gz -C /opt/local/
3、進入/opt/local/redis-4.0.9/目錄:cd /opt/local/redis-4.0.9
4、執行make install命令;
以上步驟可以將redis安裝完成。
將redis設置成開機啟動
1、進入redis目錄:/opt/local/redis-4.0.9
2、執行命令:./utils/install_server.sh
3、一直默認即可:
[root@localhost redis-4.0.9]# ./utils/install_server.sh Welcome to the redis service installer This script will help you easily set up a running redis server Please select the redis port for this instance: [6379] Selecting default: 6379 Please select the redis config file name [/etc/redis/6379.conf] Selected default - /etc/redis/6379.conf Please select the redis log file name [/var/log/redis_6379.log] Selected default - /var/log/redis_6379.log Please select the data directory for this instance [/var/lib/redis/6379] Selected default - /var/lib/redis/6379 Please select the redis executable path [/usr/local/bin/redis-server] Selected config: Port : 6379 Config file : /etc/redis/6379.conf Log file : /var/log/redis_6379.log Data dir : /var/lib/redis/6379 Executable : /usr/local/bin/redis-server Cli Executable : /usr/local/bin/redis-cli Is this ok? Then press ENTER to go on or Ctrl-C to abort. Copied /tmp/6379.conf => /etc/init.d/redis_6379 Installing service... Successfully added to chkconfig! Successfully added to runlevels 345! Starting Redis server... Installation successful! 以上操作可以將redis設置為開機啟動。
PS:通過這種方式這是redis開機啟動,redis的配置文件路徑:/etc/redis/6379.conf
所以如果修改redis的配置文件,修改路徑應該是:/etc/redis/6379.conf
redis安裝目錄下的配置文件/opt/local/redis-4.0.9/redis.conf修改會不生效;
如果想要使用/opt/local/redis-4.0.9/redis.conf,修改/etc/init.d/redis_6379文件即可。
redis客戶端命令redis-cli任意位置執行
將export PATH=$PATH:/opt/local/redis-4.0.9/redis-cli加入到/etc/profile最后一行 [root@localhost redis-4.0.9]# vi /etc/profile [root@localhost redis-4.0.9]# source /etc/profile [root@localhost redis-4.0.9]# redis-cli