From 6413f6e04b521077ec6b06f37580800e8a28b9cd Mon Sep 17 00:00:00 2001 From: zhang_xubo <2578876417@qq.com> Date: Thu, 17 Dec 2020 17:02:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=A9=E5=AE=B9=E5=90=8E=E7=94=9F=E6=88=90?= =?UTF-8?q?=E9=9D=99=E6=80=81=E6=96=87=E4=BB=B6=E5=8C=85=E5=90=AB=E4=BA=86?= =?UTF-8?q?xml=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E7=9A=84=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/manager/om/script/gs_expansion | 1 + .../om/script/impl/expansion/ExpansionImpl.py | 48 +++++++++++-------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/manager/om/script/gs_expansion b/src/manager/om/script/gs_expansion index 83696f78a..aa05816b3 100644 --- a/src/manager/om/script/gs_expansion +++ b/src/manager/om/script/gs_expansion @@ -134,6 +134,7 @@ General options: GaussLog.exitWithError(ErrorCode.GAUSS_357["GAUSS_35701"] % "-h") clusterInfo = ExpansipnClusterInfo() + self.clusterInfo = clusterInfo hostNameIpDict = clusterInfo.initFromXml(self.xmlFile) clusterDict = clusterInfo.getClusterDirectorys() backIpList = clusterInfo.getClusterBackIps() diff --git a/src/manager/om/script/impl/expansion/ExpansionImpl.py b/src/manager/om/script/impl/expansion/ExpansionImpl.py index 92c82f2aa..c5da2f29b 100644 --- a/src/manager/om/script/impl/expansion/ExpansionImpl.py +++ b/src/manager/om/script/impl/expansion/ExpansionImpl.py @@ -583,25 +583,34 @@ retry for %s times" % start_retry_num) """ self.logger.debug("Start to generate and send cluster static file.\n") - primaryHosts = self.getPrimaryHostName() - command = "gs_om -t generateconf -X %s --distribute" % self.context.xmlFile - sshTool = SshTool([primaryHosts]) - resultMap, outputCollect = sshTool.getSshStatusOutput(command, - [primaryHosts], self.envFile) - self.logger.debug(outputCollect) - self.cleanSshToolFile(sshTool) + primaryHost = self.getPrimaryHostName() + result = self.commonGsCtl.queryOmCluster(primaryHost, self.envFile) + for nodeName in self.context.nodeNameList: + nodeInfo = self.context.clusterInfoDict[nodeName] + nodeIp = nodeInfo["backIp"] + dataNode = nodeInfo["dataNode"] + exist_reg = r"(.*)%s[\s]*%s(.*)%s(.*)" % (nodeName, nodeIp, dataNode) + if not re.search(exist_reg, result) and nodeIp not in self.context.newHostList: + self.logger.debug("The node ip [%s] will not be added to cluster." % nodeIp) + dbNode = self.context.clusterInfo.getDbNodeByName(nodeName) + self.context.clusterInfo.dbNodes.remove(dbNode) + + toolPath = self.context.clusterInfoDict["toolPath"] + appPath = self.context.clusterInfoDict["appPath"] - nodeNameList = self.context.nodeNameList - - for hostName in nodeNameList: - hostSsh = SshTool([hostName]) - toolPath = self.context.clusterInfoDict["toolPath"] - appPath = self.context.clusterInfoDict["appPath"] - srcFile = "%s/script/static_config_files/cluster_static_config_%s" \ - % (toolPath, hostName) + static_config_dir = "%s/script/static_config_files" % toolPath + if not os.path.exists(static_config_dir): + os.makedirs(static_config_dir) + + for dbNode in self.context.clusterInfo.dbNodes: + hostName = dbNode.name + staticConfigPath = "%s/script/static_config_files/cluster_static_config_%s" % \ + (toolPath, hostName) + self.context.clusterInfo.saveToStaticConfig(staticConfigPath, dbNode.id) + srcFile = staticConfigPath if not os.path.exists(srcFile): - GaussLog.exitWithError("Generate static file [%s] not found." \ - % srcFile) + GaussLog.exitWithError("Generate static file [%s] not found." % srcFile) + hostSsh = SshTool([hostName]) targetFile = "%s/bin/cluster_static_config" % appPath hostSsh.scpFiles(srcFile, targetFile, [hostName], self.envFile) self.cleanSshToolFile(hostSsh) @@ -612,10 +621,9 @@ retry for %s times" % start_retry_num) # Single-node database need start cluster after expansion if self.isSingleNodeInstance: 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 +641,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=[]): """