我有2 dc和3節點:
DC1:cas01.dc01.net(172.16.3.15)和cas02.dc01.net(172.16.3.16)
DC2:cas01.dc02。例如淨(172.16.9.3)。Python的無效列表節點卡桑德拉集羣
運行下面的腳本:
cluster = Cluster(['cas01.dc01.net', 'cas02.dc01.net', 'cas01.dc02.net'],auth_provider=auth,protocol_version=3, load_balancing_policy=DCAwareRoundRobinPolicy(local_dc='DC1'))
session = cluster.connect('test')
print '_dc_live_hosts:'
for k, v in cluster.load_balancing_policy._dc_live_hosts.items():
print "DC name: %s; Node address: %s" % (k, [node.address for node in v])
print 'Cluster metadata:'
for host in cluster.metadata.all_hosts():
print 'Datacenter: %s; Host: %s; Rack: %s' % (host.datacenter, host.address, host.rack)
和接收響應:
_dc_live_hosts:
DC name: DC1; Node address: ['cas01.dc01.net', 'cas01.dc02.net', 'cas02.dc01.net', '172.16.3.15']
DC name: DC2; Node address: ['172.16.9.3']
Cluster metadata:
Datacenter: None; Host: cas01.dc01.net; Rack: None
Datacenter: None; Host: cas01.dc02.net; Rack: None
Datacenter: DC1; Host: 172.16.3.15; Rack: Rack1
Datacenter: DC2; Host: 172.16.9.3; Rack: Rack1
Datacenter: DC1; Host: cas02.dc01.net; Rack: Rack1
爲什麼重複的節點?
如果指定IP地址的列表:節點
cluster = Cluster(['172.16.3.15', '172.16.3.16', '172.16.9.3'],auth_provider=auth,protocol_version=3, load_balancing_policy=DCAwareRoundRobinPolicy(local_dc='DC1'))
...
列表是正確的:
_dc_live_hosts:
DC name: DС1; Node address: ['172.16.3.16', '172.16.3.15']
DC name: DС2; Node address: ['172.16.9.3']
Cluster metadata:
Datacenter: DС1; Host: 172.16.3.16; Rack: Rack1
Datacenter: DС1; Host: 172.16.3.15; Rack: Rack1
Datacenter: DС2; Host: 172.16.9.3; Rack: Rack1
請幫助。
你有什麼種子?你用什麼傳聞?你可以在你的cassandra.yaml文件中找到答案。如果它是PropertyFileSnitch,是否可以包含cassandra-topology.properties的內容? – DineMartine
節點cas01.dc01.net: - 種子:「cas01.dc01.net,cas02.dc01.net」節點cas02.dc01.net: - 種子:「cas01.dc01.net,cas01.dc02.net」節點cas01。 dc02.net: - 種子:「cas01.dc02.net,cas01.dc01.net」endpoint_snitch:PropertyFileSnitch 拓撲:cas01.dc01.net = DC1:Rack1 cas02.dc01.net = DC1:Rack1 cas01.dc02。 net = DC2:Rack1 –