redis启停shell脚本
启停脚本(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脚本的更多相关文章
- 编写Redis启停服务脚本
脚本内容如下; fi esac exit$RETVAL 下载脚本:艺搜下载 将下载下来的脚本放在/etc/init.d/目录下 更改脚本权限 chmod 777 /etc/init.d/red ...
- nginx启停shell脚本
#!/bin/bash # 编写 nginx 启动脚本 # 本脚本编写完成后,放置在/etc/init.d/目录下,就可以被 Linux 系统自动识别到该脚本 # 如果本脚本名为/etc/init.d ...
- Redis windows版本的启停bat脚本命令
Reids windows版本安装 redis windows官网推荐:https://github.com/MicrosoftArchive/redis/releases 下载解压即可. 启停bat ...
- 获取redis主从复制链SHELL脚本
获取redis主从复制链SHELL脚本 vi redisnode.sh #!/bin/sh master_host=$ master_port=$ auth=$ #判断输入密码是否为空,为空则转化为' ...
- shell启停服务脚本模板
一. 启动脚本模板:符合幂等性 如果该服务已经启动,再次调用该脚本,不会报错,也就是说可以反复多次调用,另外启动成功返回 一个参数,提供给自动发布平台校验该服务是否启动 #!/bin/bash ins ...
- 编写Nginx启停服务脚本
在/etc/init.d/目录下创建脚本 vim /etc/init.d/nginx 编写脚本内容:(其中下面2行需要根据情况自行修改) nginxd=/opt/nginx/sbin/nginx ng ...
- redis启停
1 查看服务器上启动的redis服务 开了两个redis单机服务,监听在两个端口. 开了一个集群,监听在6个端口. [root@localhost bin]# ps aux | grep redis ...
- centos下的redis一键安装shell脚本
#!/bin/bash yum install cpp binutils glibc-kernheaders glibc-common glibc-devel gcc make wget #安装依赖库 ...
- 数据库MySQL、redis主从切换shell脚本
具体源码可找我领取
- 04. 启停redis服务
启动 查看redis.conf文件,可以通过general中的说明,配置通过systemd来启停redis和查看redis状态(作者没有采用,而是使用service管理,service配置参考< ...
随机推荐
- Python之读写Excel
现有的Excel分为两种格式:xls(Excel 97-2003)和xlsx(Excel 2007及以上). Python处理Excel文件主要是第三方模块库xlrd.xlwt.pyexcel-xls ...
- 升级Linux内核版本
```shell# 查看内核版本,jw版本ceph默认format=2, 2.x 及之前的的内核版本需手动调整format=1# 4.x之前要关闭object-map fast-diff deep-f ...
- 如何在 duxapp 中开发一个兼容 RN 的动画库
Taro 一直以来都没有一个能兼容 RN 的动画方案,duxapp 中扩展了 createAnimation 方法,让这个方法兼容了 RN 端,下面让我们来看看实现思路 createAnimation ...
- uni-app下webview支付宝支付调起问题
前情 uni-app是我很喜欢的跨平台框架,它能开发小程序,H5,APP(安卓/iOS),对前端开发很友好,自带的IDE让开发体验也很棒,公司项目就是主推uni-app. 因疫情影响,公司不能组织聚餐 ...
- docker - 将几个目录复制到另一个目录
您如何将多个目录复制到Docker中的目标目录?我不想复制目录内容,而是复制整个目录结构.COPY和ADD命令复制目录内容,展平结构,这是我不想要的.也就是说,如果这些是我的来源: . ├── a │ ...
- shell(希尔)排序------python实现
if __name__ == '__main__': ''' 希尔排序 1.选择一个增量序列t1,t2,...,tk,其中ti>tj,tk=1 2.按增量序列个数K,对序列进行K躺排序 3.每趟 ...
- Qt编写地图综合应用36-覆盖物折线
一.前言 折线图目前应用最广的也是用来绘制各种轨迹,折线图其实就是后面动态轨迹图.飞机航线图的前身,公用的一个方法addPolyline,折线图可以设置颜色.粗细.透明度等属性,如果开启了悬浮绘图工具 ...
- Qt编写的项目作品31-PDF阅读器(雨田哥作品)
一.功能特点 仿WPS界面. 预览PDF文件. 支持PDF预览放大.缩小. 支持目录预览查看. 支持目录点击跳转页查看. 支持页数指定跳转. 支持上一页.下一页.首页.尾页跳转. 支持鼠标拖拽滑动预览 ...
- Spring+MyBatis企业应用实战(第二版)2018-电子书+源码+SQL脚本
Spring+MyBatis企业应用实战(第二版)2018学习资料: 电子书: 链接:https://pan.baidu.com/s/1yAdlA5F_HuZMbO4who5jVw 提取码:58yz ...
- 1. C++快速入门--变量和基本类型, 类别
文章使用obsidian编写, 双链部分可能失效 1 基本内置类型 1.1 算术类型 算术类型介绍 bool 类型 字符类型 整数类型 实数浮点.虚数浮点和 复数浮点 参看如下表 带符号和无符号类型的 ...