怎么在Redis里配置(bind)多个可连接的IP地址?
redis和node.js在同一个机器上面,node.js客户端通过指定的ip地址和port的格式创建,client=redis.createClient(6379, "192.168.1.1"),在限制只能本机访问的情况下,怎么让本机的redis-cli和node.js服务器都能连接Redis?
本机ip为192.168.1.1,Redis配置文件中效果如下:
● bind 127.0.0.1
本机redis-cli可以连接数据库,本机node.js服务器无法访问。
● bind 192.168.1.1
本机redis-cli无连接数据库,本机node.js服务器可以连接。
● bind 127.0.0.1
bind 192.168.1.1
本机redis-cli无法连接数据库,本机node.js服务器可以连接。
1楼(未知网友)
# TCP keepalive.
#
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
# of communication. This is useful for two reasons:
#
# 1) Detect dead peers.
# 2) Take the connection alive from the point of view of network
# equipment in the middle.
#
# On Linux, the specified value (in seconds) is the period used to send ACKs.
# Note that to close the connection the double of the time is needed.
# On other kernels the period depends on the kernel configuration.
#
# A reasonable value for this option is 60 seconds.
tcp-keepalive 0
2楼(未知网友)
bind 127.0.0.1
bind 192.168.1.1
两个一起写的时候它只能识别下面这个
-------------------------------------------------------------------------
bind 192.168.1.1
这时应该这样用 redis-cli -h 192.168.1.1 -p 6379
3楼(未知网友)
bind 0.0.0.0
4楼(未知网友)
2.8 以后可以绑定到多个指定的IP地址上
bind 127.0.0.1 192.168.3.3
注意是空格不是逗号
Redis bind to more than one IP