Greenplum启动时SSH22端⼝连接拒绝,修改默认通信端⼝
最近在使⽤GP数据库时,由于安全规则问题,GP数据库所在机器开启了防⽕墙,导致GP数据库⽆法启动。
通过查看GP数据库的⽇志发现,GP启动需要SSH 22端⼝。
这是由于GP属于分布式数据库,⼤部分是集安装使⽤,all_hosts_file⽂件是集中所有主机的主机名。gpssh-exkeys 命令主要是⽤各主机间权限互通,⽤于免密登录。默认是使⽤linux的ssh服务,其中⾛的就是默认22端⼝。
由于GP所在机器的安全规则限制,服务器ssh默认端⼝改了,⽆奈只能修改GP的gpssh-exkeys命令的脚本了。
gpssh-exkeys脚本⽂件,需要修改以下⼏个部分(加⼊服务器当前的SSH 端⼝ 6233):
def testAccess(hostname):
'''
Ensure the proper password-less access to the remote host.
Using ssh here also allows discovery of remote host keys *not*
reported by ssh-keyscan.
'''
errfile = os.path.join(tempDir, '')
cmd = 'ssh -p 6233-o "BatchMode=yes" -o "StrictHostKeyChecking=no" %s true 2>%s' % (hostname, errfile)
if GV.opt['-v']: print '[INFO %s]: %s' % (hostname, cmd)
rc = os.system(cmd)
if rc != 0:
print >> sys.stderr, '[ERROR %s] authentication check failed:' % hostname
with open(errfile) as efile:
for line in efile:
print >> sys.stderr, '    ', line.rstrip()
return False
return True
>>>>##
#  step 0
#
#    Ensure the local host can password-less ssh into each remote host
for remoteHost in GV.allHosts:
cmd = ['ssh','-p','6233', 'gpadmin@'+remoteHost.host(), '-o', 'BatchMode=yes', '-o', 'StrictHostKeyChecking=yes',  'true']        p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = pmunicate()
urncode:
print >> sys.stderr, '[ERROR]: Failed to ssh to %s. %s' % (remoteHost.host(), stderr)
print >> sys.stderr, '[ERROR]: Expected passwordless ssh to host %s' % remoteHost.host()
cmd = ('scp -P 6233-q -o "BatchMode yes" -o "NumberOfPasswordPrompts 0" ' +
'%s %s %s %s %s:.ssh/ 2>&1'
% (remoteAuthKeysFile,
remoteKnownHostsFile,
remoteIdentity,
remoteIdentityPub,
canonicalize(h.host())))
h.popen(cmd)
for h wHosts:
greenplum数据库cmd = ('scp -P 6233-q -o "BatchMode yes" -o "NumberOfPasswordPrompts 0" ' +
'%s %s %s %s %s:.ssh/ 2>&1'
% (GV.authorized_keys_fname,
GV.known_hosts_fname,
GV.id_rsa_fname,
GV.id_rsa_pub_fname,
canonicalize(h.host())))
h.popen(cmd)
我在这四个地⽅加了 -p 6233的参数进去。保存退出。
此外还需要修改脚本⽂件。在ssh 后⾯加 -p 6233参数即可。
def execute(self, cmd):
# prepend env. variables from ExcecutionContext.propagate_env_map
# e.g. Given {'FOO': 1, 'BAR': 2}, we'll produce "FOO=1 BAR=2 ..."
self.__class__.trail.add(self.targetHost)
# also propagate env from command instance specific map
keys = sorted(cmd.propagate_env_map.keys(), reverse=True)
for k in keys:
# Escape " for remote execution otherwise it interferes with ssh
"{targethost} \"{gphome} {cmdstr}\"".format(targethost=self.targetHost,
gphome=". %s/greenplum_path.sh;" % self.gphome,
dStr)
在执⾏GP的启动命令,GP数据库就可以正常启动了。
总结:这应该也是greenplum官⽅的⼀个bug,在执⾏gpssh-exkeys,gpinitsystem命令时没有提供⼀个-p 端⼝的配置参数。或许就轻松多了,哎折腾好久。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。

发表评论