Spring boot connects to Redis in remote Alibaba Cloud server (modify redis.conf configuration file + open port)

The premise of using Spring boot to connect to Redis in the remote server is that the redis in the remote server is successfully installed. If you are not sure, you can refer to the previous blog and poke me to check .
To use Spring boot to connect to Redis in the remote server, the first thing to do is to modify the address of the redis configuration file in springboot

 redis:
    host: #服务器IP地址
    port: 6379
    database: 0
    timeout: 5000

This modification is still not possible, and you need to start address authorization on the server side. The easiest way is to change the redis.conf configuration file in redis. The ip address behind bind 127.0.0.1 needs to be modified to 0.0.0.0, which means all IPs. Both can access the redis, otherwise only the server can access it.
Read file

 vim redis.conf

Find bind 127.0.0.1 and
Insert picture description here
press Insert to edit bind 0.0.0.0 After
editing, click Insert again, then press ESC, enter: wq (save and exit) to
restart redis! ( Be sure to enter under the redis folder path, which is the upper file path of bin )

 ./bin/redis-cli shutdown #关闭
 ./bin/redis-server ./bin/redis.conf #启动

The key point is that
if the above configuration is finished, an error is reported and the connection cannot be made. If you are also using a cloud server, such as Alibaba Cloud, please check whether port 6379 is opened in the access rules of the security group. If it is not opened, it will also cause connection failure. Just add it manually!
Insert picture description here

Guess you like

Origin blog.csdn.net/Wangdiankun/article/details/106433096