1.打开终端ctrl+alt+t
2.输入命令sudo apt-get update
3.输入命令sudo apt-get install redis-server
4.下载完成后,启动redis,输入redis-server
我们会发现出现许多警告,不要急,一个一个解决.
1)The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
2)WARNING overcommit_memory is set to 0! Background save may fail under low memory condition.
这两个错误,可以同时解决
进入etc目录,打开sysctl.conf文件
cd etc
sudo gedit sysctl.conf
进入文件,加入net.core.somaxconn= 1024 和 vm.overcommit_memory=1 保存
3)WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis.
第三个警告,在rc.local文件,在加一句echo never > /sys/kernel/mm/transparent_hugepage/enabled 保存(命令:cd etc sudo gedit rc.local )
4)最后重启(命令: reboot)
5.重启之后,启动redis(命令: redis-server)
先前的警告就消失.
6.连接一下redis服务器,并测试一下.