1. linux安装redis
1.1. 进入安装目录
[root@server-test-211 ~]# cd /home/app/software
1.2. 下载redis资源
[root@server-test-211 software]# wget http://download.redis.io/releash/redis-4.0.8.tar.gz
1.3. 解压
[root@server-test-211 software]# tar xzvf redis-4.0.8.tar.gz
1.4. 重命名
[root@server-test-211 software]# mv redis-4.0.8 redis
1.5. 安装
[root@server-test-211 software]# cd redis
[root@server-test-211 redis]# make
[root@server-test-211 redis]# cd src
[root@server-test-211 src]# make install PREFIX=/usr/local/redis
1.6. 配置文件复制到安装目录
[root@server-test-211 src]# cd /usr/local/redis/
[root@server-test-211 redis]# mkdir etc
[root@server-test-211 redis]# mv /home/app/software/redis/redis.conf /usr/local/redis/etc
1.7. 配置 redis 为后台启动
将
daemonize no
改为为daemonize yes
[root@server-test-211 redis]# vi /usr/local/redis/etc/redis.conf
1.8. 配置 redis 密码
[root@server-test-211 redis]# vi /usr/local/redis/etc/redis.conf
在
[sercury]
项下找到requirepass
取消注释并将
requirepass foobared
改为requirepass “123456”
1.9. 启动 redis 服务
[root@server-test-211 redis]# /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
1.10. 开机启动 redis 服务
[root@server-test-211 redis]# vi /etc/rc.local
添加
/usr/local/redis/bin/redis-server /usr/local/redis/etc/reids.conf
1.11. 启动 redis-cli 检测是否启动成功(1)
[root@server-test-211 redis]# cd /usr/local/redis/bin/
[root@server-test-211 bin]# ./redis-cli
1) 查看密码:
config get requirepass
, 如果返回NOAUTH Authentication required
错误,则登录 2) 登录:auth "123456"
,返回OK
即登录成功 3) 设置缓存数据
1.12. 检测 redis 是否启动(2)
- 进程检测
[root@server-test-211 bin]# ps -ef | grep redis
- 端口检测
[root@server-test-211 bin]# netstat -lntp | grep 6379
1.13. 停止 redis 服务
[root@server-test-211 bin]# redis-cli shutdown
[root@server-test-211 bin]# ps -ef | grep redis
[root@server-test-211 bin]# kill [进程pid]
1.14. 卸载 redis
[root@server-test-211 bin]# rm -rf /usr/local/redis // 删除安装目录
[root@server-test-211 bin]# rm -rf /usr/bin/redis-* // 删除所有redis命令
[root@server-test-211 bin]# rm -rf /home/app/software/redis*