(1)安装 ------------------- yum install -y gcc yum install -y tcl wget http://download.redis.io/releases/redis-4.0.1.tar.gz tar -xzvf redis-4.0.1.tar.gz cd redis-4.0.1/src/ make make test make install
mkdir -p /usr/local/redis/bin mkdir -p /usr/local/redis/etc cd .. cp redis.conf /usr/local/redis/etc/ cd src mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-check-rdb redis-cli redis-sentinel redis-server /usr/local/redis/bin/ ---------------------------------
(2)修改path路径 ------------------------------------- vi /etc/profile --------------------- PATH=$PATH:/usr/local/redis/bin export PATH ---------------------- source /etc/profile
(3)运行: redis-server
会报几个警告: 31084:M 14 Sep 19:39:07.644 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 31084:M 14 Sep 19:39:07.644 # Server initialized 31084:M 14 Sep 19:39:07.644 # 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. 31084:M 14 Sep 19:39:07.644 # 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.
先ctrl+c结束。
<3-1> vim /etc/sysctl.conf
添加 net.core.somaxconn= 1024 vm.overcommit_memory = 1 保存,然后 sysctl -p
<3-2> echo never > /sys/kernel/mm/transparent_hugepage/enabled echo "echo never > /sys/kernel/mm/transparent_hugepage/enabled" >>/etc/rc.local
(4)修改配置文件,启动 vim /usr/local/redis/etc/redis.conf daemonize 改为yes,即可后台启动redis
redis-server /usr/local/redis/etc/redis.conf
(5)测试 redis-cli auth 你的密码 set name aaa get name exit
(6)关闭 redis-cli shutdown redis-cli -a 你的密码 shutdown
(7)自动启动 echo "/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf" >>/etc/rc.local
|