Greenplum 大集群应该调整的sshd_config配置

本文涉及的产品
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
简介: 背景 Greenplum是MPP数据库,所以大的集群可能涉及很多的主机以及很多的segments。 Greenplum的很多管理脚本都会涉及ssh的连接,通过SSH进行远程的管理或命令的调用。 因此如果有并发的管理任务,会建立很多的SSH会话。 但是默认情况下Linux的sshd

背景

Greenplum是MPP数据库,所以大的集群可能涉及很多的主机以及很多的segments。

Greenplum的很多管理脚本都会涉及ssh的连接,通过SSH进行远程的管理或命令的调用。

因此如果有并发的管理任务,会建立很多的SSH会话。

但是默认情况下Linux的sshd_config配置是比较保守的,没有想到应用会发起那么多的SSH会话。

如果你遇到这样的报错就要关注一下sshd的配置了

ssh_exchange_identification: Connection closed by remote host
AI 代码解读

哪些sshd参数会影响Greenplum的使用

主要涉及的是sshd的MaxStartups参数. 我在前篇文章有讲到
https://yq.aliyun.com/articles/57903

.1. 指定当前最多有多少个未完成认证的并发连接,由三个值决定

start:rate:full” (e.g. "10:30:60").  
AI 代码解读

start表示未完成认证的连接数,当未完成认证的连接数超过start时,rate/100表示新发起的连接有多大的概率被拒绝连接。

如果未完成认证的连接数达到full,则新发起的连接全部拒绝。

     MaxStartups
             Specifies the maximum number of concurrent unauthenticated connections to the SSH daemon.  
         Additional connections will be dropped until authentication succeeds or the LoginGraceTime expires for a connection.  
         The default is 10:30:100.

             Alternatively, random early drop can be enabled by specifying the three colon separated values “start:rate:full” (e.g. "10:30:60").  
         sshd(8) will refuse connection attempts with a probability of “rate/100” (30%) if there are currently “start” (10) unauthenticated connections.  
         The probability increases linearly and all connection attempts are refused if the number of unauthenticated connections reaches “full” (60).
AI 代码解读

外界可以利用这个对SSHD服务进行类似的ddos攻击,例如用户并发的发起连接,并且不输入密码,等待LoginGraceTime超时。

使得未完成认证的连接大于MaxStartups(full),这样的话,用户正常的连接请求就会被drop掉,非常的危险。

如何减轻呢?似乎不好搞,但是如果不是DDOS工具,则可以尝试一下以下方法

  • LoginGraceTime 调低,例如10秒(用户自己要确保10秒能输入密码,否则设置了太复杂的密码就歇菜了)
  • MaxStartups的几个值都调大,例如 300:30:1000

如果因为Greenplum不断的发起SSH请求,导致了主机不能登录,那就糟了。

赶紧改一改MaxStartups吧。

vi /etc/ssh/sshd_confg
1000:30:3000
AI 代码解读

改后之后, 使用 sshd -T 检测一下配置是否正确

sshd -T|grep -i startup
maxstartups 1000:30:3000
AI 代码解读

检查正确后应用sshd配置即可

service sshd restart

or 

service sshd reload

or 直接发信号给sshd  (man sshd)  
sshd rereads its configuration file when it receives a hangup signal, SIGHUP,   
by executing itself with the name and options it was started with, e.g. /usr/sbin/sshd.  
AI 代码解读

调整maxstartups的理由

gpexpand --help 

-B batch_size
Batch size of remote commands to send to a given host before making a one-second pause. 
  Default is 16. Valid values are 1-128.
The gpexpand utility issues a number of setup commands that may exceed the host's maximum threshold for authenticated connections as defined by MaxStartups in the SSH daemon configuration. The one-second pause allows authentications to be completed before gpexpand issues any more commands.
The default value does not normally need to be changed. However, it may be necessary to reduce the maximum number of commands if gpexpand fails with connection errors such as 'ssh_exchange_identification: Connection closed by remote host.'


http://www.openkb.info/2014/06/greenplum-ssh-connection-issue-due-to.html  
One best practice is to increase the MaxStartups to a value which is larger than the total segments count(primary+mirror).

http://blog.csdn.net/jameswangcnbj/article/details/50801727
8.vi /etc/ssh/sshd_config

 MaxStartups 10000:30:20000
 注意service sshd restart
AI 代码解读

.2.
单个连接允许的最大会话数,也"可能"需要调整。

     MaxSessions
             Specifies the maximum number of open sessions permitted per network connection.  
             The default is 10.
AI 代码解读

注意事项

 sshd 的行为可以通过使用命令行选项和配置文件(默认是sshd_config(5))进行控制,但命令行选项会覆盖配置文件中的设置。  

 sshd 会在收到 SIGHUP 信号后重新读取配置文件,但是最初启动的命令行选项仍然有效(仍会覆盖配置文件中的设置)
AI 代码解读

查看当前sshd已有的配置

通过gcore和gdb输出当前sshd的配置
https://yq.aliyun.com/articles/57916

摘录

Greenplum is MPP architecture, and sometimes it utilizes ssh sessions to complete some tasks.
For large clusters, MaxStartups in /etc/ssh/sshd_config needs to be increased to large enough.
What is MaxStartups?

Specifies the maximum number of concurrent unauthenticated connections to the sshd daemon.
Additional connections will be dropped until authentication succeeds or the LoginGraceTime expires for a connection.
The default is 10.
Under which situations, Greenplum may use ssh sessions? greenplum有好多用到SSH的

Utility tools, for example, gpexpand, gpinitstandby, gpinitsystem, gpstart, etc.  
Web external table.  
Could be more which I do not remember...  
AI 代码解读

Symptoms:

.1. Utility tools may error out: // 遇到这个错误就改关心一下了

ssh_exchange_identification: Connection closed by remote host
AI 代码解读

.2. Below writable external table may error out:

create writable external web table test ( col1  int ) 
execute 'ssh mdw "mkdir -p ''/tmp/test''; cat > /tmp/test/test_$GP_SEGMENT_ID"'
format 'TEXT' ( delimiter as '|'  null as E'\\N'  escape as E'\\') ; 
 
insert into test select generate_series(1,3); 
ERROR:  external table test command ended with SHELL TERMINATED by signal UNRECOGNIZED (127)  
(seg26 xxx.xxx.xxx.xxx:40002 pid=23091) 
DETAIL:  Command: execute:ssh mdw "mkdir -p '/tmp/test'; cat > /tmp/test/test_$GP_SEGMENT_ID"
AI 代码解读

One best practice is to increase the MaxStartups to a value which is larger than the total segments count(primary+mirror).
.1. Increase MaxStartups in /etc/ssh/sshd_config on all servers.

.2. Restart sshd on all servers. // or reload or send signal SIGHUP to sshd

/etc/init.d/sshd restart  
AI 代码解读

祝大家玩得开心,欢迎随时来 阿里云促膝长谈 业务需求 ,恭候光临。

阿里云的小伙伴们加油,努力做 最贴地气的云数据库

目录
打赏
0
0
0
1
20696
分享
相关文章
安装MySQL后,需要调整的10个性能配置项
本文翻译自 Percona 官方博客,适用于 MySQL 5.6 及 5.7 版本。 作者:Stephane Combaudon 原文: https://www.percona.com/blog/2014/01/28/10-mysql-performance-tuning-settings-after-installation/
157 0
mysql 性能提高配置 修改 my.conf
##################################################### mysql 性能提高配置 Begin##################################################### skip-name-resolve #禁止MySQL对外部连接进行DNS解析!!所有远程主机连接授权都要使用IP地址方式 back_
941 0
一步一步学习Redis——使用config命令查看或设置配置项
一步一步学习Redis——使用config命令查看或设置配置项
2246 0
一步一步学习Redis——使用config命令查看或设置配置项
sysctl.conf优化方案
网上关于sysctl.conf的优化方案有各种版本,大多都是抄来抄去的,让新人看了很迷茫。为解决此问题,经过两天的整理,查了N多资料,将大家常用的总结如下,很多默认的不需要修改的暂未涉及,今后将逐步把所有的项目都有个翻译、讲解、修改建议,如有修改,将以此文为准,其他地方的内容,本人不负责更新。
914 0
PostgreSQL配置文件修改及启用方法
总的来说,修改和启用PostgreSQL的配置文件是一个直接而简单的过程。只需要找到配置文件,修改你想要改变的选项,然后重启服务器即可。但是,你需要注意的是,不正确的配置可能会导致服务器性能下降,甚至导致服务器无法启动。因此,在修改配置文件之前,你应该充分理解每个选项的含义和影响,如果可能的话,你应该在测试环境中先进行试验。
168 72
[转]VS2005运行时读写配置文件(.config)
from:http://blog.163.com/szx_rencaijob/blog/static/38447108200711165131665/      在VS 2005中设置和读取配置文件已经变的很简单了,而且是强类型的,读取的值可以直接赋值给相应的变量,无需强制转换。
1110 0

数据库

+关注
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等