下载 http://download.redis.io/releases/redis-5.0.8.tar.gz
tar -xzvf redis-5.0.8.tar.gz
cd redis-5.0.8
[hadoop@node1 redis-5.0.8]$ yum install gcc tcl -y
[hadoop@node1 redis-5.0.8]$ mkdir -p /home/hadoop/soft/redis
[hadoop@node1 redis-5.0.8]$ make PREFIX=/home/hadoop/soft/redis install
[hadoop@node1 redis-5.0.8]$ cd /home/hadoop/soft/redis-5.0.8/src
[hadoop@node1 src]$ cp redis-sentinel /home/hadoop/soft/redis/bin
#配置环境变量
vim ~/.bash_profile
export REDIS_HOME=/home/hadoop/soft/redis
export PATH=$PATH:$REDIS_HOME/bin
source ~/.bash_profile
把redis做成一个后台服务,最好在root的~/.bash_profile中先配置环境变量
[root@node1 ~]# cd /home/hadoop/soft/redis-5.0.8/utils
[root@node1 utils]# source ~/.bash_profile
[root@node1 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 [/home/hadoop/soft/redis/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 : /home/hadoop/soft/redis/bin/redis-server
Cli Executable : /home/hadoop/soft/redis/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!
[root@node1 utils]# cd /etc/init.d/
[root@node1 init.d]# mv redis_6379 redisd
#启动redis
[root@node1 init.d]# service redisd start
Starting Redis server...
#查看端口
[root@node1 init.d]# ss -tanl
[hadoop@node1 ~]$ redis-cli
127.0.0.1:6379> set msg 111
OK
127.0.0.1:6379> get msg
"111"
127.0.0.1:6379>
redis快照被强制关闭了导致不能持久化的问题
127.0.0.1:6379> set a 1
(error) MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.
127.0.0.1:6379> config set stop-writes-on-bgsave-error no
OK