Redis的安装
本文是基于CentOS 7.3系统环境,进行Redis的安装
- Redis-4.0.11
- CentOS 7.3
一、Redis简介
(1) 什么是Redis
Redis(Remote Dictionary Server ),即远程字典服务,是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API
二、Redis安装
(1) 下载安装包
(2) 安装依赖包
yum install gcc-c++ -y
(3) 解压安装包
tar -xzvf redis-4.0.11.tar.gz
(4) 安装redis-4.0.11
cd redis-4.0.11 make make install
(5) 配置redis
cd redis-4.0.11 vi redis.conf # 注释掉 bind 127.0.0.1 protected-mode no deamonize yes
(6) 配置开机启动
vi /etc/init.d/redis # #!/bin/bash # chkconfig: 2345 90 10 # description: Redis is a persisten key-value database PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=6379 EXEC=/usr/local/bin/redis-server REDIS_CLI=/usr/local/bin/redis-cli PIDFILE=/var/run/redis.pid CONF="/root/redis/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 ${PIDFILE} ] do echo "Waiting for Redis to shutdown..." sleep 1 done echo "Redis stopped" fi ;; restart) "$0" stop sleep 3 "$0" start ;; *) echo "Please use start or stop or restart as first argument" >&2 exit 1 esac chmod 755 redis chkconfig --add /etc/init.d/redis chkconfig redis on