配置redis自启动脚本
在redis源码目录下有一个utils文件夹,提供了install_server.sh安装工具,可生成自启动的redis脚本。
[root@huntdbredis-2.8.19]# cd utils/ [root@huntdb utils]# ./install_server.sh Welcometo the redis service installer Thisscript will help you easily set up a running redis serverPleaseselect the redis port for this instance: [6379] Selectingdefault: 6379 Pleaseselect the redis config file name [/etc/redis/6379.conf] /usr/local/redis/etc/redis.conf Pleaseselect the redis log file name [/var/log/redis_6379.log] /usr/local/redis/log/redis.log Pleaseselect the data directory for this instance [/var/lib/redis/6379] /usr/local/redis/data/ Pleaseselect the redis executable path [/usr/local/redis/bin/redis-server] Selectedconfig: Port : 6379 Configfile : /usr/local/redis/etc/redis.conf Logfile :/usr/local/redis/log/redis.log Datadir : /usr/local/redis/data/ Executable : /usr/local/redis/bin/redis-server CliExecutable : /usr/local/redis/bin/redis-cli Is thisok? Then press ENTER to go on or Ctrl-C to abort. Copied/tmp/6379.conf => /etc/init.d/redis_6379 Installingservice... Successfullyadded to chkconfig! Successfullyadded to runlevels 345! StartingRedis server... Installationsuccessful!
根据实际情况分别填写配置文件、日志文件、rdb/aof数据存储目录
脚本内容如下:
[root@huntdb utils]# cat /etc/init.d/redis_6379 #!/bin/sh #Configurationsinjected by install_server below....EXEC=/usr/local/redis/bin/redis-server CLIEXEC=/usr/local/redis/bin/redis-cli PIDFILE=/var/run/redis_6379.pid CONF="/usr/local/redis/etc/redis.conf" REDISPORT="6379" ############### # SysVInit Information #chkconfig: - 58 74 #description: redis_6379 is the redis daemon. ###BEGIN INIT INFO #Provides: redis_6379 #Required-Start: $network $local_fs $remote_fs #Required-Stop: $network $local_fs $remote_fs #Default-Start: 2 3 4 5 #Default-Stop: 0 1 6 #Should-Start: $syslog $named #Should-Stop: $syslog $named #Short-Description: start and stop redis_6379 #Description: Redis daemon ### ENDINIT INFOcase"$1" instart)if [ -f $PIDFILE ]thenecho "$PIDFILE exists, processis already running or crashed"elseecho "Starting Redisserver..."$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 toshutdown ..."sleep 1doneecho "Redis stopped"fi;;status)PID=$(cat $PIDFILE)if [ ! -x /proc/${PID} ]thenecho 'Redis is not running'elseecho "Redis is running($PID)"fi;;restart)$0 stop$0 start;;*)echo "Please use start, stop,restart or status as first argument";; esac
添加服务并更改运行级别:
[root@huntdb utils]# chkconfig --add redi_6379[root@huntdb utils]# chkconfig --level redi_6379 35 on
转载于:https://blog.51cto.com/hunt1574/1631780
配置redis自启动脚本相关推荐
- QNAP TS-x31+、TS-x31X、TS-x31配置开机自启动脚本
为了在NAS进行某些高级操作,你可能需要在启动时运行特定的程序(或脚本).尽管QNAP NAS是基于Linux打造的,但你无法使用一般Linux上的方法设置开机自启动:因为默认配置文件在每次启动时都会 ...
- linux系统下安装和配置redis(2021版)
前言:最近在阿里云市场中租用了一台ESC,学习和研发用途.操作系统版本为CentOS 7.9 64位,需要配置一些基础环境,其中就包括redis.在此记录下redis的安装和配置过程,方便自己和后来者 ...
- 高并发-【抢红包案例】之四:使用Redis+Lua脚本实现抢红包并异步持久化到数据库
文章目录 导读 概述 实现步骤 注解方式配置 Redis lua脚本和异步持久化功能的开发 Service层添加Redis抢红包的逻辑 Controller层新增路由方法 构造模拟数据,测试 代码 总 ...
- 开机自启动脚本_Linux配置开机自启动执行脚本的两种方法
代码来源:oschina 原文作者:醉生梦死zsms 原文链接:https://my.oschina.net/u/3285916/blog/1622358 本文版权归原作者所有,如有侵权请立即与我联系 ...
- [Android]开机自启动脚本和selinux权限配置
概述 在前段时间的工作中,需要开发一个开机自动启动的脚本,现把开发过程记录一下 主要框架 编写一个可以开机自动启动的脚本,方法就是通过rc文件,在boot_complete=1时,去启动这个服务,那么 ...
- centos6.5命令安装redis并设置redis自启动,可远程连接
2019独角兽企业重金招聘Python工程师标准>>> 一.安装 1.切换为root账户,安装redis所需的必要包 yum install gcc 2.进入要安装redis的路径下 ...
- Linux安装redis自启动详解
认识你自己.--德尔斐的阿波罗神庙三句箴言之一 1准备工作 链接工具:Xshell (作者使用Xshell7) Linux系统:CentOS.Ubuntu等系统都可以(作者使用CentOS8.2) r ...
- centos 6.5 安装、配置redis
redis是一种高级的Key-value数据库.它跟memcached类似,不过数据可持久化,而且支持的数据类型丰富.有字符型.链表.集合.和有序集合,支持在服务器短计算集合的并.交和补集等, ...
- linux开发板开机自启动脚本,linux 添加开机自启动脚本
Linux设置服务开机自动启动的方式有好多种,这里介绍一下通过chkconfig命令添加脚本为开机自动启动的方法. 1. 编写脚本autostart.sh(这里以开机启动redis服务为例),脚本内容 ...
最新文章
- vue从后台获取新数据后刷新_vue项目中实现定时刷新页面(重新渲染数据实时更新)...
- No Team Selected:A team must be selected to run 'ProjectName' on iPhoneName
- 52条SQL语句性能优化策略
- ways to improve your presentation by your own
- pymysql.err.OperationalError: (1203, “User root already has more than ‘max_user_connections‘ active
- 在Python当中如何打印输出当前时间(代码)
- RTX5 | 事件标志组02 - 置位事件标志组,并获取事件标志组的值
- android监控方法耗时开源库,【开源完整项目】 AndroidGodEye 监控Android数据指标
- iis7mysql 链接不上_Win7 64位IIS7出现数据库链接出错的解决办法
- 详解Python正则表达式之: (?Pname…) named group 带命名的组
- 程序员入门:如何自学编程
- 商业研究(12):下厨房,美食菜谱分享社区及新型电商,唯有美食与爱不可辜负
- Mac访问微软远程桌面Microsoft Remote Desktop For Mac
- 计算机毕业设计之java+javaweb的蛋糕甜品商城系统
- R语言使用dcauchy函数生成柯西分布密度函数数据、使用plot函数可视化柯西分布密度函数数据(Cauchy distribution)
- java换行转义字符串_回车,换行,转义字符“\r”,“\n”是什么关系?
- CRMEB 商城分销功能
- 网易我的世界服务器存档在哪个文件夹,网易版我的世界如何删除玩家存档
- 网络协议-DNS与Hosts
- 小米路由器青春版破解使用ssh,非telnet方式