centos安装redis教程:https://www.cnblogs.com/heqiuyong/p/10463334.html 或参考狂神说
以下主要记录一些重要的点:
-
redis默认安装路径:/usr/local/bin
-
将配置文件redis.conf复制到安装路径下,这样可以保证原有配置文件仍然存在
一般会把自己下载的安装文件放到opt目录下去
cd /usr/local/bin
mkdir redis-config
cp /opt/redis-5.0.3/redis.conf redis-config/
-
redis默认不是后台启动的,修改配置文件:daemonize改为yes
如果不改配置文件,直接使用redis-server命令启动:终端会被阻塞 -
通过指定配置文件启动:redis-server /usr/local/bin/redis-config/redis.conf
-
关闭redis服务
-
使用shell更方便:
[root@localhost ~]# mkdir shell-cmd
[root@localhost ~]# touch redis-start.sh
[root@localhost ~]# echo redis-server /usr/local/bin/redis-config/redis.conf >> redis-start.sh
[root@localhost ~]# cat redis-start.sh
redis-server /usr/local/bin/redis-config/redis.conf
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# sh redis-start.sh
8358:C 01 Dec 2020 11:10:44.336 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
8358:C 01 Dec 2020 11:10:44.337 # Redis version=5.0.3, bits=64, commit=00000000, modified=0, pid=8358, just started
8358:C 01 Dec 2020 11:10:44.337 # Configuration loaded
[root@localhost ~]# ps -ef | grep redis
root 8359 1 0 11:10 ? 00:00:00 redis-server 127.0.0.1:6379
root 8382 6703 0 11:11 pts/1 00:00:00 grep --color=auto redis