~~~
1.将redis-6.0.9.tar.gz上传到CentOS
Alt + P ,拖入长传到/home/cache-server/tools目录
2.解压redis-6.0.5.tar.gz到当前目录/home/cache-server/tools
tar -zxvf redis-6.0.5.tar.gz
cd redis-6.0.5
make install PREFIX=/usr/local/redis
3.拷贝配置文件
cp /home/cache-server/tools/redis-6.0.5/redis.conf /usr/local/redis/bin
cd /usr/local/redis/bin
vim redis.conf
1)注释掉 bind 127.0.0.1
2)默认为保护模式,把 protected-mode yes 改为 protected-mode no
3)默认为不守护进程模式,把daemonize no 改为daemonize yes
4)将requirepass foobared前的“#”去掉,密码改为你想要设置的密码admin
设置完,按“ESC”键,只有输入“:wq!”保存退出
4.启动redis服务器
cd /usr/local/redis/bin
./redis-server ./redis.conf #启动Redis服务器,读取指定的配置文件
ps -ef | grep redis
./redis-cli -h 192.168.133.129 -p 6379 -a admin shutdown #停止Redis
5.连接Redis服务器
第一种方式:使用自带的客户端(Linux上)
./redis-cli -h 192.168.133.129 -p 6379
192.168.45.129:6379> set name 'jack'
(error) NOAUTH Authentication required.
192.168.45.129:6379>
192.168.45.129:6379> auth admin
OK
192.168.45.129:6379> set name 'jack'
OK
192.168.45.129:6379> get name
"jack"
192.168.45.129:6379>
第二种方式:使用redis-desktop-manager GUI客户端(Window)
6.Redis自启动
vim /etc/systemd/system/redis.service
[Unit]
Description=Redis Server Manager
After=network.target
[Service]
Type=forking
#PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=always
PrivateTmp=true
[Install]
WantedBy=multi-user.target
7.设置Redis服务开机启动
systemctl daemon-reload
systemctl start redis
systemctl status redis
systemctl enable redis
~~~