wget http://download.redis.io/releases/redis-4.0.9.tar.gz
tar -zxvf redis-4.0.9.tar.gz
cd redis-4.0.9/src
make
cd src
make install
Hint: It’s a good idea to run ‘make test’
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
# 安装tcl8.5(此步可忽略,为执行make test准备)
yum install tcl
# 执行make test(此步可忽略)
[root@172 src]# make test
All tests passed without errors!
Cleanup: may take some time… OK
设置Redis开机自动启动
# 进入Redis的util目录
cd /home/redis/redis-4.0.9/utils
# 执行./install_server.sh(执行过程中全部Enter,使用默认配置,如果想修改,可依次自行修改)
[root@172 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进程
[root@172 utils]# ps -ef|grep redis
root 10280 1 0 08:15 ? 00:00:00 /usr/local/bin/redis-server 127.0.0.1:6379
Redis开启远程访问
# 查找Redis配置(注意不是安装目录下的redis.conf)
# 打开第五步设计的Redis配置,默认为:/etc/redis/6379.conf
# 修改配置文件如下几项,其它保持不变
daemonize yes
#bind 127.0.0.1 (注释,不限制IP)
protected-mode no
# 重启服务
[root@172 redis-3.2.11]# service redis_6379 restart
Stopping …
Redis stopped
Starting Redis server…
# 关闭防火墙(生产禁止直接关闭,应设置对应规则,此处不延伸)
# 停止firewall
systemctl stop firewalld.service
# 禁止firewall开机启动
systemctl disable firewalld.service