From a7ef9ae10038a8fc9a586fe0ea2d806fa6937553 Mon Sep 17 00:00:00 2001 From: xue_meng_en <1836611252@qq.com> Date: Sun, 13 Nov 2022 21:37:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9B=86=E7=BE=A4=E5=81=9C?= =?UTF-8?q?=E6=AD=A2=E7=8A=B6=E6=80=81=E4=B8=8B=E5=8D=B8=E8=BD=BDcm?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=90=AF=E5=8A=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tool/cm_tool/InstallImpl.py | 14 ++++++-------- tool/cm_tool/cm_uninstall | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/tool/cm_tool/InstallImpl.py b/tool/cm_tool/InstallImpl.py index 83d908b..cdfbd9a 100644 --- a/tool/cm_tool/InstallImpl.py +++ b/tool/cm_tool/InstallImpl.py @@ -248,6 +248,10 @@ class InstallImpl: errorDetail = "\nStatus: %s\nOutput: %s" % (status, output) self.logger.logExit("Failed to start cluster." + errorDetail) + status, output = InstallImpl.refreshDynamicFile(self.envFile) + if status != 0: + self.logger.error("Failed to refresh dynamic file." + output) + queryCmd = "source %s; cm_ctl query -Cv" % self.envFile status, output = subprocess.getstatusoutput(queryCmd) if status != 0: @@ -283,17 +287,11 @@ class InstallImpl: errorDetail = "\nCommand: %s\nStatus: %s\nOutput: %s" % (refreshDynamicFileCmd, status, output) return status, errorDetail - def refreshStaticAndDynamicFile(self): + def _refreshStaticFile(self): self.logger.log("Refreshing static and dynamic file using xml file with cm.") status, output = InstallImpl.refreshStaticFile(self.envFile, self.xmlFile) if status != 0: self.logger.logExit("Failed to refresh static file." + output) - if self.clusterStopped: - self.logger.log("Don't need to refresh dynamic file when the cluster is currently stopped.") - return - status, output = InstallImpl.refreshDynamicFile(self.envFile) - if status != 0: - self.logger.logExit("Failed to refresh dynamic file." + output) def run(self): self.logger.log("Start to install cm tool.") @@ -302,6 +300,6 @@ class InstallImpl: self.createManualStartFile() self.initCMServer() self.initCMAgent() - self.refreshStaticAndDynamicFile() + self._refreshStaticFile() self.setMonitorCrontab() self.startCluster() diff --git a/tool/cm_tool/cm_uninstall b/tool/cm_tool/cm_uninstall index a1f007a..63634a5 100644 --- a/tool/cm_tool/cm_uninstall +++ b/tool/cm_tool/cm_uninstall @@ -196,6 +196,22 @@ General options: status, output = InstallImpl.refreshStaticFile(self.envFile, self.xmlFile) if status != 0: self.logger.logExit("Failed to refresh static file." + output) + # Remove dynamic file, if the cluster is stopped currently. + removeDynamicCmd = "source %s; rm -f $GAUSSHOME/bin/cluster_dynamic_config" % self.envFile + for host in self.hostnames: + isLocal = False + if host == self.localhostName: + isLocal = True + executeCmdOnHost(host, removeDynamicCmd, isLocal) + clusterStopped = False + checkClusterStoppedCmd = "source %s; ls $GAUSSHOME/bin/cluster_manual_start" % self.envFile + status, output = subprocess.getstatusoutput(checkClusterStoppedCmd) + if status == 0: + clusterStopped = True + self.logger.debug("Command: " + checkClusterStoppedCmd) + self.logger.debug("Status: %s\nOtput: %s" % (status, output)) + if clusterStopped: + return status, output = InstallImpl.refreshDynamicFile(self.envFile) if status != 0: self.logger.logExit("Failed to refresh dynamic file." + output)