跳至主要內容

安装redis

zhengcog...大约 1 分钟缓存NoSQL数据库

centos7编译安装redis

wget http://download.redis.io/releases/redis-6.0.6.tar.gz
mkdir -p /usr/local/redis
yum install -y centos-release-scl
yum install -y devtoolset-7-gcc
scl enable devtoolset-7 bash
tar xzf redis-6.0.6.tar.gz
cd redis-6.0.6
make
cp ./src/redis-server ./src/redis-cli ./redis.conf /usr/local/redis/

制作系统启动服务

vi /etc/systemd/system/redis.service

# 贴入内容 开始
[Unit]
Description=redis

[Service]
ExecStart=/usr/local/redis/redis-server /usr/local/redis/redis.conf --daemonize no
Restart=always
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=redis
User=root
LimitNOFILE=1048576
LimitNPROC=1048576

[Install]
WantedBy=multi-user.target
# 贴入内容 结束

启动/重启/停止服务

# 启动
systemctl start redis

# 停止
systemctl stop redis

# 重启
systemctl restart redis

# 设置开机自启
systemctl enable redis

# 取消开机自启
systemctl disable redis

# 查看状态
systemctl status redis

处理启动警告信息

WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

处理方法:

vi /etc/sysctl.conf

# 贴入内容 开始
net.core.somaxconn= 1024
# 贴入内容 结束

sysctl -p

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

处理方法:

vi /etc/sysctl.conf

# 贴入内容 开始
vm.overcommit_memory=1
# 贴入内容 结束

sysctl -p

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.

处理方法:

echo never > /sys/kernel/mm/transparent_hugepage/enabled

vi /etc/rc.local

# 文件内容末尾贴入内容 开始
echo never > /sys/kernel/mm/transparent_hugepage/enabled
# 文件内容末尾贴入内容 结束

警告处理完成后,重启redis即可

上次编辑于:
贡献者: Hyman
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v2.15.5