启停脚本(redis-5.0.5)

一、编辑脚本

vim /u01/redis/redisServer.sh

#!/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: redis_6379
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Redis data structure server
# Description: Redis data structure server. See https://redis.io
### END INIT INFO REDISPORT=6379
EXEC=/u01/redis/src/redis-server
CLIEXEC=/u01/redis/src/redis-cli PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/u01/redis/redis.conf"
PWD=`cat $CONF | grep ^requirepass|awk '{print $2}'` 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 -a $PWD -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

二、开机启动

[root@localhost redis]# cp /u01/redis/redis.sh /etc/init.d/redis
[root@localhost redis]# chkconfig --add redis
[root@localhost redis]# systemctl start redis


https://www.cnblogs.com/houchaoying/p/13031041.html

三、使用systemV启动方法

编写启动脚本

vim /lib/systemd/system/redis.service

[Unit]
Description=Redis
After=network.target
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/opt/redis6/bin/redis-server /opt/redis6/bin/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

四、开机启动

使用systemctl命令
# 重载服务
systemctl daemon-reload
# 开机自启
systemctl enable redis
# 启动
systemctl start redis
# 重启
systemctl restart redis    
# 停止
systemctl stop redis
# 查看状态
systemctl status redis
# 关闭开机启动
systemctl disable redis

redis启停shell脚本的更多相关文章

  1. 编写Redis启停服务脚本

    脚本内容如下; fi   esac   exit$RETVAL 下载脚本:艺搜下载 将下载下来的脚本放在/etc/init.d/目录下 更改脚本权限 chmod 777 /etc/init.d/red ...

  2. nginx启停shell脚本

    #!/bin/bash # 编写 nginx 启动脚本 # 本脚本编写完成后,放置在/etc/init.d/目录下,就可以被 Linux 系统自动识别到该脚本 # 如果本脚本名为/etc/init.d ...

  3. Redis windows版本的启停bat脚本命令

    Reids windows版本安装 redis windows官网推荐:https://github.com/MicrosoftArchive/redis/releases 下载解压即可. 启停bat ...

  4. 获取redis主从复制链SHELL脚本

    获取redis主从复制链SHELL脚本 vi redisnode.sh #!/bin/sh master_host=$ master_port=$ auth=$ #判断输入密码是否为空,为空则转化为' ...

  5. shell启停服务脚本模板

    一. 启动脚本模板:符合幂等性 如果该服务已经启动,再次调用该脚本,不会报错,也就是说可以反复多次调用,另外启动成功返回 一个参数,提供给自动发布平台校验该服务是否启动 #!/bin/bash ins ...

  6. 编写Nginx启停服务脚本

    在/etc/init.d/目录下创建脚本 vim /etc/init.d/nginx 编写脚本内容:(其中下面2行需要根据情况自行修改) nginxd=/opt/nginx/sbin/nginx ng ...

  7. redis启停

    1 查看服务器上启动的redis服务 开了两个redis单机服务,监听在两个端口. 开了一个集群,监听在6个端口. [root@localhost bin]# ps aux | grep redis ...

  8. centos下的redis一键安装shell脚本

    #!/bin/bash yum install cpp binutils glibc-kernheaders glibc-common glibc-devel gcc make wget #安装依赖库 ...

  9. 数据库MySQL、redis主从切换shell脚本

    具体源码可找我领取

  10. 04. 启停redis服务

    启动 查看redis.conf文件,可以通过general中的说明,配置通过systemd来启停redis和查看redis状态(作者没有采用,而是使用service管理,service配置参考< ...

随机推荐

  1. onlyoffice

    https://helpcenter.onlyoffice.com/installation/docs-enterprise-install-centos.aspx?_ga=2.51626159.76 ...

  2. 多线程编程入门Thread_Task_async_await简单秒懂

    ` using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; u ...

  3. PM2部署DotNet应用程序

    pm2简介 PM2是一个Node.js的进程管理工具,可以帮助开发者简化Node.js应用的部署和运维.它提供了进程守护.负载均衡.日志管理等功能,可以监控应用程序的运行状态,并在发生意外情况时自动重 ...

  4. RHCL8无法使用yum install的解决方法

    ​报错如下: Updating Subscription Management repositories. Unable to read consumer identity This system i ...

  5. openEuler欧拉部署Jenkins

    一.系统优化 关闭防火墙 systemctl stop firewalld systemctl disable firewalld 二.安装Jenkins dnf -y install docker ...

  6. 如何为在线客服系统的 Web Api 后台主程序添加 Bootstrap 启动页面

    背景 我在业余时间开发了一款自己的独立产品:升讯威在线客服与营销系统.这个系统的核心后台主程序,在最早期是完全没有页面,经常有朋友部署之后,一访问是 404,以为没有部署成功.我一看这肯定不行啊,可后 ...

  7. 鸿蒙应用开发从入门到入行 - 篇3:ArkUI布局基础与制作可交互页面

    鸿蒙应用开发从入门到入行 - 篇3:ArkUI布局基础与制作可交互页面 导读:在本篇文章里,您将掌握事件.装饰器.双向绑定等相关知识,并利用所学知识做一个待办列表的案例. 练手案例:登录界面 开始之前 ...

  8. OGC标准地图服务协议总结

    OGC标准地图服务协议总结 1. WMS WMS(Web Map Service)是OGC(Open Geospatial Consortium)定义的一种地图服务协议.它允许客户端通过HTTP请求从 ...

  9. [LC735]行星碰撞

    题目描述 给定一个整数数组 asteroids,表示在同一行的行星.对于数组中的每一个元素,其绝对值表示行星的大小,正负表示行星的移动方向(正表示向右移动,负表示向左移动).每一颗行星以相同的速度移动 ...

  10. Solution Set -「NOIP Simu.」20221011

    「Unknown」找   给出平面上 \(n\) 个点, 对于每个点, 求出它到其他点的欧式距离平方和.   \(n\le2\times10^5\).   Tag:「水题无 tag」   画风正常的签 ...