From 1694ac9ec7f2608f7318abf3881965221f846539 Mon Sep 17 00:00:00 2001 From: liuheng Date: Wed, 10 May 2023 15:32:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?om=E5=AE=89=E8=A3=85=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0PGDATA=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/local/PreInstallUtility.py | 32 +++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/script/local/PreInstallUtility.py b/script/local/PreInstallUtility.py index 7708708..ad924fa 100644 --- a/script/local/PreInstallUtility.py +++ b/script/local/PreInstallUtility.py @@ -1541,16 +1541,7 @@ Common options: self.logger.debug( "Successfully set %s user profile." % VersionInfo.PRODUCT_NAME) - def setToolEnv(self): - """ - function: set environment variables - input : NA - output: NA - """ - self.logger.debug("Setting tool ENV.") - - userProfile = self.getUserProfile() - + def clearToolEnv(self, userProfile): # clean ENV in os profile self.logger.debug("OS profile exists. Deleting crash old tool ENV.") # clean MPPRC FILE PATH @@ -1568,7 +1559,8 @@ Common options: FileUtil.deleteLine(userProfile, "^\\s*export\\s*UNPACKPATH=.*$") self.logger.debug( "Deleting crash GPHOME in user environment variables.") - + # clean PGDATA + FileUtil.deleteLine(userProfile, "^\\s*export\\s*PGDATA*") # clean LD_LIBRARY_PATH FileUtil.deleteLine(userProfile, "^\\s*export\\s*LD_LIBRARY_PATH=\\$GPHOME\\/script" @@ -1600,13 +1592,23 @@ Common options: "^\\s*export\\s*PATH=\\/root\\/gauss_om\\/%s\\" "/script:\\$PATH$" % self.user) self.logger.debug("Deleting crash PATH in user environment variables.") - # clean PYTHONPATH FileUtil.deleteLine(userProfile, "^\\s*export\\s*PYTHONPATH=\\$GPHOME\\/lib") self.logger.debug( "Deleting crash PYTHONPATH in user environment variables.") + def setToolEnv(self): + """ + function: set environment variables + input : NA + output: NA + """ + self.logger.debug("Setting tool ENV.") + userProfile = self.getUserProfile() + + self.clearToolEnv(userProfile) + # set ENV in os profile self.logger.debug( "Successfully deleted crash old tool ENV. Setting new tool ENV.") @@ -1624,6 +1626,12 @@ Common options: ["export GPHOME=%s" % self.clusterToolPath]) package_dir = os.path.realpath(os.path.join(os.path.realpath(__file__), "../../../")) FileUtil.writeFile(userProfile, ["export UNPACKPATH=%s" % package_dir]) + # set PGDATA + hostName = NetUtil.GetHostIpOrName() + node_info = self.clusterInfo.getDbNodeByName(hostName) + datadir = node_info.datanodes[0].datadir + FileUtil.writeFile(userProfile, + ["export PGDATA=%s" % datadir]) # set PATH if userProfile is ClusterConstants.ETC_PROFILE: FileUtil.writeFile(userProfile, [ -- Gitee From cf101d4cd92afc5fee4077b95c793ef1989546a7 Mon Sep 17 00:00:00 2001 From: liuheng Date: Fri, 12 May 2023 11:42:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?azPriority=E4=BC=98=E5=85=88=E7=BA=A7?= =?UTF-8?q?=E7=9B=B8=E5=90=8C=E5=A2=9E=E5=8A=A0=E6=8A=A5=E9=94=99=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/gspylib/common/DbClusterInfo.py | 4 ++++ script/gspylib/common/ErrorCode.py | 5 +++-- script/impl/preinstall/PreinstallImpl.py | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/script/gspylib/common/DbClusterInfo.py b/script/gspylib/common/DbClusterInfo.py index 31e89c7..91564fc 100644 --- a/script/gspylib/common/DbClusterInfo.py +++ b/script/gspylib/common/DbClusterInfo.py @@ -598,6 +598,7 @@ class instanceInfo(): self.controlPort = 0 # az name self.azName = "" + self.azPriority = 0 self.clusterName = "" # peer port etcd self.peerPort = 0 @@ -1901,6 +1902,7 @@ class dbClusterInfo(): # set DB azName for OLAP for inst in dbNode.datanodes: inst.azName = dbNode.azName + inst.azPriority = dbNode.azPriority return dbNode @@ -2616,6 +2618,7 @@ class dbClusterInfo(): db_inst.syncNum = -1 db_inst.syncNumFirst = "" db_inst.azName = db_node.azName + db_inst.azPriority = db_node.azPriority self.dbNodes[0].datanodes.append(db_inst) self.dbNodes[0].appendInstance(1, MIRROR_ID_AGENT, INSTANCE_ROLE_CMAGENT, INSTANCE_TYPE_UNDEFINED, [], None, "") @@ -3118,6 +3121,7 @@ class dbClusterInfo(): for node in self.dbNodes: for inst in node.datanodes: inst.azName = node.azName + inst.azPriority = node.azPriority self.__setNodePortForSinglePrimaryMultiStandby() def __getPeerInstance(self, dbInst): diff --git a/script/gspylib/common/ErrorCode.py b/script/gspylib/common/ErrorCode.py index 8964539..036e26d 100644 --- a/script/gspylib/common/ErrorCode.py +++ b/script/gspylib/common/ErrorCode.py @@ -189,7 +189,7 @@ class ErrorCode(): " outputMap: %s", 'GAUSS_50238': "[GAUSS-50238] : Check integrality of bin ", "file %s failed." - 'GAUSS_50239': "[GAUSS-50236] : %s should be set in scene config " + 'GAUSS_50239': "[GAUSS-50239] : %s should be set in scene config " "file." } @@ -630,7 +630,8 @@ class ErrorCode(): 'GAUSS_51655': "[GAUSS-51655] : There is %s on the cluster when operating on a cluster" "the %s parameter is not needed.", 'GAUSS_51656': "[GAUSS-51656] : Waiting for udev trigger to end timeout", - 'GAUSS_51657': "[GAUSS-51657] : Waiting for start %s to end timeout" + 'GAUSS_51657': "[GAUSS-51657] : Waiting for start %s to end timeout", + 'GAUSS_51658': "[GAUSS-51658] : The azName is different, and the value of azPriority must be different. " } ########################################################################### diff --git a/script/impl/preinstall/PreinstallImpl.py b/script/impl/preinstall/PreinstallImpl.py index fb868d8..3b25eb1 100644 --- a/script/impl/preinstall/PreinstallImpl.py +++ b/script/impl/preinstall/PreinstallImpl.py @@ -1462,6 +1462,26 @@ class PreinstallImpl: raise Exception(ErrorCode.GAUSS_502["GAUSS_50232"] % ( dataInst.datadir, appPath)) + def checkAzPriorityValue(self): + """ + function : Check azName and azPriority value, The azName is different, and the value of azPriority must be different. + input : None + output : None + """ + priority_map = {} + for db_node in self.context.clusterInfo.dbNodes: + for data_inst in db_node.datanodes: + az_name = data_inst.azName + priority = data_inst.azPriority + if (az_name not in priority_map): + priority_map[az_name] = priority + + result = set() + for value in priority_map.values(): + result.add(value) + if len(result) < len(priority_map.values()): + raise Exception(ErrorCode.GAUSS_516["GAUSS_51658"]) + def checkOSSoftware(self): """ function: setting the dynamic link library @@ -1537,6 +1557,8 @@ class PreinstallImpl: # Check whether the instance directory # conflicts with the application directory. self.checkInstanceDir() + # check azPriotity + self.checkAzPriorityValue() # install tools phase1 self.installToolsPhase1() # exchange user key for root user -- Gitee