本次博文采用redis-5.0.5!
$ yum install gcc c++
$ wget http://download.redis.io/releases/redis-5.0.5.tar.gz
$ tar zxf redis-5.0.5.tar.gz && cd redis-5.0.5
$ make
$ mkdir -p /usr/local/redis/{bin,conf,data,logs}
$ cp /root/redis-5.0.5/src/redis* /usr/local/redis/bin/
$ cp /root/redis-5.0.5/redis.conf /usr/local/redis/conf/
$ cd /usr/local/redis/bin/
$ rm -f *.{c,h,o}
$ cd /usr/local/redis/conf/
$ cp redis.conf{,.bak}
$ egrep -v ‘^$|^#‘ redis.conf.bak > redis.conf
$ vim /usr/local/redis/conf/redis.conf
# 仅仅标注需要修改的内容
bind 0.0.0.0 # 更改位监听所有地址
port 6379 # 监听的端口
daemonize yes # 启用守护进程
pidfile /usr/local/redis/data/redis_6379.pid # 指定pid文件
logfile "/usr/local/redis/logs/redis.log" # 指定日志文件
$ echo ‘export PATH=${PATH}:/usr/local/redis/bin‘ >> /etc/profile
$ source /etc/profile
$ redis-server -v
Redis server v=5.0.5 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=5a375fdbca3fe645
$ redis-server /usr/local/redis/conf/redis.conf
$ ss -anpt | grep 6379
LISTEN 0 128 *:6379 *:* users:(("redis-server",pid=22753,fd=6)
$ redis-cli # 本地连接
127.0.0.1:6379>
$ redis-cli -h 10.4.7.101 -p 6379 # 远端连接,则需要指定IP及端口
10.4.7.101:6379>
$ cat /usr/local/redis/logs/redis.log
接下来就解决这些warning问题。
$ ulimit -n # 查看当前值
1024
$ echo ‘* - nofile 65535‘ >> /etc/security/limits.conf
# 修改后,重新登录即可生效,重新登录后再次查看当前值
$ ulimit -n
65535
$ echo "net.core.somaxconn = 1024" > /etc/sysctl.d/redis.conf
$ sysctl -p /etc/sysctl.d/redis.conf #刷新使其生效
net.core.somaxconn = 1024
$ echo "vm.overcommit_memory = 1" >> /etc/sysctl.d/redis.conf
$ sysctl -p /etc/sysctl.d/redis.conf # 刷新使其生效
net.core.somaxconn = 1024
vm.overcommit_memory = 1
$ echo never > /sys/kernel/mm/transparent_hugepage/enabled
# 上述指令只是当前生效,重启后就会失效,接下来改为永久生效
$ echo ‘echo never > /sys/kernel/mm/transparent_hugepage/enabled‘ >> /etc/rc.local
$ chmod +x /etc/rc.d/rc.local
至此,reboot重启服务器也好,只是重启redis服务也好,都不会再报哪些warning问题了。如下:
原文:https://www.cnblogs.com/lvzhenjiang/p/14359730.html