下载redis源码包到/opt/解压并改名为redis,也可以直接从官网下载上传至服务器安装目录
root@apiserver01:/opt/redis/logs# cd /opt/ root@apiserver01:/opt# ls install_saltminion.sh install_zabbixagent.sh nimsoft redis redis-3.2.1.tar.gz zabbix-release_2.4-1+wheezy_all.deb zeus root@apiserver01:/opt# |
建立必要的文件目录
root@apiserver01:/opt/redis# cd /opt/redis/;mkdir {conf,data,logs,bin,pids} root@apiserver01:/opt/redis# ls 00-RELEASENOTES BUGS CONTRIBUTING data INSTALL Makefile README.md runtest runtest-sentinel src utils bin conf COPYING deps logs MANIFESTO redis.conf runtest-cluster sentinel.conf tests root@apiserver01:/opt/redis# |
执行make并copy可执行文件到/opt/redis/bin目录
root@apiserver01:/opt/redis# make root@apiserver01:/opt/redis# cp src/{redis-cli,redis-server,redis-sentinel,redis-check-rdb,redis-check-aof} ../bin -rp root@apiserver01:/opt/redis# ls bin/ redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server root@apiserver01:/opt/redis# |
执行安装脚本
root@apiserver02:/opt/redis/utils# ./install_server.sh Welcome to the redis service installer This script will help you easily set up a running redis server Please select the redis port for this instance: [6379] Selecting default: 6379 Please select the redis config file name [/etc/redis/6379.conf] /opt/redis/conf/6379.conf Please select the redis log file name [/var/log/redis_6379.log] /opt/redis/logs/redis_6379.log Please select the data directory for this instance [/var/lib/redis/6379] /opt/redis/data Please select the redis executable path [] /opt/redis/bin/redis-server Selected config: Port : 6379 Config file : /opt/redis/conf/6379.conf Log file : /opt/redis/logs/redis_6379.log Data dir : /opt/redis/data Executable : /opt/redis/bin/redis-server Cli Executable : /opt/redis/bin/redis-cli Is this ok? Then press ENTER to go on or Ctrl-C to abort. Copied /tmp/6379.conf => /etc/init.d/redis_6379 Installing service... update-rc.d: using dependency based boot sequencing insserv: warning: script ‘K01apf‘ missing LSB tags and overrides insserv: warning: script ‘apf‘ missing LSB tags and overrides Success! Starting Redis server... Installation successful! root@apiserver02:/opt/redis/utils# /etc/init.d/redis_6379 stop Stopping ... Redis stopped root@apiserver02:/opt/redis/utils# |
启动并查看日志
2571:M 09 Jul 17:36:51.448 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 2571:M 09 Jul 17:36:51.448 # Server started, Redis version 3.2.1 2571:M 09 Jul 17:36:51.448 # 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. 2571:M 09 Jul 17:36:51.449 # 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. |
修改系统参数,解决redis启动WARNING
echo 511 > /proc/sys/net/core/somaxconn echo "vm.overcommit_memory = 1” >> /etc/sysctl.conf echo never > /sys/kernel/mm/transparent_hugepage/enabled |
本文出自 “linux系统” 博客,请务必保留此出处http://rovkxu.blog.51cto.com/4358086/1834844
原文:http://rovkxu.blog.51cto.com/4358086/1834844