安装
yum install epel-release
yum install redis
如果要安装最新的redis,需要安装Remi的软件源,官网地址:http://rpms.famillecollet.com/yum install -y http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
然后可以使用下面的命令安装最新版本的redis:yum --enablerepo=remi install redis -y
安装完毕后,即可使用下面的命令启动redis服务systemctl restart redis
Redis客户端redis-cli
允许远程访问vim /etc/redis.conf
# bind 127.0.0.1 ::1
bind 0.0.0.0
# daemonize是守护进程的意思, 改成yes
daemonize yes
设置密码
requirepass HtiL9h661DQspm
设置开机自动systemctl enable redis.service
Redis启动警告解决方案
警告1:
WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. 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
0, 表示内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。
1, 表示内核允许分配所有的物理内存,而不管当前的内存状态如何。
2, 表示内核允许分配超过所有物理内存和交换空间总和的内存
警告2
WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
解决方案:vim /etc/sysctl.conf
# 添加配置
net.core.somaxconn = 1024
查看配置是否成功: sysctl -p
警告3:
WARNING Your system is configured to use the 'xen' clocksource which might lead to degraded performance. Check the result of the [slow-clocksource] system check: run 'redis-server --check-system' to check if the system's clocksource isn't degrading performance.