Linux下Redis开机自启(Centos)
来源:互联网 发布:汉高薪资待遇 知乎 编辑:程序博客网 时间:2024/06/13 10:58
废话少说,直接来步骤:
1、设置redis.conf中daemonize为yes,确保守护进程开启。
2、编写开机自启动脚本
vi /etc/init.d/redis
脚本内容如下:
# chkconfig: 2345 10 90 # description: Start and Stop redis PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=6379 EXEC=/usr/redisbin/redis-server REDIS_CLI=/usr/redisbin/redis-cli PIDFILE=/var/run/redis.pid CONF="/use/redisbin/redis.conf" AUTH="1234" 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 if [ "$?"="0" ] then echo "Redis is running..." fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE exists, process is not running." else PID=$(cat $PIDFILE) echo "Stopping..." $REDIS_CLI -p $REDISPORT SHUTDOWN sleep 2 while [ -x $PIDFILE ] do echo "Waiting for Redis to shutdown..." sleep 1 done echo "Redis stopped" fi ;; restart|force-reload) ${0} stop ${0} start ;; *) echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2 exit 1 esac
3、写完后保存退出VI
4、设置权限
chmod 755 redis
5、启动测试
/etc/init.d/redis start
启动成功会提示如下信息:
Starting Redis server...Redis is running...
使用redis-cli测试:
[root@rk ~]# /usr/redisbin/redis-cli127.0.0.1:6379> set foo barOK127.0.0.1:6379> get foo"bar"127.0.0.1:6379> exit
6、设置开机自启动
chkconfig redis on
7、关机重启测试
reboot
然后在用redis-cli测试即可。
0 0
- Linux下Redis开机自启(Centos)
- Linux下Redis开机自启(Centos)
- Linux(Centos)下Redis开机自启设置
- Linux下Redis开机自启(Centos)
- Linux下Redis开机自启(Centos)
- Linux下设置Redis开机自启
- redis在centos下安装与开机自启配置
- linux/centos开机自启(linux tomcat开机自启/nginx开机自启)
- redis linux 开机自启
- linux下redis设置开机自启动
- linux下redis设置开机自启动
- Centos开机自启动redis
- Centos开机自启动redis
- Centos开机自启动redis
- Centos开机自启动redis
- Centos开机自启动redis
- Linux上Redis加入服务(开机自启)
- Linux上Redis加入服务(开机自启)
- Mac 下 破解 sublime text 2 方法详解
- python核心编程-map函数
- excel排版:人工定制列宽时部分列宽参数
- python核心编程-map处理多个序列
- ssh登录报错-bash: fork: retry: Resource temporarily unavailable
- Linux下Redis开机自启(Centos)
- Bootstrap 3 + MVC 5 - validation css tips
- 灾难的一天:“SSL_connect SYSCALL”和“the scheme https does not accept registry part”两种错误
- IOS开发记录(一)
- 渐变动画/按钮/图片拉伸/copy/KVC/KVO
- POJ 1426 Find The Multiple
- 徒步一千里 (1930) (長津惠山)
- golang---利用反射机制对结构体进行循环赋值
- POJ 2243 Knight Moves