diff --git a/script/gspylib/common/DbClusterInfo.py b/script/gspylib/common/DbClusterInfo.py index 31e89c7cd039ba883bde8ad43f7030e4989746b7..91564fca0ee34d87c5aaa37ae72014b731cbfe2e 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 8964539d8eabc8ed9d24905d3804cda3181bea44..036e26d0f16ae2afebe544b689b8adeefccfa25b 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 fb868d88e8775abfbf60a6d7009b2f4b288d601b..3b25eb128184db60b65c9c7f20ba77ec8eb79695 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 diff --git a/script/local/PreInstallUtility.py b/script/local/PreInstallUtility.py index 770870831da53be46a65b4fd06a07cbdfc7466c0..ad924fa8f88d0a152849b42628f0578894588c13 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, [