标签:redis
Redis最新版本是2.8.19
cd /data/app_software/
wget http://download.redis.io/releases/redis-2.8.19.tar.gz
tar zxvf redis-2.8.19.tar.gz
make
mkdir -p /data/app_platform/redis/{bin,conf}
cp src/redis-server /data/app_platform/redis/bin/
cp src/redis-cli /data/app_platform/redis/bin/
cp src/redis-benchmark /data/app_platform/redis/bin/
cp src/redis-check-dump /data/app_platform/redis/bin/
cp src/redis-check-aof /data/app_platform/redis/bin/
cp redis.conf /data/app_platform/redis/conf/
修改/data/app_platform/redis/conf/redis.conf配置,具体配置根据各自需要进行设置
redis 2.8中新增加的配置
# TCP listen() backlog. # # In high requests-per-second environments you need an high backlog in order # to avoid slow clients connections issues. Note that the Linux kernel # will silently truncate it to the value of /proc/sys/net/core/somaxconn so # make sure to raise both the value of somaxconn and tcp_max_syn_backlog # in order to get the desired effect. tcp-backlog 511
$ grep -E -v ‘^#|^$‘ /data/app_platform/redis/conf/redis.conf daemonize yes pidfile /var/run/redis.pid port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 0 loglevel notice logfile /data/app_data/redis/logs/redis.log 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 /data/app_data/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 appendonly no 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 512 hash-max-ziplist-value 64 list-max-ziplist-entries 512 list-max-ziplist-value 64 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
添加启动文件/etc/init.d/redis
#!/bin/bash # # redis - this script starts and stops the redis-server daemon # # chkconfig: - 80 12 # description: Redis is a persistent key-value database # processname: redis-server # config: /etc/redis/redis.conf # pidfile: /var/run/redis.pid source /etc/init.d/functions BIN="/data/app_platform/redis/bin" CONFIG="/data/app_platform/redis/conf/redis.conf" PIDFILE="/var/run/redis.pid" ### Read configuration [ -r "$SYSCONFIG" ] && source "$SYSCONFIG" RETVAL=0 prog="redis-server" desc="Redis Server" start() { if [ -e $PIDFILE ];then echo "$desc already running...." exit 1 fi echo -n $"Starting $desc: " daemon $BIN/$prog $CONFIG RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog return $RETVAL } stop() { echo -n $"Stop $desc: " killproc $prog RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog $PIDFILE return $RETVAL } restart() { stop start } case "$1" in start) start ;; stop) stop ;; restart) restart ;; condrestart) [ -e /var/lock/subsys/$prog ] && restart RETVAL=$? ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" RETVAL=1 esac exit $RETVAL
启动Redis后查看下日志
chkconfig --level 35 redis on
service redis start
cat /data/app_data/redis/logs/redis.log [16854] 24 Jan 22:31:27.113 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ‘‘-._ _.-`` `. `_. ‘‘-._ Redis 2.8.19 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ‘‘-._ ( ‘ , .-` | `, ) Running in stand alone mode |`-._`-...-` __...-.``-._|‘` _.-‘| Port: 6379 | `-._ `._ / _.-‘ | PID: 16854 `-._ `-._ `-./ _.-‘ _.-‘ |`-._`-._ `-.__.-‘ _.-‘_.-‘| | `-._`-._ _.-‘_.-‘ | http://redis.io `-._ `-._`-.__.-‘_.-‘ _.-‘ |`-._`-._ `-.__.-‘ _.-‘_.-‘| | `-._`-._ _.-‘_.-‘ | `-._ `-._`-.__.-‘_.-‘ _.-‘ `-._ `-.__.-‘ _.-‘ `-._ _.-‘ `-.__.-‘ [16854] 24 Jan 22:31:27.114 # Server started, Redis version 2.8.19 [16854] 24 Jan 22:31:27.114 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add ‘vm.overcommit_memory = 1‘ to /etc/sysctl.conf and then reboot or run the command ‘sysctl vm.overcommit_memory=1‘ for this to take effect. [16854] 24 Jan 22:31:27.114 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command ‘echo never > /sys/kernel/mm/transparent_hugepage/enabled‘ as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled. [16854] 24 Jan 22:31:27.114 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. [16854] 24 Jan 22:31:27.115 * The server is now ready to accept connections on port 6379
根据日志提示调整系统配置
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf ;sysctl -p
echo never > /sys/kernel/mm/transparent_hugepage/enabled 并且把这行添加到/etc/rc.local中使主机重启后仍然生效
echo "net.core.somaxconn = 2048" >> /etc/sysctl.conf;sysctl -p
然后再重新启动Redis
本文出自 “Linux SA John” 博客,请务必保留此出处http://john88wang.blog.51cto.com/2165294/1607834
标签:redis
原文地址:http://john88wang.blog.51cto.com/2165294/1607834