redis 服务开着,但是程序连不上,可能是防火墙没有对redis端口开放。
root@iZ23tkclljpZ:/usr/bin# sudo ufw status
Status: active
To Action From
-- ------ ----
3306 ALLOW Anywhere
22 ALLOW Anywhere
80/tcp ALLOW Anywhere
21/tcp ALLOW Anywhere
8080/tcp ALLOW Anywhere
3306 (v6) ALLOW Anywhere (v6)
22 (v6)ALLOW Anywhere (v6)
80/tcp (v6)ALLOW Anywhere (v6)
21/tcp (v6)ALLOW Anywhere (v6)
8080/tcp (v6) ALLOW Anywhere (v6)
root@iZ23tkclljpZ:/usr/bin# $ sudo ufw allow 6379/tcp
$: command not found
root@iZ23tkclljpZ:/usr/bin# sudo ufw allow 6379/tcp
Rule added
Rule added (v6)
root@iZ23tkclljpZ:/usr/bin# sudo ufw status
Status: active
To Action From
-- ------ ----
3306 ALLOW Anywhere
22 ALLOW Anywhere
80/tcp ALLOW Anywhere
21/tcp ALLOW Anywhere
8080/tcp ALLOW Anywhere
6379/tcp ALLOW Anywhere
3306 (v6) ALLOW Anywhere (v6)
22 (v6)ALLOW Anywhere (v6)
80/tcp (v6)ALLOW Anywhere (v6)
21/tcp (v6)ALLOW Anywhere (v6)
8080/tcp (v6) ALLOW Anywhere (v6)
6379/tcp (v6) ALLOW Anywhere (v6)
root@iZ23tkclljpZ:/usr/bin# sudo ufw status
Status: active
To Action From
-- ------ ----
3306 ALLOW Anywhere
22 ALLOW Anywhere
80/tcp ALLOW Anywhere
21/tcp ALLOW Anywhere
8080/tcp ALLOW Anywhere
6379/tcp ALLOW Anywhere
3306 (v6) ALLOW Anywhere (v6)
22 (v6)ALLOW Anywhere (v6)
80/tcp (v6)ALLOW Anywhere (v6)
21/tcp (v6)ALLOW Anywhere (v6)
8080/tcp (v6) ALLOW Anywhere (v6)
6379/tcp (v6) ALLOW Anywhere (v6)
root@iZ23tkclljpZ:/usr/bin# sudo ufw delete allow 6379/tcp
Rule deleted
Rule deleted (v6)
root@iZ23tkclljpZ:/usr/bin# sudo ufw delete allow 6379
Could not delete non-existent rule
Could not delete non-existent rule (v6)
root@iZ23tkclljpZ:/usr/bin# sudo ufw allow 6379
Rule added
Rule added (v6)
从上面步骤来看是allow 6379,而不是开启6379/tcp。