安装Redis

安装Redis

用户创建

groupadd -g 1001 redis
useradd -g 1001 -u 1001 -s /sbin/nologin redis

安装所需的软件包。

yum install clang make

下載

cd /usr/local/src/
wget -c http://download.redis.io/releases/redis-5.0.5.tar.gz

安裝

tar zxvf redis-5.0.5.tar.gz
cd redis-5.0.5
CC=clang make && make install

设定

mkdir -p /usr/local/redis/dump
cp -pi redis.conf /usr/local/redis/.
vi /usr/local/redis/redis.conf

其他设置需要酌情进行修正。

158c158
< pidfile /var/run/redis_6379.pid
---
> pidfile /var/run/redis.pid
263c263
< dir ./
---
> dir /usr/local/redis/dump

内核参数的调整

sysctl vm.overcommit_memory=1
sysctl net.core.somaxconn=1024
vi /etc/sysctl.conf
60a61,63
>
> vm.overcommit_memory = 1
> net.core.somaxconn = 1024

启动

vi /etc/systemd/system/redis.service
[Unit]
Description=redis

[Service]
Type=simple
ExecStart=/usr/local/bin/redis-server /usr/local/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
User=redis
Group=redis
SyslogIdentifier=redis

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start redis
systemctl enable redis
广告
将在 10 秒后关闭
bannerAds