[root@jjh ~]# wget https://download.redis.io/releases/redis-6.0.9.tar.gz [root@jjh ~]# tar -zxvf redis-6.0.9.tar.gz -C /usr/local/ [root@jjh ~]# cd /usr/local/redis-6.0.9/ [root@jjh ~]# ln -s /usr/local/redis-6.0.9/ /usr/local/redis [root@jjh redis-6.0.9]# yum -y install tcl [root@jjh redis-6.0.9]# make [root@jjh redis-6.0.9]# make test ··· \o/ All tests passed without errors!
Cleanup: may take some time... OK ··· [root@jjh redis-6.0.9]# make install [root@jjh redis-6.0.9]# mkdir conf bin [root@jjh redis-6.0.9]# cp redis.conf sentinel.conf conf/ [root@jjh redis-6.0.9]# find src/ -perm 755 -type f -exec cp {} bin/ \; [root@jjh redis-6.0.9]# ls bin/ redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server [root@jjh redis-6.0.9]# echo 'PATH=$PATH:/usr/local/redis/bin/' >> /etc/profile [root@jjh redis-6.0.9]# bash /etc/profile [root@jjh redis-6.0.9]# redis-server 15486:C 20Dec202015:53:14.105 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 15486:C 20Dec202015:53:14.105 # Redis version=6.0.9, bits=64, commit=00000000, modified=0, pid=15486, just started 15486:C 20Dec202015:53:14.105 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf _._ _.-``__ ''-._ _.-```. `_. ''-._Redis6.0.9 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._`._ / _.-' | PID: 15486 `-._`-._ `-./ _.-' _.-' |`-._`-._`-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._`-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._`-.__.-' _.-' `-._ _.-' `-.__.-'
15486:M 20Dec202015:53:14.106 # WARNING: TheTCP backlog setting of511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of128. 15486:M 20Dec202015:53:14.106 # Server initialized 15486:M 20Dec202015:53:14.106 # 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'forthis to take effect. 15486:M 20Dec202015:53:14.106 # WARNING you have TransparentHugePages (THP) support enabled in your kernel. This will create latency and memory usage issues withRedis. To fix this issue run the command 'echo madvise > /sys/kernel/mm/transparent_hugepage/enabled'as root, and add it to your /etc/rc.localin order to retain the setting after a reboot. Redis must be restarted after THP is disabled (set to 'madvise' or 'never'). 15486:M 20Dec202015:53:14.106 * Ready to accept connections
aof 的方式也同时带来了另一个问题:持久化文件会变的越来越大。例如我们调用 incr test 命令100次,文件中必须保存全部的100条命令,其实有99条都是多余的。因为要恢复数据库的状态其实文件中保存一条 set test 100就够了。为了压缩 aof 的持久化文件。redis 提供了 bgrewriteaof 命令。收到此命令 redis 将使用与快照类似的方式将内存中的数据以命令的方式保存到临时文件中,最后替换原来的文件。