• 安装redis


    yum install gcc-c++
     
    tar -zxvf redis-4.0.10.tar.gz
    cd redis-4.0.10
    make
    make PREFIX=/usr/local/redis install
     
    echo "export PATH=$PATH:/usr/local/redis/bin">>/etc/profile 
    source /etc/profile
     
    cp redis.conf /etc/redis_6379.conf
     

    /etc/redis_6379.conf 文件配置
    port 6379
    daemonize yes
    dir "/data/redis/6379/"
    logfile "6379.log"
    dbfilename "dump-6379.rdb"

    启动redis

    redis-server /etc/redis_6379.conf &

    或者使用 /etc/init.d 的方式,创建下面文件

    vi /etc/init.d/redis_6379

    #/bin/sh
    #Configurations injected by install_server below....

    EXEC=/usr/local/redis/bin/redis-server
    CLIEXEC=/usr/local/redis/bin/redis-cli
    PIDFILE=/var/run/redis_6379.pid
    CONF="/etc/redis_6379.conf"
    REDISPORT="6379"
    #password="chengce243"
     

    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 $password -p $REDISPORT shutdown
                while [ -x /proc/${PID} ]
                do
                    echo "Waiting for Redis to shutdown ..."
                    sleep 1
                done
                echo "Redis stopped"
            fi
            ;;
        status)
            if [ ! -f $PIDFILE ]
            then
                echo 'Redis is not running'
            else
                echo "Redis is running ($(<$PIDFILE))"
            fi
            ;;
        restart)
            $0 stop
            $0 start
            ;;
        *)
            echo "Please use start, stop, restart or status as first argument"
            ;;
    esac

    关闭redis

    redis-cli -p 6379 shutdown

    或者

    /etc/init.d/redis_6379 stop

     
  • 相关阅读:
    k-近邻算法
    配置nginx 高并发 php
    ubuntu上安装mysql 编译安装
    Webpack探索【1】--- 基础知识
    【JavaScript专题】--- 立即执行函数表达式
    Eslint使用指南
    Maven学习笔记【2】 -- 安装和配置
    Maven学习笔记【1】 -- Maven简介
    Git中如何将代码恢复到之前某个节点
    密码硬编码(Password Management: Hardcoded Password)
  • 原文地址:https://www.cnblogs.com/liang545621/p/9410381.html
Copyright © 2020-2023  润新知