美文网首页
redis.conf详解之bind

redis.conf详解之bind

作者: 小易哥学呀学 | 来源:发表于2021-11-17 09:03 被阅读0次

    用法

    绑定到本机的其中一个ip
    bind 2.2.2.2 
    
    绑定到本机的两个ip,如果10.0.0.1无效redis依旧可以启动。
    bind 192.168.1.100 -10.0.0.1
    
    绑定到本机的ipv6
    bind ::1
    

    用途

    bind用于绑定本机的网络接口(网卡),redis只接受来自绑定网络接口的请求。
    比如本机有两个网卡分别对应ip 1.1.1.1 ,2.2.2.2,配置bind 1.1.1.1,客户端288.30.3.3访问2.2.2.2将无法连接redis。

    注意事项

    如果不配置bindredis将监听本机所有可用的网络接口。
    不配置指:redis.conf中无bind配置、#bind 127.0.0.1

    - 当指定的网络接口不可用且其他网络接口可用时,不会启动失败。
    17.0.0.1效ip,127.0.0.1为效ip。以下配置以及log输出。

    bind -17.0.0.1
    // Warning: Could not create server TCP listening socket 17.0.0.1:6379: bind: Can't assign requested address
    // Configured to not listen anywhere, exiting.
    
    bind -17.0.0.1 127.0.0.1
    // Warning: Could not create server TCP listening socket 17.0.0.1:6379: bind: Can't assign requested address
    // ···省略···
    // Ready to accept connections
    

    原生注释

    # By default, if no "bind" configuration directive is specified, Redis listens
    # for connections from all available network interfaces on the host machine.
    # It is possible to listen to just one or multiple selected interfaces using
    # the "bind" configuration directive, followed by one or more IP addresses.
    # Each address can be prefixed by "-", which means that redis will not fail to
    # start if the address is not available. Being not available only refers to
    # addresses that does not correspond to any network interfece. Addresses that
    # are already in use will always fail, and unsupported protocols will always BE
    # silently skipped.
    #
    # Examples:
    #
    # bind 192.168.1.100 10.0.0.1     # listens on two specific IPv4 addresses
    # bind 127.0.0.1 ::1              # listens on loopback IPv4 and IPv6
    # bind * -::*                     # like the default, all available interfaces
    #
    # ~~~ 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 on the
    # IPv4 and IPv6 (if available) loopback interface addresses (this means Redis
    # will only be able to accept client connections from the same host that it is
    # running on).
    #
    # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
    # JUST COMMENT OUT THE FOLLOWING LINE.
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

    相关文章

      网友评论

          本文标题:redis.conf详解之bind

          本文链接:https://www.haomeiwen.com/subject/brmqtrtx.html