1 回答

TA貢獻1816條經(jīng)驗 獲得超4個贊
Cassandra的docker中那個隨機生成的ip(172.18.0.5)映射的其實和它內(nèi)部localhost是同一個node,但是從外部的host是只能訪問localhost地址,而訪問不到那個隨機生成的ip(172.18.0.5)地址的,因為localhost地址是做了映射的,那個隨機生成的ip(172.18.0.5)地址是沒有做映射。
所以,我就想如何讓外部的host可以訪問那個隨機生成的ip(172.18.0.5),我想了一會兒之后,發(fā)現(xiàn)這樣比較麻煩,得每次啟動Cassandra的docker之后,手動去改外部的hosts文件。
然后,我想可不可以不隨機生成ip(172.18.0.5),我就找到了Cassandra的CASSANDRA_LISTEN_ADDRESS
這個環(huán)境變量,dockerhub上的解釋如下:
This variable is for controlling which IP address to listen for incoming connections on. The default value is auto, which will set the listen_address option in cassandra.yaml to the IP address of the container as it starts. This default should work in most use cases.
大概意思就是不設(shè)置CASSANDRA_LISTEN_ADDRESS
變量,就會隨機生成ip(172.18.0.5)。
于是,我就設(shè)置了這個CASSANDRA_LISTEN_ADDRESS
變量的值為localhost
,然后運行程序也沒有報上面的那個錯誤了。
添加回答
舉報