Redis安装
1、解压Redis压缩包
/usr/local/redis
tar -zxvf redis-5.0.4.tar.gz
2、编译redis二进制
安装到指定目录中
cd /usr/local/redis/redis-5.0.4
make PREFIX=/usr/local/redis/redis-5.0.4 install
3、启动redis
cd /usr/local/redis/redis-5.0.4/bin
./redis-server ../redis.conf
4、常见警告处理
WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
echo 1024 > /proc/sys/net/core/somaxconn
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.
echo 1 > /proc/sys/vm/overcommit_memory
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.
vim /etc/rc.local
echo 1024 > /proc/sys/net/core/somaxconn
echo never > /sys/kernel/mm/transparent_hugepage/enabled
注意:Centos7已经写了要chmod +x /etc/rc.d/rc.local 授权一下才会起作用
vim /etc/sysctl.conf
vm.overcommit_memory = 1
5、修改配置文件
- 修改端口号
port 6379
- 修改守护进程
daemonize no
- 修改密码
requirepass foobared