1、下载当前稳定版
wget http://download.redis.io/releases/redis-stable.tar.gz
或者
wget http://download.redis.io/releases/redis-5.0.5.tar.g
2、加压缩
tar -zxvf redis-5.0.5.tar.gz
3、编译
cd redis-5.0.5/
make
make install PREFIX=/usr/local/redis
4、编辑配置文件
vi redis.conf
bind 10.17.12.160
protected-mode no
port 6379
daemonize yes
requirepass 123456
说明:
daemonize yes
表示后台运行
protected-mode no
表示关闭保护模式
cp redis.conf /usr/local/redis
5、启动服务
cd /usr/local/redis
bin/redis-server redis.conf >> /var/log/redis.log &
6、简单使用
登录bin/redis-cli -h 10.17.12.XXX -p 6379 -a 123456
[root@server redis]# bin/redis-cli -h 10.17.12.xxx -p 6379 -a 123456
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
10.17.12.xxx:6379> set "name" "chengyuqiang"
OK
10.17.12.xxx:6379> get "name"
"chengyuqiang"
10.17.12.xxx:6379> quit
[root@server redis]#
7、关闭服务
[root@server ~]# ps -aux | grep redis
root 763 0.1 0.1 159468 11952 ? Ssl 09:35 0:02 /usr/local/redis/bin/redis-server 10.17.12.xxx:6379
root 1182 0.0 0.0 112648 952 pts/0 S+ 10:08 0:00 grep --color=auto redis
[root@server ~]# kill 763