CentOS 6.5 安装 Redis-3.2.6
Posted 52PHP
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS 6.5 安装 Redis-3.2.6相关的知识,希望对你有一定的参考价值。
到官网下载最新版的 Redis-3.2.6,
我把它放到文件夹:/usr/local/src/centos-sdk/source2/redis
安装脚本 redis-3.2.6.sh
#!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" exit 1 fi setenforce 0 # 临时禁用,不需要重启(推荐)。 ################################################## ### 安装 工具 ################################################## yum install gcc-c++ yum install -y tcl yum install wget ################################################## ### 安装 redis ################################################## cd /usr/local/src/centos-sdk/source2/redis tar -xzvf ./redis-3.2.6.tar.gz mkdir -pv /usr/local/redis/redis-3.2.6 \\cp -rf ./redis-3.2.6/* /usr/local/redis/redis-3.2.6 cd /usr/local/redis/redis-3.2.6 # 测试 redis make cd src make test # 配置 redis mkdir /usr/local/redis/redis-3.2.6/etc \\cp -rf /usr/local/src/centos-sdk/config/redis-3.2.6/redis.conf /usr/local/redis/reids-3.2.6/etc/redis.conf # 开机启动(已弃用) # echo "/usr/local/redis/redis-3.2.6/src/redis-server /usr/local/redis/redis-3.2.6/etc/redis.conf &" >> /etc/rc.local # 启动 redis(已弃用) # /usr/local/redis/redis-3.2.6/src/redis-server /usr/local/redis/redis-3.2.6/etc/redis.conf & # 设置 redis 开机启动 \\cp -rf /usr/local/src/centos-sdk/config/redis-3.2.6/redis.init /etc/rc.d/init.d/redis # 拷贝redis.init到启动目录 chmod +x /etc/rc.d/init.d/redis # 添加执行权限 chkconfig redis on # 设置开机启动 service redis start # 启动 redis
/usr/local/redis/reids-3.2.6/etc/redis.conf 内容如下:
bind 127.0.0.1 protected-mode yes port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize yes supervised no pidfile /var/run/redis.pid 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 /usr/local/redis/data slave-serve-stale-data yes slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-disable-tcp-nodelay no slave-priority 100 requirepass 52php-wenjianbao maxclients 1024 maxmemory 1GB maxmemory-policy allkeys-lru appendonly yes appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes lua-time-limit 5000 slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "" hash-max-ziplist-entries 128 hash-max-ziplist-value 1024 list-max-ziplist-size -2 list-compress-depth 0 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
更详细的介绍:Redis-3.2.6 配置文件中文翻译
/etc/init.d/redis 文件内容如下
# chkconfig: 2345 10 90 # description: Start and Stop redis PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=6379 # 端口 EXEC=/usr/local/redis/redis-3.2.6/src/redis-server # 服务程序 REDIS_CLI=/usr/local/redis/redis-3.2.6/src/redis-cli # 命令行程序 PIDFILE=/var/run/redis.pid CONF="/usr/local/redis/redis-3.2.6/etc/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 if [ "$?"="0" ] then echo "Redis is running..." fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE exists, process is not running." else PID=$(cat $PIDFILE) echo "Stopping..." $REDIS_CLI -p $REDISPORT SHUTDOWN while [ -x $PIDFILE ] do echo "Waiting for Redis to shutdown..." sleep 1 done echo "Redis stopped" fi ;; restart|force-reload) ${0} stop ${0} start ;; *) echo "Usage: $0 {start|stop|restart|force-reload}" >&2 exit 1 esac
延伸阅读:
以上是关于CentOS 6.5 安装 Redis-3.2.6的主要内容,如果未能解决你的问题,请参考以下文章