Redis bind配置 ,首先说结论

bind 127.0.0.1, 只能在本地机器连接bind 127.0.0.1 192.168.2.14, 可以通过 redis-cli -p 127.0.0.1 或 redis-cli -p 192.168.2.14 链接,就是说127.0.0.1只能是本地使用,所以bind 127.0.0.1仅支持本机,而bind 192.168.2.14 所有可以通过192.168.2.14访问到 192.168.2.14这个服务器的机器,都可以通过 redis-cli -p 192.168.2.14链接redisbind 0.0.0.0 配置成0.0.0.0 这个redis所在的服务器支持几个ip来连接,就可以通过这几个ip来连接redis(举例说明:假设A服务器 通过 ip addr 查看这个服务器的ip有三个,分别是127.0.0.1,192.168.2.14,336.334.224.1,那么就意味着你可以通过这三个ip来连接redis,你能通过哪个ip可以链接到A服务器,你就可以通过这个ip来连接redis)如果不填 ,效果和 bind 0.0.0.0一样

通过上面也大概能猜到,bind 配置就是通过你配置的ip来访问 redis服务的(就是通过127.0.0.1或192.168.2.14来连接,谁能访问到 bind 后面配置的ip,谁就可以通过这个ip来连接redis) 然后我们再来看redis关于bind 的注释

# By default, if no "bind" configuration directive is specified, Redis listens

# for connections from all the network interfaces available on the server.

# It is possible to listen to just one or multiple selected interfaces using

# the "bind" configuration directive, followed by one or more IP addresses.

#

# Examples:

#

# bind 192.168.1.100 10.0.0.1

# bind 127.0.0.1 ::1

#

# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the

# internet, binding to all the interfaces is dangerous and will expose the

# instance to everybody on the internet. So by default we uncomment the

# following bind directive, that will force Redis to listen only into

# the IPv4 lookback interface address (this means Redis will be able to

# accept connections only from clients running into the same computer it

# is running).

#

# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES

# JUST COMMENT THE FOLLOWING LINE.

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

bind 127.0.0.1

请认真阅读上述英文注释, 下面是google翻译 默认情况下,如果未指定“ bind”配置指令,则Redis将侦听服务器上所有可用网络接口的连接。 可以使用“ bind”配置指令仅侦听一个或多个所选接口,然后侦听一个或多个IP地址。 如果运行Redis的计算机直接暴露于Internet,则绑定到所有接口都是很危险的,并且会将实例暴露给Internet上的所有人。 因此,默认情况下,我们取消注释以下bind指令,这将强制Redis仅侦听IPv4回顾接口地址(这意味着Redis将只能接受来自运行在同一台计算机上的客户端的连接)。 如果您确定要立即侦听所有接口,请仅注意以下内容。 bind 127.0.0.1

精彩文章

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。