https://redis.io/
1.源码包安装# tar -zxf redis-4.0.6.tar.gz -C /usr/local/
# cd /usr/local/ && mv redis-4.0.6 redis
# cd redis
# vim redis.conf, 修改如下:
bind 0.0.0.0 # 可以从任何IP访问
daemonize yes # 允许作为后台服务运行
# redis-server ./redis.conf
# ps -ef | grep redis
# redis-cli
127.0.0.1:6379> set key1 123456
OK
127.0.0.1:6379> get key1
"123456"
127.0.0.1:6379> exit
2.增加访问密码
# vim redis.conf
requirepass bigdata
# redis-cli
127.0.0.1:6379> shutdown save # 关闭redis
not connected> exit
# ps -ef |grep redis
root 6410 2440 0 17:53 pts/0 00:00:00 grep --color=auto redis
# redis-server ./redis.conf # 启动redis
# redis-cli
127.0.0.1:6379> get key1
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth bigdata
OK
127.0.0.1:6379> get key1
"123456"
# pwd
/usr/local/redis
# cd utils/
# ./install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server
Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] /usr/local/redis/redis.conf
Please select the redis log file name [/var/log/redis_6379.log] /usr/local/redis/redis.log
Please select the data directory for this instance [/var/lib/redis/6379] /usr/local/redis/data
Please select the redis executable path [/usr/local/bin/redis-server]
Selected config:
Port : 6379
Config file : /usr/local/redis/redis.conf
Log file : /usr/local/redis/redis.log
Data dir : /usr/local/redis/data
Executable : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
/var/run/redis_6379.pid exists, process is already running or crashed
Installation successful!
# chkconfig --list|grep redis
redis_6379 0:off 1:off 2:on 3:on 4:on 5:on 6:off
# systemctl status redis_6379
● redis_6379.service - LSB: start and stop redis_6379
Loaded: loaded (/etc/rc.d/init.d/redis_6379)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)
# systemctl stop redis_6379
# systemctl start redis_6379
# ps -ef|grep redis
root 6412 1 0 17:53 ? 00:00:00 redis-server 0.0.0.0:6379
root 6530 2440 0 18:03 pts/0 00:00:00 grep --color=auto redis
# vim /etc/init.d/redis_6379
# redis-cli # 测试使用
127.0.0.1:6379> auth bigdata
OK
127.0.0.1:6379> set key3 abc
OK
127.0.0.1:6379> get key3
"abc"