From c21c37a3e4d5542c7dc2179b71bbde3520c49851 Mon Sep 17 00:00:00 2001 From: xue_meng_en <1836611252@qq.com> Date: Wed, 1 Feb 2023 15:54:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D-L=E6=A8=A1=E5=BC=8F=E6=89=A9?= =?UTF-8?q?=E5=AE=B9=E5=90=8E=E5=A4=87=E6=9C=BA=E7=9A=84application=5Fname?= =?UTF-8?q?=E6=9C=AA=E4=BF=AE=E6=94=B9=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/impl/expansion/ExpansionImpl.py | 43 +++++++++++++++++++------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/script/impl/expansion/ExpansionImpl.py b/script/impl/expansion/ExpansionImpl.py index a3f78319..96e71f38 100644 --- a/script/impl/expansion/ExpansionImpl.py +++ b/script/impl/expansion/ExpansionImpl.py @@ -371,13 +371,9 @@ class ExpansionImpl(): existingStandbys = list(set(self.existingHosts) - (set([primaryHostIp]))) failedInstallHosts = [] notInstalledCascadeHosts = [] - for newHost,appName in zip(standbyHosts, \ - self.getIncreaseAppNames(len(standbyHosts))): + for newHost in standbyHosts: if not self.expansionSuccess[newHost]: continue - log_path = ClusterDir.getUserLogDirWithUser(self.user) - log_dir = "%s/pg_log/dn_%d" % (log_path, appName) - audit_dir = "%s/pg_audit/dn_%d" % (log_path, appName) hostName = self.context.backIpNameMap[newHost] sshIp = self.context.clusterInfoDict[hostName]["sshIp"] port = self.context.clusterInfoDict[hostName]["port"] @@ -439,12 +435,8 @@ class ExpansionImpl(): inst_dir = self.context.clusterInfoDict[hostName]["dataNode"] guc_path = os.path.join(self.context.clusterInfoDict["appPath"], "bin", "gs_guc") - para_str = " -c \"application_name='dn_{0}'\" " \ - "-c \"log_directory='{1}'\" " \ - " -c \"audit_directory='{2}'\" " \ - " -c \"listen_addresses='localhost,{3}'\"" \ - " -c \"port='{4}'\"" \ - "".format(appName, log_dir, audit_dir, newHost, port) + para_str = " -c \"listen_addresses='localhost,{0}'\"" \ + " -c \"port='{1}'\"".format(newHost, port) cmd = "source {0}; {1} set -D {2} {3}".format(self.envFile, guc_path, inst_dir, para_str) self.logger.debug( @@ -465,7 +457,27 @@ class ExpansionImpl(): self.logger.log("Finish to install database on all nodes.") if self._isAllFailed(): GaussLog.exitWithError(ErrorCode.GAUSS_357["GAUSS_35706"] % "install") - + + def resetStandbyAppName(self, hostName, sshIp): + if not self.newInsIds: + return + appName = self.newInsIds[0] + logPath = ClusterDir.getUserLogDirWithUser(self.user) + logDir = "%s/pg_log/dn_%d" % (logPath, appName) + auditDir = "%s/pg_audit/dn_%d" % (logPath, appName) + instDir = self.context.clusterInfoDict[hostName]["dataNode"] + gucPath = os.path.join(self.context.clusterInfoDict["appPath"], + "bin", "gs_guc") + paraStr = " -c \"application_name='dn_{0}'\" " \ + "-c \"log_directory='{1}'\" " \ + " -c \"audit_directory='{2}'\" " \ + "".format(appName, logDir, auditDir) + cmd = "source {0}; {1} set -D {2} {3}".format( + self.envFile, gucPath, instDir, paraStr) + self.logger.debug("Command for set guc params: %s" % cmd) + sshTool = SshTool([sshIp], timeout=300) + self.guc_executor(sshTool, cmd, sshIp) + def preInstallOnHosts(self): """ execute preinstall step @@ -807,6 +819,8 @@ gs_guc set -D {dn} -c "available_zone='{azName}'" hostRole = ROLE_STANDBY self.logger.log("Start to build %s %s." % (hostRole, host)) self.checkTmpDir(hostName) + # reset current standby's application name before started + self.resetStandbyAppName(hostName=hostName, sshIp=host) # start new host as standby mode self.commonGsCtl.stopInstance(hostName, dataNode, self.envFile) result, output = self.commonGsCtl.startInstanceWithMode(host, @@ -888,6 +902,9 @@ gs_guc set -D {dn} -c "available_zone='{azName}'" if self.context.newHostCasRoleMap[host] == "off": existingStandbys.append(host) self.logger.log("\rBuild %s %s success." % (hostRole, host)) + # after current standby build successfully, + # the minimum dn id has been used, so pop it from newInsIds + self.newInsIds.pop(0) else: self.expansionSuccess[host] = False self.logger.log("\rBuild %s %s failed." % (hostRole, host)) @@ -1550,6 +1567,8 @@ remoteservice={remoteservice}'" # change to db manager user. the below steps run with db manager user. self.changeUser() + # newInsIds indicates unused dn id list + self.newInsIds = self.getIncreaseAppNames(len(self.context.newHostList)) if not self.context.standbyLocalMode: self.logger.log("Start to install database on new nodes.") self.installDatabaseOnHosts() -- Gitee