redis啟動過程

來源:互聯網
上載者:User

標籤:使用   io   檔案   for   ar   art   cti   代碼   log   

redis啟動分為兩種:開發環境、生產環境

一、開發環境

        1、cd redis-2.8.13/src

        2、 ./redis-server 啟動服務端

        3、./redis-cli       啟動用戶端

二、生產環境(隨系統開機啟動)

        1、配置redis初始化指令碼(樣本在/redis-2.8.13/utils/下),並放在/etc/init.d/下(命名為redis_6379)

#!/bin/sh

#

# 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

        如何修改此初始化指令檔:修改redis服務端要監聽的連接埠號碼:6379(預設)

 

        二、在/etc目錄下建立目錄:/etc/redis  和   /var/redis/6379,並存放相應的檔案

    1、/etc/redis/    存放設定檔,命名為6379.cof (模板在原始碼目錄/redis-2.8.13/)

edis configuration file example

daemonize no                    //修改為yes    使redis以守護進程模式啟動

pidfile /var/run/redis.pid        //修改為/var/run/redis_6379.pid    設定redis的PID檔案的路徑

port 6379                            //修改為6379    監聽連接埠號碼

timeout 0

loglevel notice

logfile ""

databases 16

save 900 1

save 300 10

save 60 10000

stop-writes-on-bgsave-error yes

rdbcompression yes

rdbchecksum yes

dbfilename dump.rdb

dir ./                                                    //修改為/var/redis/6379    設定持久化檔案的路徑

slave-serve-stale-data yes

slave-read-only yes

repl-disable-tcp-nodelay no

slave-priority 100

appendonly no

appendfilename "appendonly.aof"

appendfsync everysec

no-appendfsync-on-rewrite no

auto-aof-rewrite-percentage 100

auto-aof-rewrite-min-size 64mb

lua-time-limit 5000

slowlog-max-len 128

latency-monitor-threshold 0

notify-keyspace-events ""

hash-max-ziplist-entries 512

hash-max-ziplist-value 64

list-max-ziplist-entries 512

list-max-ziplist-value 64

set-max-intset-entries 512

zset-max-ziplist-entries 128

zset-max-ziplist-value 64

hll-sparse-max-bytes 3000

activerehashing yes

client-output-buffer-limit normal 0 0 0

client-output-buffer-limit slave 256mb 64mb 60

client-output-buffer-limit pubsub 32mb 8mb 60

hz 10

aof-rewrite-incremental-fsync yes


    2、在/var/redis/連接埠號碼 目錄下存放 持久化檔案 (使用該組件時在存放)

    3、sudo update-rc.d   redis_6379   defaults  (配置隨機啟動命令  redis_6379為初始化指令檔)


redis啟動過程

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.