1. Install gcc-c++, tcl
yum install gcc-c++ tcl
2. Decompress, compile and test
tar zxvf redis-5.0.5.tar.gz make make test
3. Install to / opt
make PREFIX=/opt/redis/redis-5.0.5 install # Create a soft chain ln -s redis-5.0.5 latest
4. Configuration file. There is an example redis.conf in the source file directory. The final configuration content is (the second half uses 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 is set to no, directly start the test with the command line and observe the log output.
./bin/redis-server ./conf/redis_16379.conf
6. Solve warning
For / proc/sys/net/core/somaxconn and overcommit \ memory is set to 0, modify / etc/sysctl.conf and add
net.core.somaxconn = 1024 vm.overcommit_memory = 1
Then execute sysctl -p
For the transparent page, first modify it in real time
echo never >> /sys/kernel/mm/transparent_hugepage/enabled echo never >> /sys/kernel/mm/transparent_hugepage/defrag
inspect
[root@middle ~]# cat /sys/kernel/mm/transparent_hugepage/enabled [always] madvise never [root@middle ~]# cat /sys/kernel/mm/transparent_hugepage/defrag [always] madvise never # All the above needs to be changed into never
Join to start automatic modification
# Add the following to / 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. Join Systemd service. Add / lib/systemd/system.redis.service, as follows
[root@p01 ~]# more /lib/systemd/system/redis.service [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=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
Join service and start
systemctl enable redis.service systemctl start redis systemctl status redis
.