1. 安装配置
以下的配置,是在CentOS7.6,/opt目录下进行的
$ wget http://download.redis.io/releases/redis-4.0.10.tar.gz
$ tar xvf redis-4.0.11.tar.gz
$ cd redis-4.0.11/
$ make install PREFIX=/opt/redis-4.0.11
$ vim redis.conf
bind 0.0.0.0(可以外部访问的IP,如果前面加#注释掉,所有的都能访问)
port 6379(可修改服务端口)
daemonize yes(直接后台运行)
requirepass password(设置访问密码,原本是注释掉的,需要放开)
2 启动服务
$ cd src
$ ./redis-server ../redis.conf
1592:C 10 Oct 13:43:31.090 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1592:C 10 Oct 13:43:31.090 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=1592, just started
1592:C 10 Oct 13:43:31.090 # Configuration loaded
3 终止服务
$ ps aux|grep redis
root 1593 0.1 0.0 145316 7524 ? Ssl 13:43 0:00 bin/redis-server 0.0.0.0:6379
$ kill -9 1593
或者
$ cd /opt/redis-4.0.1
$ bin/redis-cli shutdown
4 验证服务
[root@cluster74 redis-4.0.11]# bin/redis-cli -h 10.10.7.74
127.0.0.1:6379> set 'redis' 'ok'
OK
127.0.0.1:6379> get 'redis'
"ok"
127.0.0.1:6379> quit