好上居,黄长健,织缘网
shell>vi start-redis.sh #!/bin/bash source /etc/profile redis_home=/ghca/redis-3.2.6 $redis_home/bin/redis-server $redis_home/etc/redis.conf
shell>$redis_home/bin/redis-server redis.conf #即可,不过可以在启动命令总添加参数
shell>redis -h host/ip -p port shutdown 向redis-server端发送shutdown命令
#!/bin/sh redisport=6666 exec=./redis-server cliexec=./redis-cli authpasswd='passwd_by_zjq;' # 如果设置了密码,这里是需要设置的,因为利用redis-cli 发送shutdown信号需要提供密码。 pidfile=/ghca/redis/bin/redis_${redisport}.pid conf="/ghca/redis/etc/redis.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 -a $authpasswd -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
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
理解Redis持久化,RDB持久化和AOF持久化的不同处理方式
Redis 两类持久化方式,快照和全量追加日志的不同处理方式
网友评论