ming@ming-VirtualBox:~$ wget http://download.redis.io/releases/redis-3.0.7.tar.gz// 安裝
ming@ming-VirtualBox:~$ tar zxvf redis-3.0.7.tar.gz root@ming-VirtualBox:~# cd redis-3.0.7/ root@ming-VirtualBox:~# make root@ming-VirtualBox:~# make test root@ming-VirtualBox:~# make install
// 經過初始化腳本啓動Redis redis
root@ming-VirtualBox:~# cd utils/ root@ming-VirtualBox:~# cp redis_init_script /etc/init.d/redis_6379 root@ming-VirtualBox:~# mkdir /etc/redis root@ming-VirtualBox:~# mkdir -p /var/redis/6379 root@ming-VirtualBox:~# cp redis.conf /etc/redis/6379.cnf// 簡單地修改2個配置參數
root@ming-VirtualBox:~# vi /etc/redis/6379.conf
...... shell # By default Redis does not run as a daemon. Use 'yes' if you need it.# Note that Redis will write a pid file in /var/run/redis.pid when daemonized. daemonize yes ...... # The working directory. # # The DB will be written inside this directory, with the filename specified # above using the 'dbfilename' configuration directive. # # The Append Only File will also be created inside this directory. # # Note that you must specify a directory here, not a file name. dir /var/redis/6379 ...... |
ming@ming-VirtualBox:~$ sudo /etc/init.d/redis_6379 start
Starting Redis server... 12912:M 15 Mar 14:23:19.873 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.0.7 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 12912 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 12912:M 15 Mar 14:23:19.881 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 12912:M 15 Mar 14:23:19.882 # Server started, Redis version 3.0.7 12912:M 15 Mar 14:23:19.882 # 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. 12912:M 15 Mar 14:23:19.883 # 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. 12912:M 15 Mar 14:23:19.883 * The server is now ready to accept connections on port 6379 |
root@ming-VirtualBox:~# echo 511 >/proc/sys/net/core/somaxconn root@ming-VirtualBox:~# echo "net.core.somaxconn = 551" > /etc/sysctl.confwarning 2:
root@ming-VirtualBox:~# echo "vm.overcommit_memory=1" >> /etc/sysctl.conf root@ming-VirtualBox:~# echo 1 > /proc/sys/vm/overcommit_memorywarning 3:
root@ming-VirtualBox:~# echo never > /sys/kernel/mm/transparent_hugepage/enabled// 再次啓動redis
ming@ming-VirtualBox:~$ sudo /etc/init.d/redis_6379 start & ming@ming-VirtualBox:~$ ss -nat | grep 6379 LISTEN 0 511 *:6379 *:* LISTEN 0 511 :::6379 :::*
// 關閉redis 數據庫
ming@ming-VirtualBox:~$ sudo redis-cli SHUTDOWN 2497:M 15 Mar 15:29:43.531 # User requested shutdown... 2497:M 15 Mar 15:29:43.531 * Saving the final RDB snapshot before exiting. 2497:M 15 Mar 15:29:43.535 * DB saved on disk 2497:M 15 Mar 15:29:43.535 # Redis is now ready to exit, bye bye... [1]+ Done sudo /etc/init.d/redis_6379 start