个人博客
- Linux版本:CentOS7.7
- Redis版本:5.0.8
1、下载Redis
2、解压安装
- 解压并编译。
1 2 3
| tar -xvf redis-5.0.8.tar.gz cd redis-5.0.8 make
|
make如果报错,则需要安装gcc环境 yum install gcc-c++
- 安装到
/usr/local/redis/目录下,并复制配置文件。
1 2 3 4 5
| cd src make install PREFIX=/usr/local/redis cd ../ mkdir /usr/local/redis/config cp ./redis.conf /usr/local/redis/config/
|
3、修改配置
vi /usr/local/redis/config/redis.conf
1 2 3 4 5 6
| # 去除本地访问限制 # bind 127.0.0.1 # 关闭保护模式,否则外网不能访问Redis protected-mode no # 是否以守护进程启动 daemonize yes
|
port端口可改可不改,主要看有没有端口冲突。
4、启动Redis
- 使用命令
/usr/local/redis/bin/redis-server /usr/local/redis/config/redis.conf 启动Redis。 - 查看进程
ps aux|grep redis - 查看端口
netstat -tnlp|grep 6379
5、停Redis
- 使用
pkill redis命令或者/usr/local/redis/bin/redis-cli shutdown来平滑关闭Redis进程。 - 一般不建议使用kill命令直接杀进程,可能会导致数据丢失。
6、卸载Redis
- 只需要删除安装目录即可
rm -rf /usr/local/redis
参考链接