From ccf8110812e7ea8fae136b1d0993dae18cd48ae3 Mon Sep 17 00:00:00 2001 From: zhang_xubo <2578876417@qq.com> Date: Wed, 16 Sep 2020 21:27:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E6=9C=89=E4=B8=BB=E5=A4=87=E6=89=A9?= =?UTF-8?q?=E5=AE=B9=E6=97=B6=E5=80=99=EF=BC=8C=E9=9C=80=E8=A6=81=E7=BB=99?= =?UTF-8?q?=E5=A4=87=E6=9C=BApg=5Fhba=E6=96=87=E4=BB=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=A4=87=E6=9C=BA=E7=9A=84=E8=8A=82=E7=82=B9?= =?UTF-8?q?trust=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../om/script/impl/expansion/ExpansionImpl.py | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/manager/om/script/impl/expansion/ExpansionImpl.py b/src/manager/om/script/impl/expansion/ExpansionImpl.py index 939da41a0..9b6dbeff7 100644 --- a/src/manager/om/script/impl/expansion/ExpansionImpl.py +++ b/src/manager/om/script/impl/expansion/ExpansionImpl.py @@ -355,6 +355,7 @@ class ExpansionImpl(): self.queryPrimaryClusterDetail() self.setPrimaryGUCConfig() self.setStandbyGUCConfig() + self.addTrustOnExistNodes() self.restartSingleDbWithPrimaryMode() self.buildStandbyHosts() self.generateClusterStaticFile() @@ -393,6 +394,32 @@ class ExpansionImpl(): primaryHost = self.getPrimaryHostName() standbyHostNames = list(set(nodeList).difference(set([primaryHost]))) self.setGUCOnClusterHosts(standbyHostNames) + + def addTrustOnExistNodes(self): + """ + add host trust in pg_hba.conf on existing standby node. + """ + self.logger.debug("Start to set host trust on existing node.") + allNodeNames = self.context.nodeNameList + newNodeIps = self.context.newHostList + newNodeNames = [] + trustCmd = [] + for node in newNodeIps: + nodeName = self.context.backIpNameMap[node] + newNodeNames.append(nodeName) + cmd = 'host all all %s/32 trust' % node + trustCmd.append(cmd) + existNodes = list(set(allNodeNames).difference(set(newNodeNames))) + for node in existNodes: + dataNode = self.context.clusterInfoDict[node]["dataNode"] + cmd = "" + for trust in trustCmd: + cmd += "gs_guc set -D %s -h '%s';" % (dataNode, trust) + sshTool = SshTool([node]) + resultMap, outputCollect = sshTool.getSshStatusOutput(cmd, + [node], self.envFile) + self.cleanSshToolFile(sshTool) + self.logger.debug("End to set host trust on existing node.") def restartSingleDbWithPrimaryMode(self): """ @@ -431,8 +458,8 @@ retry for %s times" % start_retry_num) for host in standbyHosts: hostName = self.context.backIpNameMap[host] dataNode = self.context.clusterInfoDict[hostName]["dataNode"] - command += "gs_guc set -D %s -h 'host all all %s/32 \ - trust';" % (dataNode, host) + command += ("gs_guc set -D %s -h 'host all all %s/32 " + \ + "trust';") % (dataNode, host) self.logger.debug(command) sshTool = SshTool([primaryHost]) resultMap, outputCollect = sshTool.getSshStatusOutput(command,