redis配置開機自啟動

2021-10-01 12:08:08 字數 2345 閱讀 8910

系統開機啟動時會去載入/etc/init.d/下面的指令碼,通常而言每個指令碼檔案會自定義實現程式的啟動;若想將新的程式開機自啟動,只需在該目錄下新增乙個自定義啟動程式的指令碼,然後設定相應規則即可。

2.1首先我們找到redis的檔案目錄

然後進入utils中,輔助檔案到我們的指令碼啟動處

3.1編輯

1.:為埠配置

2.:全域性通用redis安裝目錄基本配置(根據自身所安裝的進行配置,此處用的我自身的)

3:redis-server所在路徑(不知道在哪,可以 whereis redis-server查詢)

4.redis-cli所在路徑(不知道在哪,可以 whereis redis-cli查詢,一般為redis-server相同目錄)

5.可以不進行修改

6.自身redis.conf所在檔案位置(不知道在哪,可以 whereis redis.conf查詢)

chmod 777 /etc/init.d/redis
查詢redis.conf配置檔案所在位置

whereis redis.conf

修改general所在的守護程序為開啟--yes

成功,附錄:redis指令碼

#!/bin/sh

## ****** 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

### end init info

redisport=6379

redispath=/usr/local/bin

exec=$/redis-server

cliexec=$/redis-cli

pidfile=/var/run/redis_$.pid

conf="/usr/local/redis/redis-4.0.12/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 -p $redisport shutdown

while [ -x /proc/$ ]

doecho "waiting for redis to shutdown ..."

sleep 1

done

echo "redis stopped"

fi;;

*)echo "please use start or stop as first argument"

;;esac

Redis配置開機自啟動

1.redis開啟守護程序 2.新增開啟啟動配置檔案,修改相應值為實際值,完整檔案見最後 3.修改新增redis啟動指令碼許可權為可執行 chmod x redis4.etc init.d stop 出現stopping error noauth authentication required.錯誤...

redis配置為開機自啟動

將redis設定為系統服務,並且開機自啟動。需要完成以下指令碼。bin sh chkconfig 2345 10 90 description start and stop redis path usr local bin sbin usr bin bin redisport 6379 exec u...

redis開機自啟動

一.啟動redis 1.redis server 這種方式啟動,當按ctrl c退出時會關閉啟動 2.redis server 加上 號使redis以後台程式方式執行 二.檢測redis程序後台是否存在的三種方法 1.ps ef grep redis 檢視redis程序 2.netstat lntp...