From 5e76b6f169dab3687dc7c1d8f800766aa1eecc8f Mon Sep 17 00:00:00 2001
From: zhang_xubo <2578876417@qq.com>
Date: Fri, 20 Nov 2020 10:29:43 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=A9=E5=AE=B9=E6=97=B6?=
=?UTF-8?q?=E5=80=99tmpmppdbPath=E9=85=8D=E7=BD=AE=E9=A1=B9=E6=98=AF?=
=?UTF-8?q?=E5=90=A6=E5=AD=98=E5=9C=A8=E5=AF=BC=E8=87=B4=E5=AE=89=E8=A3=85?=
=?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
修复已经是备机时候还可以继续扩容的问题
修复已经是备机时候还可以继续扩容的问题
---
.../om/script/impl/expansion/ExpansionImpl.py | 68 +++++++++++++++----
1 file changed, 55 insertions(+), 13 deletions(-)
diff --git a/src/manager/om/script/impl/expansion/ExpansionImpl.py b/src/manager/om/script/impl/expansion/ExpansionImpl.py
index 92c82f2aa..75dfd778e 100644
--- a/src/manager/om/script/impl/expansion/ExpansionImpl.py
+++ b/src/manager/om/script/impl/expansion/ExpansionImpl.py
@@ -175,9 +175,10 @@ class ExpansionImpl():
logPath = self.context.clusterInfoDict["logPath"]
corePath = self.context.clusterInfoDict["corePath"]
toolPath = self.context.clusterInfoDict["toolPath"]
+ mppdbconfig = ""
tmpMppdbPath = DefaultValue.getEnv("PGHOST")
- if not tmpMppdbPath:
- tmpMppdbPath = toolPath
+ if tmpMppdbPath:
+ mppdbconfig = '' % tmpMppdbPath
xmlConfig = """\
@@ -189,7 +190,7 @@ class ExpansionImpl():
-
+ {mappdbConfig}
@@ -210,7 +211,7 @@ class ExpansionImpl():
""".format(nodeName=nodeName,backIp=backIp,appPath=appPath,
logPath=logPath,toolPath=toolPath,corePath=corePath,
sshIp=sshIp,port=port,dataNode=dataNode,azName=self.context.azName,
- mppdbPath=tmpMppdbPath)
+ mappdbConfig=mppdbconfig)
return xmlConfig
def changeUser(self):
@@ -221,11 +222,15 @@ class ExpansionImpl():
GaussLog.exitWithError(ErrorCode.GAUSS_503["GAUSS_50300"] % user)
user_name = pw_record.pw_name
- user_uid = pw_record.pw_uid
- user_gid = pw_record.pw_gid
- env = os.environ.copy()
+ user_uid = pw_record.pw_uid
+ user_gid = pw_record.pw_gid
os.setgid(user_gid)
os.setuid(user_uid)
+ os.environ["HOME"] = pw_record.pw_dir
+ os.environ["USER"] = user_name
+ os.environ["LOGNAME"] = user_name
+ os.environ["SHELL"] = pw_record.pw_shell
+
def initSshConnect(self, host, user='root'):
@@ -583,11 +588,11 @@ retry for %s times" % start_retry_num)
"""
self.logger.debug("Start to generate and send cluster static file.\n")
- primaryHosts = self.getPrimaryHostName()
+ curHostName = socket.gethostname()
command = "gs_om -t generateconf -X %s --distribute" % self.context.xmlFile
- sshTool = SshTool([primaryHosts])
+ sshTool = SshTool([curHostName])
resultMap, outputCollect = sshTool.getSshStatusOutput(command,
- [primaryHosts], self.envFile)
+ [curHostName], self.envFile)
self.logger.debug(outputCollect)
self.cleanSshToolFile(sshTool)
@@ -611,11 +616,11 @@ retry for %s times" % start_retry_num)
# Single-node database need start cluster after expansion
if self.isSingleNodeInstance:
+ primaryHost = self.getPrimaryHostName()
self.logger.debug("Single-Node instance need restart.\n")
- self.commonGsCtl.queryOmCluster(primaryHosts, self.envFile)
+ self.commonGsCtl.queryOmCluster(primaryHost, self.envFile)
# if primary database not normal, restart it
- primaryHost = self.getPrimaryHostName()
dataNode = self.context.clusterInfoDict[primaryHost]["dataNode"]
insType, dbStat = self.commonGsCtl.queryInstanceStatus(primaryHost,
dataNode, self.envFile)
@@ -633,7 +638,7 @@ retry for %s times" % start_retry_num)
self.commonGsCtl.startInstanceWithMode(hostName, dataNode,
MODE_STANDBY, self.envFile)
- self.commonGsCtl.startOmCluster(primaryHosts, self.envFile)
+ self.commonGsCtl.startOmCluster(primaryHost, self.envFile)
def setGUCOnClusterHosts(self, hostNames=[]):
"""
@@ -835,6 +840,43 @@ standby nodes.")
"""
self.checkUserAndGroupExists()
self.checkXmlFileAccessToUser()
+ self.validNodeInStandbyList()
+
+ def validNodeInStandbyList(self):
+ """
+ check if the node has been installed in the cluster.
+ """
+ self.logger.debug("Start to check if the nodes in standby list\n")
+
+ curHostName = socket.gethostname()
+ command = "su - %s -c 'source %s;gs_om -t status --detail'" % \
+ (self.user, self.envFile)
+ sshTool = SshTool([curHostName])
+ resultMap, outputCollect = sshTool.getSshStatusOutput(command,
+ [curHostName], self.envFile)
+ self.logger.debug(outputCollect)
+
+ newHosts = self.context.newHostList
+ standbyHosts = []
+ existHosts = []
+ while len(newHosts) > 0:
+ hostIp = newHosts.pop()
+ nodeName = self.context.backIpNameMap[hostIp]
+ nodeInfo = self.context.clusterInfoDict[nodeName]
+ dataNode = nodeInfo["dataNode"]
+ exist_reg = r"(.*)%s[\s]*%s(.*)" % (nodeName, hostIp)
+ if not re.search(exist_reg, outputCollect):
+ standbyHosts.append(hostIp)
+ else:
+ existHosts.append(hostIp)
+ self.context.newHostList = standbyHosts
+ if len(existHosts) > 0:
+ self.logger.log("The nodes [%s] are already in the cluster. Skip expand these nodes." \
+ % ",".join(existHosts))
+ self.cleanSshToolFile(sshTool)
+ if len(standbyHosts) == 0:
+ self.logger.log("There is no node can be expanded.")
+ sys.exit(0)
def checkXmlFileAccessToUser(self):
"""