Merge branch 'master' of gitee.com:opengauss/openGauss-OM into master

This commit is contained in:
薛蒙恩
2021-03-06 15:39:51 +08:00
committed by Gitee
53 changed files with 3047 additions and 416 deletions

View File

@ -1085,7 +1085,7 @@ class dbNodeInfo():
elif (instRole == INSTANCE_ROLE_DATANODE):
dbInst.port = self.__assignNewInstancePort(self.datanodes,
instRole, instanceType)
dbInst.haPort = dbInst.port + 1
dbInst.haPort = dbInst.port + 6
dbInst.ssdDir = ssddir
dbInst.syncNum = syncNum
self.datanodes.append(dbInst)
@ -1419,8 +1419,7 @@ class dbClusterInfo():
"""
i = 0
(clusterState, syncInfo) = self.__getDnSenderStatus(sshtool,
localHostName,
nodeId)
localHostName)
outText = \
"--------------------------------------------------------------" \
"---------\n\n"
@ -1449,9 +1448,12 @@ class dbClusterInfo():
outText = outText + (
"instance_state : %s\n" %
dnInst.state)
outText = outText + (
"az_name : %s\n" %
dnInst.azName)
if dnInst.localRole == "Primary":
outText = outText + (
"static_connections : %s\n\n" %
"static_connections : %s\n" %
dnInst.staticConnections)
outText = outText + (
"HA_state : %s\n" %
@ -1460,14 +1462,14 @@ class dbClusterInfo():
"instance_role : %s\n" %
dnInst.localRole)
if dnInst.localRole == "Primary":
outText = outText + "------------------------" \
outText = outText + "\n------------------------" \
"---------------" \
"--------------------------------\n\n"
continue
for i_loop in syncInfo:
if i_loop[11] == '':
i_loop[11] = 'Unknown'
if i_loop[0] == dnInst.listenIps[0]:
if i_loop[11] == '':
i_loop[11] = 'Unknown'
outText = outText + (
"HA_state : %s\n" %
i_loop[1])
@ -1505,11 +1507,10 @@ class dbClusterInfo():
outText = outText + (
"upstream_nodeIp : %s\n" %
i_loop[12])
outText = outText + ("\n")
outText = outText + "------------------------" \
"---------------" \
"--------------------------------\n\n"
break
outText = outText + "\n------------------------" \
"---------------" \
"--------------------------------\n\n"
if nodeId != 0:
break
else:
@ -1808,7 +1809,7 @@ class dbClusterInfo():
dnInsNum += len(dbNode.datanodes)
return dnInsNum
def __getDnSenderStatus(self, sshtool, localHostName, nodeId):
def __getDnSenderStatus(self, sshtool, localHostName):
sql_get = "select a.client_addr, b.state, b.sender_sent_location," \
"b.sender_write_location, b.sender_flush_location," \
"b.sender_replay_location, b.receiver_received_location," \
@ -1859,7 +1860,6 @@ class dbClusterInfo():
"receiver_received_location, receiver_write_location," \
"receiver_flush_location, receiver_replay_location," \
"sync_percent, channel from pg_stat_get_wal_receiver();"
cascadeOutput = ""
if dbNode.name != localHostName:
cmd = "[need_replace_quotes] gsql -m -d postgres -p " \
"%s -A -t -c \"%s\"" % \
@ -1870,7 +1870,7 @@ class dbClusterInfo():
"failed to connect") >= 0:
continue
else:
output = cascadeOutput.split('\n')[1:-1]
cascadeOutput = cascadeOutput.split('\n')[1:-1]
else:
cmd = "gsql -m -d postgres -p %s -A -t -c \"%s\"" % (
dnInst.port, subsql)
@ -1960,9 +1960,7 @@ class dbClusterInfo():
with open(fileName, "a") as fp:
fp.write(content)
fp.flush()
else:
sys.stdout.write(content)
sys.stdout.write(content)
def __checkOsUser(self, user):
"""
@ -3429,6 +3427,7 @@ class dbClusterInfo():
input : []
output : NA
"""
# port range from +1 to +7, here define haPort = dataportBase + 6
for dbNode in self.dbNodes:
i = 0
for dbInst in dbNode.datanodes:
@ -3436,11 +3435,11 @@ class dbClusterInfo():
dbInst.port = dbNode.masterBasePorts[
INSTANCE_ROLE_DATANODE] + i * \
PORT_STEP_SIZE
dbInst.haPort = dbInst.port + 1
dbInst.haPort = dbInst.port + 6
peerInsts = self.__getPeerInstance(dbInst)
for j in range(len(peerInsts)):
peerInsts[j].port = dbInst.port
peerInsts[j].haPort = peerInsts[j].port + 1
peerInsts[j].haPort = peerInsts[j].port + 6
i += 1
# flush CMSERVER instance port
i = 0