时间:2021-05-24
一、CentOS 7.0系统下的设置方法
假设Redis已经安装,版本3.2.4
#cd redis-3.2.4#mkdir /etc/redis#cp redis.conf /etc/redis/6379.conf#cp utils/redis_init_script /etc/init.d/redis#chmod a+x /etc/init.d/redis#cp src/redis-server /usr/local/bin/#cp src/redis-cli /usr/local/bin/#vim /etc/init.d/redis在脚本文件添加 #chkconfig: 2345 80 90
否则会出现 “redis服务不支持chkconfig”的错误提示
#!/bin/sh#chkconfig: 2345 80 90# Simple Redis init.d script conceived to work on Linux systems# as it does use of the /proc filesystem.REDISPORT=6379EXEC=/usr/local/bin/redis-serverCLIEXEC=/usr/local/bin/redis-cliPIDFILE=/var/run/redis_${REDISPORT}.pidCONF="/etc/redis/${REDISPORT}.conf"case "$1" instart)if [ -f $PIDFILE ]thenecho "$PIDFILE exists, process is already running or crashed"elseecho "Starting Redis server..."$EXEC $CONFfi;;stop)if [ ! -f $PIDFILE ]thenecho "$PIDFILE does not exist, process is not running"elsePID=$(cat $PIDFILE)echo "Stopping ..."$CLIEXEC -p $REDISPORT shutdownwhile [ -x /proc/${PID} ]doecho "Waiting for Redis to shutdown ..."sleep 1doneecho "Redis stopped"fi;;*)echo "Please use start or stop as first argument";;esac注册事件,开机启动
#chkconfig redis on启动服务
#service redis start查看服务是否启动
#lsof -i:6379二、Debian 8.0设置方法
步骤与上面类似,不过Debian 用update-rc.d (或insserv)代替chkconfig
脚本文件描述也不一样。
假设Redis已经安装,版本3.2.4
#cd redis-3.2.4#mkdir /etc/redis#cp redis.conf /etc/redis/6379.conf#cp utils/redis_init_script /etc/init.d/redis#chmod a+x /etc/init.d/redis#cp src/redis-server /usr/local/bin/#cp src/redis-cli /usr/local/bin/#vim /etc/init.d/redis在脚本文件添加
### BEGIN INIT INFO# Provides: redis6379# Required-Start: $local_fs $network# Required-Stop: $local_fs# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: redis6379# Description: penavico redis 6379### END INIT INFO否则会出现 “ insserv: warning: script ‘redis6379′ missing LSB tags and overrides”的错误提示
#!/bin/sh## Simple Redis init.d script conceived to work on Linux systems# as it does use of the /proc filesystem.### BEGIN INIT INFO# Provides: redis6379# Required-Start: $local_fs $network# Required-Stop: $local_fs# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: redis6379# Description: penavico redis 6379### END INIT INFOREDISPORT=6379EXEC=/usr/local/bin/redis-serverCLIEXEC=/usr/local/bin/redis-cliPIDFILE=/var/run/redis_${REDISPORT}.pidCONF="/etc/redis/${REDISPORT}.conf"case "$1" in start) if [ -f $PIDFILE ] then echo "$PIDFILE exists, process is already running or crashed" else echo "Starting Redis server..." $EXEC $CONF fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE does not exist, process is not running" else PID=$(cat $PIDFILE) echo "Stopping ..." $CLIEXEC -p $REDISPORT shutdown while [ -x /proc/${PID} ] do echo "Waiting for Redis to shutdown ..." sleep 1 done echo "Redis stopped" fi ;; *) echo "Please use start or stop as first argument" ;;esac注册事件,开机启动
#update-rc.d redisd defaults启动服务
#service redis start查看服务是否启动
#lsof -i:6379开机启动以后,默认的配置文件位置:/etc/redis/6379.conf
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对的支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
CenterOS中安装Redis及开机启动设置详解从官方下载最新Redis进行安装,官网地址:http://redis.io/download$wgethttp
docker部署redis首先在linux中安装上Docker,然后启动Docker服务Centos7中启动Dockersystemctlstartdocker
Linux系统下如何查询开机启动的程序?对于没有启动的程序如何设置开机启动?又如何设置在不同的启动等级下程序启动或不启动?这里用Centos6.7下如何启动ss
为了减轻管理者的负担,我们可以设置让MySQL开机自动启动。要实现MySQL开机自动启动,我们需要搞定如下几个问题:(1)Linux开机自动启动脚本放在哪儿?一
此文档概述Linux开机提示kernelpanic-notsyncing:Attemptedtokillinit!解决方法1、重新启动linux系统,看见如图见