Redis自启与脚本配置
1.首先关闭当前正在运行的redis服务,创建相关命令的软链接
[[email protected] utils]# ln -s /usr/local/redis-5.0.3/utils/redis_init_script /etc/rc.d/init.d/redis
[[email protected] utils]# ln -s /usr/local/redis-5.0.3/src/redis-cli /usr/local/bin/redis-cli
[[email protected] utils]# ln -s /usr/local/redis-5.0.3/src/redis-server /usr/local/bin/redis-server
2.修改配置文件
[[email protected] utils]# vim /etc/rc.d/init.d/redis
#注意前面是行号
20 PASSWORD=$(cat $CONF|grep '^\s*requirepass'|awk '{print $2}'|sed 's/"//g')
21 if [ -z $PASSWORD ]
22 then
23 $CLIEXEC -p $REDISPORT shutdown
24 else
25 $CLIEXEC -a $PASSWORD -p $REDISPORT shutdown
26 fi
27 #$CLIEXEC -a $PASSWORD -p $REDISPORT shutdown
注意:在配置文件中有这么一句话: CONF="/etc/redis/${REDISPORT}.conf"
[[email protected] utils]# mkdir /etc/redis
[[email protected] utils]# ln -s /usr/local/redis-5.0.3/redis.conf /etc/redis/6379.conf
至此,脚本配置完成
将redis服务加入自启列表
chkconfig --add redis
设置开机自启动
chkconfig redison
查看是否成功
chkconfig --list |grep redis
转载自:https://blog.****.net/u010309394/article/details/81807597