一、CentOS 7.0系统下的设置方法
假设Redis已经安装,版本3.2.4
#cd redis-3.2.4
#mkdir /etc/redis
#cp redis.conf /etc/redis/6379.conf
#cp utils/redis_init_script /etc/init.d/redis
#chmod a+x /etc/init.d/redis
#cp src/redis-server /usr/local/bin/
#cp src/redis-cli /usr/local/bin/
#vim /etc/init.d/redis
在脚本文件添加 #chkconfig: 2345 80 90
否则会出现 “redis服务不支持chkconfig”的错误提示
#!/bin/sh
#chkconfig: 2345 80 90
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
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 -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
注册事件,开机启动
#chkconfig redis on
启动服务
#service redis start
查看服务是否启动
#lsof -i:6379
二、Debian 8.0设置方法
步骤与上面类似,不过Debian 用update-rc.d (或insserv)代替chkconfig
脚本文件描述也不一样。
假设Redis已经安装,版本3.2.4
#cd redis-3.2.4
#mkdir /etc/redis
#cp redis.conf /etc/redis/6379.conf
#cp utils/redis_init_script /etc/init.d/redis
#chmod a+x /etc/init.d/redis
#cp src/redis-server /usr/local/bin/
#cp src/redis-cli /usr/local/bin/
#vim /etc/init.d/redis
在脚本文件添加
### BEGIN INIT INFO
# Provides: redis6379
# Required-Start: $local_fs $network
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis6379
# Description: penavico redis 6379
### END INIT INFO
否则会出现 “ insserv: warning: script ‘redis6379′ missing LSB tags and overrides”的错误提示
#!/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: redis6379
# Required-Start: $local_fs $network
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis6379
# Description: penavico redis 6379
### END INIT INFO
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
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 -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
注册事件,开机启动
#update-rc.d redisd defaults
启动服务
#service redis start
查看服务是否启动
#lsof -i:6379
开机启动以后,默认的配置文件位置:/etc/redis/6379.conf
打造万能Windows封装包 封装软件包
打造万能Windows封装包 对于那些经常需要给朋友攒机或者重新安装操作系统的电脑高手来说,每次安装Windows系统所经历的漫长等待无异于一次折磨。虽然身边有(31)人阅读时间:2024-10-07修改注册表加快Windows(修改注册表加快网速)
修改注册表加快Windows 7关机速度 关机更迅速,操作简单方便,何乐而不为呢! 在Windows7系统的“开始”菜单的搜索框中输入“regedit”打开注册(29)人阅读时间:2024-10-07windows关闭默认共享(windows7关闭默认共享)
windows关闭默认共享 一、运行–CMD–net share 会显示你的电脑的共享情况 二、如果有些没有关闭:net share c$ /d net sha(25)人阅读时间:2024-10-07windows安装redis缓存使用图文教程(window 安装redis)
windows安装redis缓存使用图文教程 下载安装 通过https://github.com/mythz/redis-windows这里可以直接下载,然后解(27)人阅读时间:2024-10-07打造万能Windows封装包 封装软件包
打造万能Windows封装包 对于那些经常需要给朋友攒机或者重新安装操作系统的电脑高手来说,每次安装Windows系统所经历的漫长等待无异于一次折磨。虽然身边有..2024-10-07修改注册表加快Windows(修改注册表加快网速)
修改注册表加快Windows 7关机速度 关机更迅速,操作简单方便,何乐而不为呢! 在Windows7系统的“开始”菜单的搜索框中输入“regedit”打开注册..2024-10-07windows关闭默认共享(windows7关闭默认共享)
windows关闭默认共享 一、运行–CMD–net share 会显示你的电脑的共享情况 二、如果有些没有关闭:net share c$ /d net sha..2024-10-07windows安装redis缓存使用图文教程(window 安装redis)
windows安装redis缓存使用图文教程 下载安装 通过https://github.com/mythz/redis-windows这里可以直接下载,然后解..2024-10-07