Redis安装
1.下载Redis安装包到/sur/src/下
[root@localhost src]# wget http://download.redis.io/releases/redis-5.0.7.tar.gz
--2020-01-07 05:44:25-- http://download.redis.io/releases/redis-5.0.7.tar.gz
Resolving download.redis.io (download.redis.io)... 109.74.203.151
Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1984203 (1.9M) [application/x-gzip]
Saving to: ‘redis-5.0.7.tar.gz’
100%[======================================>] 1,984,203 32.7KB/s in 39s
2020-01-07 05:45:04 (49.9 KB/s) - ‘redis-5.0.7.tar.gz’ saved [1984203/1984203]
2.安装gcc、gcc-c++编译器
[root@localhost src]# yum -y install gcc gcc-c++
3.解压redis安装包并编译
[root@localhost src]# tar xf redis-5.0.7.tar.gz
[root@localhost src]# cd redis-5.0.7/
[root@localhost redis-5.0.7]# make && make install
4.启动程序,查看端口号6379:
[root@localhost ~]# mkdir /etc/redis
[root@localhost ~]# cp /usr/src/redis-5.0.7/redis.conf /etc/redis/ //配置文件放到/etc/redis/下
[root@localhost ~]# ls /etc/redis/
redis.conf
[root@localhost ~]# nohup redis-server /etc/redis/redis.conf & //后台启动
[1] 9503
nohup: ignoring input and appending output to ‘nohup.out’
[root@localhost ~]# ss -natl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 127.0.0.1:6379 *:*
LISTEN 0 128 *:111 *:*
LISTEN 0 5 192.168.122.1:53 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 127.0.0.1:631 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::111 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 128 ::1:631 :::*
LISTEN 0 100 ::1:25 :::*
5.配置密码认证
[root@localhost ~]# vim /etc/redis/redis.conf //修改配置文件
# requirepass foobared //更改前
bind 127.0.0.1
requirepass peiyf //更改后
bind 192.168.100.200
//测试:
[root@localhost ~]# redis-cli -h 192.168.100.200 -p 6379
192.168.100.200:6379> keys *
(error) NOAUTH Authentication required.
192.168.100.200:6379> quit
[root@localhost ~]# redis-cli -h 192.168.100.200 -p 6379 -a peiyf
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.100.200:6379> keys *
(empty list or set)