1. Install gcc-c ++, tcl
yum install gcc-c++ tcl
2. Extract, compile, test
tar zxvf redis-5.0.5.tar.gz
make
make test
3. mounted to / opt
PREFIX = the make / opt / Redis / Redis-5.0.5 install
# Create a soft link
ln -s redis-5.0.5 latest
4. profile, there are examples in the source directory redis.conf, final configuration content (the latter half of the default, no change)
[root@p01 ~]# cat /opt/redis/latest/conf/redis_16379.conf | grep -v '^$'|grep -v '^#'|grep -v '^;'
bind 192.168.123.32
protected-mode yes
port 16379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised auto
pidfile /var/run/redis_16379.pid
loglevel notice
logfile "/data/redis/logs/redis_16379.log"
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /data/redis/db/
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
replica-priority 100
requirepass rzczurzlx4xzs|yjpkdjzhljlevY0bLh
....
5. When daemonize configured to no direct line with the command to start the test, observed log output
./bin/redis-server ./conf/redis_16379.conf
6. solve warning
For the / proc / sys / net / core / somaxconn and overcommit_memory is set to 0, modify /etc/sysctl.conf, increased
net.core.somaxconn = 1024
vm.overcommit_memory = 1
Then execute sysctl -p
For transparent_hugepage, first of all real-time changes
echo never >> /sys/kernel/mm/transparent_hugepage/enabled
echo never >> /sys/kernel/mm/transparent_hugepage/defrag
an examination
[root@middle ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
[root@middle ~]# cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never
# 以上都需要变成never
Join start automatically modified
# 在/etc/rc.local中增加如下内容
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
.
7. Add Systemd services increased /lib/systemd/system.redis.service, reads as follows
[Unit]
Description=Redis
After=network.target
[Service]
Type=forking
PIDFile=/var/run/redis_16379.pid
ExecStart=/opt/redis/latest/bin/redis-server /opt/redis/latest/conf/redis_16379.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/opt/redis/latest/bin/redis-cli -p 16379 shutdown
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Note: here and do not use # ExecStop = / bin / kill -s QUIT $ MAINPID this command to stop redis, because the use of this statement after running systemctl stop redis, redis not perform closing action, but exit it. when viewed with systemctl status redis state is failed. only ExecStop = / opt / redis / latest / bin / redis-cli -p 16379 shutdown to stop redis correct, even if configured in the conf password, there is no need to specify a password.
Join the service and start
systemctl enable redis.service
systemctl start redis
systemctl status redis
Here on Redis articles you might like, you may wish to refer to the following: