[root@tbwy02 ~]# cd /tools/
[root@tbwy02 tools]# yum install -y wget gcc make tcl
[root@tbwy02 tools]# wget http://download.redis.io/redis-stable.tar.gz
[root@tbwy02 tools]# wget http://download.redis.io/releases/redis-3.0.2.tar.gz
[root@tbwy02 tools]# tar -zxvf redis-4.0.8.tar.gz
[root@tbwy02 tools]# cd redis-4.0.8
[root@tbwy02 redis-4.0.8]# make
[root@tbwy02 redis-4.0.8]# make test

Hint: It's a good idea to run 'make test' ;)
make[1]: Leaving directory `/tools/redis-4.0.8/src'

[root@tbwy02 redis-4.0.8]# make test

\o/ All tests passed without errors!
Cleanup: may take some time... OK
make[1]: Leaving directory `/tools/redis-4.0.8/src'

[root@tbwy02 redis-4.0.8]# make install
cd src && make install
make[1]: Entering directory `/tools/redis-4.0.8/src'

Hint: It's a good idea to run 'make test' ;)

INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/tools/redis-4.0.8/src'
[root@tbwy02 redis-4.0.8]# mkdir -p /etc/redis
[root@tbwy02 redis-4.0.8]# cp redis.conf /etc/redis/
[root@tbwy02 redis-4.0.8]# vim /etc/redis/redis.conf
# zkm 2018-3-23 15:30
daemonize yes
protected-mode no  要设置成no      (默认是设置成yes的, 防止了远程访问,在redis3.2.3版本后)
bind 127.0.0.1 (注释掉)
[root@tbwy02 redis-4.0.8]# /usr/local/bin/redis-server /etc/redis/redis.conf
25570:C 23 Mar 15:36:36.630 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
25570:C 23 Mar 15:36:36.630 # Redis version=4.0.8, bits=64, commit=00000000, modified=0, pid=25570, just started
25570:C 23 Mar 15:36:36.630 # Configuration loaded
[root@tbwy02 redis-4.0.8]# ps -ef |grep redis
root     25571     1  0 15:36 ?        00:00:00 /usr/local/bin/redis-server 127.0.0.1:6379       
root     25577 19689  0 15:37 pts/0    00:00:00 grep redis
[root@tbwy02 redis-4.0.8]# redis-cli
127.0.0.1:6379> set name david
OK
127.0.0.1:6379> get name
"david"
127.0.0.1:6379> quit

11.关闭客户端
[root@tbwy02 redis-4.0.8]# redis-cli shutdown

或者

pkill redis-server

-A INPUT -p tcp -m state --state NeW -m tcp --dport 6379 -j ACCEPT

12、开机启动配置

echo "/usr/local/bin/redis-server /etc/redis/redis.conf &" >> /etc/rc.local

开机启动要配置在 rc.local 中,而 /etc/profile 文件,要有用户登录了,才会被执行。

05-20 20:17