下載地址:http://redis.io/downloadredis
一、將下載好的redis複製到:/opt/software/redis-4.0.9.tar.gzthis
二、在/opt/software/目錄下執行命令:tar -zxvf redis-4.0.9.tar.gz -C /opt/local/spa
三、進入/opt/local/redis-4.0.9/目錄:cd /opt/local/redis-4.0.9code
四、執行make install命令;server
以上步驟能夠將redis安裝完成。blog
將redis設置成開機啓動ip
一、進入redis目錄:/opt/local/redis-4.0.9it
二、執行命令:./utils/install_server.shio
三、一直默認便可:table
[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