我正在尝试通过以下脚本更新Cassandra表。
import requests
import json
import os
from cassandra import ConsistencyLevel
from cassandra.cluster import Cluster
from cassandra.query import SimpleStatement
from cassandra.auth import PlainTextAuthProvider
from cassandra.cqlengine import connection
def main():
pogid_supcs = open("supcpog","r")
print "Connecting to Cassandra \n"
auth_provider = PlainTextAuthProvider(username='XXX', password='XYZEW')
cluster = Cluster(['10.65.120.27','10.65.120.2','10.65.120.24','10.70.120.22','10.70.120.24','10.70.120.23'],auth_provider = auth_provider)
session = cluster.connect()
lines = pogid_supcs.readlines()
pogid_supcs.close()
attributes = open("attributesBackup40.txt","w")
attributeError = open("attributeError1.txt","a")
#attributes.write(" pog_id | supc | attribute_name | value |\n")
for line in lines:
#try:
pogid = long(line.split(",")[1]);
supc = ((line.split(",")[0]).strip()).upper();
print pogid
print supc
statement="update cams_web.product_full set catalog_status='TERMINATED' where pog_id = "+str(pogid)+" and supc = '"+supc+"';"
print statement
session.execute(statement)
# results = session.execute(statement)
# for rows in results:
# print rows.pog_id
# val=(rows.value).encode('ascii','ignore')
# attributes.write(str(rows.pog_id)+","+str(rows.supc)+","+str(rows.attribute_name)+","+str(rows.bucket_id)+","+str(rows.sub_partition)+","+str(rows.attribute_class)+","+str(rows.brand_id)+","+str(rows.created)+","+str(rows.priority)+","+str(rows.updated)+","+val+"\n")
# attributes.write("\n")
# except:
#attributeError.write(pogid"\n")
attributes.close()
if __name__ == "__main__" :
main()
当我在脚本中登录这些机器之一并运行更新查询时,该语句运行良好,但是当我尝试通过脚本执行查询时,出现以下错误。
Error from server: code=1000 [Unavailable exception] message="Cannot achieve consistency level LOCAL_ONE" info={'required_replicas': 1, 'alive_replicas': 0, 'consistency': 'LOCAL_ONE'}
我要连接的所有计算机都已启动。