安裝使用Redis

來源:互聯網
上載者:User

標籤: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 yespidfile /var/run/redis.pidport 6379tcp-backlog 511timeout 0tcp-keepalive 0loglevel noticelogfile /data/app_data/redis/logs/redis.logdatabases 16save 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbdir /data/app_data/redis/data slave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100appendonly noappendfilename "appendonly.aof"appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events ""hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-entries 512list-max-ziplist-value 64set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-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.pidsource /etc/init.d/functionsBIN="/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=0prog="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=1esacexit $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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.