vim
/etc/init
.d
/redisc
將下方指令碼寫入redisc檔案中
#!/bin/sh
# chkconfig: 2345 80 90
## ****** redis init.d script conceived to work on linux systems
# as it does use of the /proc filesystem.
ip=192.168.6.51
redisport0=7000
redisport1=7001
redisport2=7002
#redisport3=7003
#redisport4=7004
#redisport5=7005
exec=/usr/local/redis/redis-3.2.4/src/redis-server
cliexec=/usr/local/redis/redis-3.2.4/src/redis-cli
pidfile=/var/run/redis_$.pid
conf0="/usr/local/redis/redis_cluster/$/redis.conf"
conf1="/usr/local/redis/redis_cluster/$/redis.conf"
conf2="/usr/local/redis/redis_cluster/$/redis.conf"
#conf3="/usr/local/redis/redis_cluster/$/redis.conf"
#conf4="/usr/local/redis/redis_cluster/$/redis.conf"
#conf5="/usr/local/redis/redis_cluster/$/redis.conf"
case "$1" in
start)
if [ -f $pidfile ]
then
echo "$pidfile exists, process is already running or crashed"
else
echo "starting redis cluster server..."
$exec $conf0 &
$exec $conf1 &
$exec $conf2 &
#$exec $conf3 &
#$exec $conf4 &
#$exec $conf5 &
echo "啟動成功..."
fi;;
stop)
if [ ! -f $pidfile ]
then
echo "$pidfile does not exist, process is not running"
else
pid=$(cat $pidfile)
echo "stopping ..."
$cliexec -h $ip -p $redisport0 shutdown
$cliexec -h $ip -p $redisport1 shutdown
$cliexec -h $ip -p $redisport2 shutdown
#$cliexec -h $ip -p $redisport3 shutdown
#$cliexec -h $ip -p $redisport4 shutdown
#$cliexec -h $ip -p $redisport5 shutdown
while [ -x /proc/$ ]
doecho "waiting for redis cluster to shutdown ..."
sleep 1
done
echo "redis cluster stopped"
fi;;
*)echo "please use start or stop as first argument"
;;esac
1.註冊為系統服務
chkconfig --add redisc
以後可以使用命令來控制redis的啟動和關閉
啟動:service redisc start
關閉:service redisc stop
設定許可權: chmod 777 redisc 後就可以啟動/關閉了
檢視服務列表: chkconfig --list
2.配置為開機自啟動
chkconfig redisc on
CentOS 7 安裝配置Redis
wget tar xzvf redis 3.2.8.tar.gz 切換至程式目錄,並執行make命令編譯 cd redis 3.2.8 make執行安裝命令 make installmake install安裝完成後,會在 usr local bin目錄下生成下面幾個可執行檔案,它們的作用分別是 備...
centos7安裝配置redis
關閉防火牆 systemctl stop firewalld.service 停止firewall systemctl disable firewalld.service 禁止firewall開機啟動 firewall cmd state 檢視預設防火牆狀態 關閉後顯示notrunning,開啟後顯...
Centos 7安裝配置redis
個人 yum install wget wget tar zxvf redis stable.tar.gz yum install gcc y cd redis stable make malloc libc cd src make install 等待安裝成功即可 vim root redis s...