本文共 2042 字,大约阅读时间需要 6 分钟。
背景:redis做为非常流行的nosql,无论是运维还是开发人员都应该撑握,下面给大家带redis的原码安装
一,安装
1,wget2,tar -zxvf redis-3.2.12.tar.gz
3,cp redis-3.2.12 /usr/local/redis-3.2.12
4,cd /usr/local/redis-3.2.12
5,make && make install
6,cp redis.conf /etc/redis.conf
7.启动:
redis-server /etc/redis.conf二,linux 内核优化:
vim /etc/rc.local
#redis settint
echo never > /sys/kernel/mm/transparent_hugepage/enabledecho 2018 >/proc/sys/net/core/somaxconnvim /etc/sysctl.cnf
vm.overcommit_memory = 1sysctl -p
--备注:
如果不整体这些参数,redis启动时会有告警信息,最重要的是有可能会导致redis一个性能问题,特别是redis并发量比较大的时候====================================================================
第一个警告:The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.意思是:TCP backlog设置值,511没有成功,因为 /proc/sys/net/core/somaxconn这个设置的是更小的128.临时解决方法:(即下次启动还需要修改此值)echo 511 > /proc/sys/net/core/somaxconn永久解决方法:(即以后启动还需要修改此值)将其写入/etc/rc.local文件中。baklog参数实际控制的是已经3次握手成功的还在accept queue的大小。参考linux里的backlog详解第二个警告: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.意思是:overcommit_memory参数设置为0!在内存不足的情况下,后台程序save可能失败。建议在文件 /etc/sysctl.conf 中将overcommit_memory修改为1。临时解决方法:echo "vm.overcommit_memory=1" > /etc/sysctl.conf永久解决方法:将其写入/etc/sysctl.conf文件中。参考:有关linux下redis overcommit_memory的问题第三个警告:you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix thisissue 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 thesetting after a reboot. Redis must be restarted after THP is disabled.意思是:你使用的是透明大页,可能导致redis延迟和内存使用问题。执行 echo never > /sys/kernel/mm/transparent_hugepage/enabled 修复该问题。临时解决方法:echo never > /sys/kernel/mm/transparent_hugepage/enabled。永久解决方法:将其写入/etc/rc.local文件中。转载于:https://blog.51cto.com/538858/2328258