Redis 安装Linux

1.Redis官网下载

2.或者直接命令下载安装

[root@xiaobing redis]# wget http://download.redis.io/releases/redis-7.0.2.tar.gz
[root@xiaobing redis-7.0.2]# tar xzf redis-7.0.2.tar.gz 
[root@xiaobing redis-7.0.2]# cd redis-7.0.2/
[root@xiaobing redis-7.0.2]# make

3.启动  

[root@xiaobing src]# ./redis-server   
[root@xiaobing src]# nohup ./redis-server & //守护进程启动

 4.客户端连接

[root@xiaobing src]# ./redis-cli 
127.0.0.1:6379> set name xiaobing
OK
127.0.0.1:6379> get name
"xiaobing"
127.0.0.1:6379> 

5.查看Redis PID

[root@xiaobing redis-7.0.2]# lsof -i:6379
COMMAND      PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
redis-cli 327344 root    3u  IPv4 6152285      0t0  TCP localhost:38498->localhost:redis (ESTABLISHED)
redis-ser 327367 root    6u  IPv4 6152255      0t0  TCP *:redis (LISTEN)
redis-ser 327367 root    7u  IPv6 6152256      0t0  TCP *:redis (LISTEN)
redis-ser 327367 root    8u  IPv4 6152286      0t0  TCP localhost:redis->localhost:38498 (ESTABLISHED)
[root@xiaobing redis-7.0.2]# kill 327367   //杀掉进程

6.Redis密码设置

127.0.0.1:6379> config set requirepass 123456   //设置密码
OK
127.0.0.1:6379> auth 123456   //密码验证
OK
127.0.0.1:6379> config get requirepass   //获取密码
1) "requirepass"
2) "123456"
127.0.0.1:6379> 

7.默认是本地访问的。需要开放外网访问

1.打开redi.conf 文件在NETWORK部分修改
2.注释掉 bind 127.0.0.1 -::1 //仅本地访问
或者# bind 192.168.1.100 10.0.0.1     # listens on two specific IPv4 addresses
3.修改:protected-mode yes //yes 改为 no 关闭保护
4.[root@xiaobing src]# nohup ./redis-server ../redis.conf  //指定配置文件启动守护进程

Window验证连接:

 注意:除配置文件以外,连接失败原因还应该检查 1.阿里云主机是否开放端口6379,或者 2.redis是否指定配置文件启动

posted @ 2022-07-04 17:32  o小兵o  阅读(28)  评论(0编辑  收藏  举报