Centos7瀹夎骞堕厤缃畆edis

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7瀹夎骞堕厤缃畆edis相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/%e5%bc%80%e5%90%af' title='寮€鍚?>寮€鍚?/a>   鍘绘帀   isp   瀹氫箟   娣诲姞   exists   opp   filesyste   

涓€銆佷笅杞絩edis-5.0.5瀹夎鍖?/span>

# wget http://download.redis.io/releases/redis-5.0.5.tar.gz

浜屻€佽В鍘嬪帇缂╁寘鑷虫寚瀹氱洰褰?br />

# mkdir -p /home/mark/tools
# tar zxvf redis-5.0.5.tar.gz -C /home/mark/tools/

涓夈€佽浆鍒皉edis瑙e帇鐩綍

# cd redis-5.0.5/

鍥涖€佺紪璇戝畨瑁?/span>

# make MALLOC=libc
灏?/span>/redis-5.0.5/src鐩綍涓嬬殑鏂囦欢娣诲姞鑷?usr/local/bin鐩綍
# cd src/ && make install

浜斻€佽缃畆edis寮€鏈鸿嚜鍚?/span>

淇敼redis.conf鏂囦欢
    daemonize no 鏀逛负 daemonize yes
    # sed -i 鈥榮/daemonize no/daemonize yes/g鈥?../redis.conf
1銆佸湪/etc鐩綍涓嬫柊寤簉edis鐩綍
    # mkdir -p /etc/redis
2銆佸皢/redis-5.0.5/redis.conf 鏂囦欢澶嶅埗涓€浠藉埌/etc/redis鐩綍涓嬶紝骞跺懡鍚嶄负6379.conf銆€
    # cp /home/mark/tools/redis-5.0.5/redis.conf /etc/redis/6379.conf
3銆佸皢redis鐨勫惎鍔ㄨ剼鏈鍒朵竴浠芥斁鍒?etc/init.d鐩綍涓?    # cp /home/mark/tools/redis-5.0.5/utils/redis_init_script /etc/init.d/redisd
4銆佽缃紑鏈鸿嚜鍚?    # systemctl enable redisd
5銆佸紑鍚湇鍔?amp;鏌ョ湅鏈嶅姟鐘舵€?    # systemctl start redisd
    # systemctl status redisd.service
    鈼?redisd.service - LSB: Redis data structure server
       Loaded: loaded (/etc/rc.d/init.d/redisd; bad; vendor preset: disabled)
       Active: active (running) since 浜?2020-06-09 17:50:19 CST; 7min ago
         Docs: man:systemd-sysv-generator(8)
       CGroup: /system.slice/redisd.service
               鈹斺攢10153 /usr/local/bin/redis-server 127.0.0.1:6379

鍏€佽缃鎴风鐧诲綍瀵嗙爜

缂栬緫redis.conf鏂囦欢锛屾悳绱equirepass鍏抽敭瀛楋紝鍘绘帀娉ㄩ噴鍚庯紝鎶奻oobared鏇挎崲涓鸿嚜宸辩殑瀵嗙爜鍗冲彲锛?# vim ../redis.conf
requirepass 123456

涓冦€佹洿鏀瑰畬瀹㈡埛绔櫥褰曞瘑鐮侊紝Redis鏈嶅姟鍋滄鎶ラ敊瑙e喅鏂规

1銆佷慨鏀箁edis鏈嶅姟鑴氭湰锛屽姞鍏ュ涓嬫墍绀虹殑绾㈣壊鎺堟潈淇℃伅鍗冲彲锛?    vi /etc/init.d/redis

    $CLIEXEC -a "youpassword" -p $REDISPORT shutdown

2銆佹垨娣诲姞涓€涓瘑鐮佸彉閲忥紝鐩存帴寮曠敤濡備笅锛?    #!/bin/sh
    #
    # Simple 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 https://redis.io
    ### END INIT INFO

    REDISPORT=6379
    EXEC=/usr/local/bin/redis-server
    CLIEXEC=/usr/local/bin/redis-cli
    RESDISPASSWORD=123456            ###瀹氫箟瀵嗙爜鍙橀噺

    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 -a $RESDISPASSWORD -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"
            ;;
閲嶆柊鍔犺浇鏈嶅姟閰嶇疆鏂囦欢
# systemctl daemon-reload

 

以上是关于Centos7瀹夎骞堕厤缃畆edis的主要内容,如果未能解决你的问题,请参考以下文章

Mac涓婄殑redis瀹夎涓巎edis鍏ラ棬

mac锛欸o瀹夎鍜岄厤缃?GoLand瀹夎鍜屼娇鐢ㄤ箣瀹屾暣鏁欑▼

Spring Boot锛堝崄涓€锛塕edis闆嗘垚浠嶥ocker瀹夎鍒板垎甯冨紡Session鍏变韩

Cisco 浜ゆ崲鏈洪厤缃殑鍩烘湰鍛戒护

Postgresql鏃ュ織鏀堕泦