linux 开机启动设置密码,Linux下Redis设置密码及开机自启动
1、設置Redis.conf中daemonize為yes,確保守護進程開啟;
找到#requirepass foorbared這一行,直接替換掉這行,改為requirepass 新密碼
2、編寫開機自啟動腳本vi?/etc/init.d/redis
腳本內容如下:#!/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
3、寫完后保存退出
4、設置權限chmod?755?redis
5、啟動測試/etc/init.d/redis?start
6、連接測試redis-cli?-a?新密碼?-p?6379
7、設置開機自啟動chkconfig?redis?on
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的linux 开机启动设置密码,Linux下Redis设置密码及开机自启动的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 软控股份是做什么的
- 下一篇: 年底离职员工感慨 裸辞真的需要勇气