GBase 8a集群在用户修改了sshd默认端口时如何安装

Linux 下ssh默认服务端口是22, 如果用户修改了该端口,比如2222,则会导致ssh无法连接22端口而报错。本文介绍在这种情况下,GBase 8a集群安装的方法。

sshd配置了2222端口

[root@gbase_rh7_003 ~]# grep Port  /etc/ssh/sshd_config
Port 2222
#GatewayPorts no
[root@gbase_rh7_003 ~]#

默认ssh连接该服务器报错

[root@gbase_rh7_004 ~]# ssh 10.0.2.103
ssh: connect to host 10.0.2.103 port 22: Connection refused

必须指定-p 参数

[root@gbase_rh7_004 ~]# ssh 10.0.2.103 -p 2222
root@10.0.2.103's password:
Permission denied, please try again.
root@10.0.2.103's password:
Permission denied, please try again.
root@10.0.2.103's password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
[root@gbase_rh7_004 ~]#

修改用户级ssh配置实现指定端口

用户级ssh配置文件为 ~/.ssh/config, 其权限可以设置为600。

[root@gbase_rh7_003 ~]# cat /home/gbase/.ssh/config
Host 10.0.2.10?
        port 2222

该配置的详细用户可以自行搜索,已知的

  • 可以指定多个IP,每个部分用Host作为开头
  • IP可以用通配符,比如?或者*
  • IP可以用CIDR,比如192.168.1.0/24
  • IP【不支持】范围,比如100-106,有些郁闷
  • host的IP可以一次指定多个,中间用空格分隔。如果你的版本不支持,又无法用通配符,那就每个IP写一段。

多个host的测试结果

[gbase@gbase_rh7_003 gcinstall]$ cat ~/.ssh/config
Host 10.0.2.103 10.0.2.104
        port 2222

Host 10.0.2.105
        port 22
[gbase@gbase_rh7_003 gcinstall]$

[gbase@gbase_rh7_003 ~]$
[gbase@gbase_rh7_003 ~]$ ssh 10.0.2.103
gbase@10.0.2.103's password:

[gbase@gbase_rh7_003 ~]$ ssh 10.0.2.104
gbase@10.0.2.104's password:

[gbase@gbase_rh7_003 ~]$ ssh 10.0.2.105
gbase@10.0.2.105's password:

[gbase@gbase_rh7_003 ~]$ 

安装

配置文件

由于gcware服务用ssh探测机器是否在线,所以通过sshPort参数指定。该参数将写入到gcware.conf里。

[gbase@gbase_rh7_003 gcinstall]$ cat demo.options
installPrefix= /opt/gbase
coordinateHost = 10.0.2.103,10.0.2.104
coordinateHostNodeID = 234,235,237
dataHost = 10.0.2.103,10.0.2.104
#existCoordinateHost =
#existDataHost =
#existGcwareHost=
gcwareHost = 10.0.2.103,10.0.2.104
gcwareHostNodeID = 234,235,237
dbaUser = gbase
dbaGroup = gbase
dbaPwd = 'gbase1234'
rootPwd = ''
#dbaHome =
#numaCpuBind=''
#numaMemBind=''
#numaHddBind=''
#dbRootPwd = ''
#rootPwdFile = rootPwd.json
#characterSet = utf8
sshPort = 2222
#genDBUser=gbase
#genDBPwd=GBase2O11O531
[gbase@gbase_rh7_003 gcinstall]$ cat demo.options | grep sshPort
sshPort = 2222
[gbase@gbase_rh7_003 gcinstall]$

安装成功

10.0.2.104              install gcware and cluster on host 10.0.2.104 successfully.
10.0.2.103              install gcware and cluster on host 10.0.2.103 successfully.
Starting all gcluster nodes ...
adding new datanodes to gcware ...
InstallCluster Successfully
[gbase@gbase_rh7_003 gcinstall]$ gcadmin
bash: gcadmin: command not found...
[gbase@gbase_rh7_003 gcinstall]$ source ~/.gbase_profile
[gbase@gbase_rh7_003 gcinstall]$ gcadmin
CLUSTER STATE:         ACTIVE

====================================
| GBASE GCWARE CLUSTER INFORMATION |
====================================
| NodeName |  IpAddress   | gcware |
------------------------------------
| gcware1  |  10.0.2.103  |  OPEN  |
------------------------------------
| gcware2  |  10.0.2.104  |  OPEN  |
------------------------------------
====================================================
|      GBASE COORDINATOR CLUSTER INFORMATION       |
====================================================
|   NodeName   | IpAddress  | gcluster | DataState |
----------------------------------------------------
| coordinator1 | 10.0.2.103 |   OPEN   |     0     |
----------------------------------------------------
| coordinator2 | 10.0.2.104 |   OPEN   |     0     |
----------------------------------------------------
===========================================================
|        GBASE CLUSTER FREE DATA NODE INFORMATION         |
===========================================================
| NodeName  | IpAddress  | gnode | syncserver | DataState |
-----------------------------------------------------------
| FreeNode1 | 10.0.2.104 | OPEN  |    OPEN    |     0     |
-----------------------------------------------------------
| FreeNode2 | 10.0.2.103 | OPEN  |    OPEN    |     0     |
-----------------------------------------------------------

0 virtual cluster
2 coordinator node
2 free data node

[gbase@gbase_rh7_003 gcinstall]$ 

查看gcware的ssh端口

[root@gbase_rh7_003 ~]# grep ssh_port /opt/gbase/10.0.2.103/gcware/config/gcware.conf
    node_ssh_port: 2222
[root@gbase_rh7_003 ~]#