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配置参考< ...
随机推荐
- JDK7新特性之G1 GC
Garbage-first garbage collector,简称G1 GC,是最终将用于代替Concurrent Mark-Sweep garbage collector(CMS GC)的新一代垃 ...
- python系统模块之re
正则模块re: 元字符: 字符 描述 . 除换行符外的任意字符 \ 转义字符 [...] 字符集合,匹配任务其中一个 \d 数字:[0-9] \D 非数字:[^\d] \w 单词字符[A-Za-z0- ...
- golang之性能分析工具pprof
PProf 是一个 Go 程序性能分析工具,可以分析 CPU.内存等性能.Go 在语言层面上集成了 profile 采样工具,只需在代码中简单地引入 runtime/ppro 或者 net/http/ ...
- S2P销讯通-主数据对于客户关系管理系统的重要性
由于业务发展,各大企业的业务系统经历了从无到有,从简单到复杂,从而形成了一个又一个的业务系统,比如OA.HR.CRM.ERP等等. 主数据在客户关系管理系统(CRM)中扮演着至关重要的角色.主数据是指 ...
- 远程连接利器:玩转MobaXterm
今天这篇文章轻松不烧脑,主要是想和大家分享一下我在工作中常用的远程管理工具--MobaXterm.这款工具不仅功能强大,而且在日常的远程操作中极为高效,特别适合用来管理远程服务器.MobaXterm结 ...
- 探索Matplotlib-Gallery:Python数据可视化的游乐园
探索matplotlib-gallery:Python数据可视化的游乐园 在数据科学的世界里,数据可视化是一个不可或缺的工具,它帮助我们理解数据.发现模式.并传达信息.Matplotlib是Pytho ...
- jdk安装-windows和linux
下载:见此博客https://www.cnblogs.com/zn19961006/p/12857930.html 一.windows安装 1.很简单,运行exe,然后一直下一步 选安装路径. 注意: ...
- 【C#】【平时作业】习题-10-委托
什么是委托? C# 中的委托(Delegate)类似于 C 或 C++ 中函数的指针. 委托(Delegate) 是存有对某个方法的引用的一种引用类型变量.引用可在运行时被改变. 委托(Delegat ...
- 【Java】【SpringBoot】CP03:热部署
This article is written by Xrilang(Chinese Name:萌狼蓝天) If you want find me ,You can contact me in Bil ...
- https://gitlab.com/volian/nala/-/wikis/Installation
Installation Debian Testing/Sid Nala is officially in the testing and sid repos. sudo apt install ...