drop physical slot in gs_dropnode

This commit is contained in:
zhang_xubo
2022-03-15 21:12:09 +08:00
parent 0f6fc9a86c
commit cff1ce0147
2 changed files with 25 additions and 12 deletions

View File

@ -641,7 +641,7 @@ class OperCommon:
self.logger.debug( self.logger.debug(
"[gs_dropnode]Get repl slot failed:" + output) "[gs_dropnode]Get repl slot failed:" + output)
GaussLog.exitWithError(ErrorCode.GAUSS_358["GAUSS_35809"]) GaussLog.exitWithError(ErrorCode.GAUSS_358["GAUSS_35809"])
return ','.join(output.split('\n')[1:]) return ','.join(output.split('\n'))
def SetReplSlot(self, host, gsqlPath, port, dnid, def SetReplSlot(self, host, gsqlPath, port, dnid,
flag_rollback=False): flag_rollback=False):

View File

@ -69,6 +69,9 @@ STANDBY_INSTANCE = 1
# statu failed # statu failed
STATUS_FAIL = "Failure" STATUS_FAIL = "Failure"
BASE_ID_DATANODE = 6001
MAX_DATANODE_NUM = 9
class ExpansionImpl(): class ExpansionImpl():
""" """
@ -101,10 +104,11 @@ class ExpansionImpl():
self.envFile = mpprcFile self.envFile = mpprcFile
currentTime = str(datetime.datetime.now()).replace(" ", "_").replace( currentTime = str(datetime.datetime.now()).replace(" ", "_").replace(
".", "_") ".", "_").replace(":", "_")
self.commonGsCtl = GsCtlCommon(expansion) self.commonGsCtl = GsCtlCommon(expansion)
self.tempFileDir = "/tmp/gs_expansion_%s" % (currentTime) self.tempFileDir = "/tmp/gs_expansion_%s" % (currentTime)
self.remote_pkg_dir = os.path.join(self.tempFileDir, "pkg")
self.logger.debug("tmp expansion dir is %s ." % self.tempFileDir) self.logger.debug("tmp expansion dir is %s ." % self.tempFileDir)
# primary's wal_keep_segments value # primary's wal_keep_segments value
self.walKeepSegments = -1 self.walKeepSegments = -1
@ -170,14 +174,15 @@ class ExpansionImpl():
for host in self.context.newHostList: for host in self.context.newHostList:
sshTool = SshTool([host], timeout=time_out) sshTool = SshTool([host], timeout=time_out)
# mkdir package dir and send package to remote nodes. # mkdir package dir and send package to remote nodes.
sshTool.executeCommand("umask 0022;mkdir -p %s" % srcFile , sshTool.executeCommand("umask 0022;mkdir -m a+x -p %s; chown %s:%s %s" % \
(self.remote_pkg_dir, self.user, self.group, self.tempFileDir),
DefaultValue.SUCCESS, [host]) DefaultValue.SUCCESS, [host])
for file in pkgfiles: for file in pkgfiles:
if not os.path.exists(file): if not os.path.exists(file):
GaussLog.exitWithError("Package [%s] is not found." % file) GaussLog.exitWithError("Package [%s] is not found." % file)
sshTool.scpFiles(file, srcFile, [host]) sshTool.scpFiles(file, self.remote_pkg_dir, [host])
sshTool.executeCommand("cd %s;tar -xf %s" % (srcFile, pkgfiles[0]), sshTool.executeCommand("cd %s;tar -xf %s" % (self.remote_pkg_dir,
DefaultValue.SUCCESS, [host]) os.path.basename(pkgfiles[0])), DefaultValue.SUCCESS, [host])
self.cleanSshToolFile(sshTool) self.cleanSshToolFile(sshTool)
self.logger.log("End to send soft to each standby nodes.") self.logger.log("End to send soft to each standby nodes.")
@ -351,12 +356,20 @@ class ExpansionImpl():
clusterInfo.initFromStaticConfigWithoutUser(staticFile) clusterInfo.initFromStaticConfigWithoutUser(staticFile)
dbNodes = clusterInfo.dbNodes dbNodes = clusterInfo.dbNodes
maxinsId = -1 newInsIds = []
existInsIds = []
for dbNode in dbNodes: for dbNode in dbNodes:
for dnInst in dbNode.datanodes: for dnInst in dbNode.datanodes:
maxinsId = max(maxinsId, int(dnInst.instanceId)) existInsIds.append(int(dnInst.instanceId))
idx = 0
return range(maxinsId + 1, maxinsId + 1 + num) while idx <= MAX_DATANODE_NUM and num > 0:
insId = BASE_ID_DATANODE + idx
if insId not in existInsIds:
newInsIds.append(insId)
existInsIds.append(insId)
num -= 1
idx += 1
return newInsIds
def installDatabaseOnHosts(self): def installDatabaseOnHosts(self):
""" """
@ -464,12 +477,12 @@ class ExpansionImpl():
if not EnvUtil.getEnv("MPPDB_ENV_SEPARATE_PATH"): if not EnvUtil.getEnv("MPPDB_ENV_SEPARATE_PATH"):
preinstallCmd = "{softPath}/script/gs_preinstall -U {user} -G {group} "\ preinstallCmd = "{softPath}/script/gs_preinstall -U {user} -G {group} "\
"-X {xmlFile} --non-interactive --skip-hostname-set 2>&1".format( "-X {xmlFile} --non-interactive --skip-hostname-set 2>&1".format(
softPath = self.context.packagepath, user = self.user, softPath = self.remote_pkg_dir, user = self.user,
group = self.group, xmlFile = tempXmlFile) group = self.group, xmlFile = tempXmlFile)
else: else:
preinstallCmd = "{softPath}/script/gs_preinstall -U {user} -G {group} " \ preinstallCmd = "{softPath}/script/gs_preinstall -U {user} -G {group} " \
"-X {xmlFile} --sep-env-file={envFile} --skip-hostname-set " \ "-X {xmlFile} --sep-env-file={envFile} --skip-hostname-set " \
"--non-interactive 2>&1".format(softPath = self.context.packagepath, "--non-interactive 2>&1".format(softPath = self.remote_pkg_dir,
user = self.user, user = self.user,
group = self.group, group = self.group,
xmlFile = tempXmlFile, xmlFile = tempXmlFile,