redis 3.2.13安装部署(centos7)

    技术2022-07-10  104

    一、安装部署

    1.linux安装(centos 7)

    (1)下载

    http://download.redis.io/releases/redis-3.2.13.tar.gz

    (2)gcc检查(若没有gcc则网上下载相关rpm,本人下载并打包了一个gcc.tar.gz) https://download.csdn.net/download/xiaolilian007/12564824

    # gcc --version # tar xzvf gcc.tar.gz # cd gcc # rpm -Uvh *.rpm --nodeps --force # gcc --version gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)

    (3)创建目录

    # mkdir -p /usr/local/xiaoll/redis # cd /usr/local/xiaoll/redis/

    (4)上传文件(redis-3.2.13.tar.gz)至该目录

    (5)解压

    # tar xzvf redis-3.2.13.tar.gz

    (6)编译

    # cd redis-3.2.13 # make MALLOC=libc

    (7)启动

    # cd src/ # ./redis-server

    (8)添加开机自启,并添加到系统服务

    ①复制redis配置文件(保护模式关闭,不绑定ip,守护进程(后台模式)打开)

    # mkdir /etc/redis # cd .. # cp redis.conf /etc/redis/6379.conf # vi /etc/redis/6379.conf 修改protected-mode yes,改为 protected-mode no 注释 bind 127.0.0.1, #bind 127.0.0.1 修改daemonize no ,改为 daemonize yes

    ②将启动文件拷贝至init.d中并修改部分内容(chkconfig/description/EXEC/CLIEXEC/PIDFILE)

    # cp utils/redis_init_script /etc/init.d/redisd # vi /etc/init.d/redisd #!/bin/sh # # chkconfig: 2345 10 90 # description: Start and Stop redisd # Simple Redis init.d script conceived to work on Linux systems # as it does use of the /proc filesystem. REDISPORT=6379 EXEC=/usr/local/xiaoll/redis/redis-3.2.13/src/redis-server CLIEXEC=/usr/local/xiaoll/redis/redis-3.2.13/src/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

    ③授予执行权限

    # chmod +x /etc/init.d/redisd

    ④添加到系统服务

    # chkconfig --add redisd # chkconfig --list redisd

    ⑤启动并检查是否成功

    # service redisd start # ps -ef | grep redis

    ⑥重启服务器,检验开机自启是否配置成功

    Processed: 0.013, SQL: 9