南大通用GBase 8a V95版本的domain方式安装扩容等操作样例,IP可以轻松更换了

GBase 8a在V95版本开始,支持用domain方式来安装集群,只要DNS解析配置好。更换IP时,修改IP和DNS,然后重启网络使新IP生效就可以了,【不需要】重启数据库服务。

安装

安装配置文件demo.options

注意如下几点:
1、管理节点的数量coordinateHost,必须和coordinateHostNodeID相同
2、coordinateHostNodeID 必须是数字,可以0开头。

[gbase@gbase_rh7_001 gcinstall]$ cat demo.options
installPrefix= /opt/gbase
coordinateHost = gbase_rh7_001,gbase_rh7_003
coordinateHostNodeID = 001,003
dataHost = gbase_rh7_001,gbase_rh7_003
#existCoordinateHost =10.0.2.101
#existDataHost =10.0.2.101
dbaUser = gbase
dbaGroup = gbase
dbaPwd = 'gbase1234'
rootPwd = ''
#rootPwdFile = rootPwd.json

DNS配置/etc/hosts

如下是hosts的配置样例,所有节点都要做。

[root@gbase_rh7_003 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.2.101  gbase_rh7_001
10.0.2.102  gbase_rh7_002
10.0.2.104  gbase_rh7_003

安装过程

注意其中现实的是domainName 而不是IP了。

[gbase@gbase_rh7_001 gcinstall]$ ./gcinstall.py --silent=demo.options
*********************************************************************************

promulgation unit as well as the Generaldata issue Chinese original text as the standard.

*********************************************************************************
Do you accept the above licence agreement ([Y,y]/[N,n])? y
*********************************************************************************
                     Welcome to install GBase products
*********************************************************************************
Environmental Checking on gcluster nodes.
CoordinateHost:
gbase_rh7_001    gbase_rh7_003
DataHost:
gbase_rh7_001    gbase_rh7_003
Are you sure to install GCluster on these nodes ([Y,y]/[N,n])? y
gbase_rh7_001           start install on host gbase_rh7_001
gbase_rh7_003           start install on host gbase_rh7_003

gbase_rh7_001           install cluster on host gbase_rh7_001 successfully.
gbase_rh7_003           install cluster on host gbase_rh7_003 successfully.
Starting all gcluster nodes...
adding new datanodes to gcware...
[gbase@gbase_rh7_001 gcinstall]$ 

初始化和校验

请注意,在gcware.conf里,其nodeid就是配置文件里的参数,这个是不允许修改的。

[gbase@gbase_rh7_001 gcinstall]$ gcadmin
CLUSTER STATE:         ACTIVE

================================================================
|            GBASE COORDINATOR CLUSTER INFORMATION             |
================================================================
|   NodeName   |   IpAddress   | gcware | gcluster | DataState |
----------------------------------------------------------------
| coordinator1 | gbase_rh7_001 |  OPEN  |   OPEN   |     0     |
----------------------------------------------------------------
| coordinator2 | gbase_rh7_003 |  OPEN  |   OPEN   |     0     |
----------------------------------------------------------------
==============================================================
|          GBASE CLUSTER FREE DATA NODE INFORMATION          |
==============================================================
| NodeName  |   IpAddress   | gnode | syncserver | DataState |
--------------------------------------------------------------
| FreeNode1 | gbase_rh7_001 | OPEN  |    OPEN    |     0     |
--------------------------------------------------------------
| FreeNode2 | gbase_rh7_003 | OPEN  |    OPEN    |     0     |
--------------------------------------------------------------

0 virtual cluster
2 coordinator node
2 free data node

[gbase@gbase_rh7_001 gcinstall]$ gcadmin distribution gcChangeInfo.xml p 1 d 1
gcadmin generate distribution ...

NOTE: node [gbase_rh7_001] is coordinator node, it shall be data node too
NOTE: node [gbase_rh7_003] is coordinator node, it shall be data node too
gcadmin generate distribution successful

[gbase@gbase_rh7_001 gcinstall]$ gcadmin
CLUSTER STATE:         ACTIVE
VIRTUAL CLUSTER MODE:  NORMAL

================================================================
|            GBASE COORDINATOR CLUSTER INFORMATION             |
================================================================
|   NodeName   |   IpAddress   | gcware | gcluster | DataState |
----------------------------------------------------------------
| coordinator1 | gbase_rh7_001 |  OPEN  |   OPEN   |     0     |
----------------------------------------------------------------
| coordinator2 | gbase_rh7_003 |  OPEN  |   OPEN   |     0     |
----------------------------------------------------------------
=========================================================================================================
|                                    GBASE DATA CLUSTER INFORMATION                                     |
=========================================================================================================
| NodeName |                IpAddress                 | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
|  node1   |              gbase_rh7_001               |       1        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------
|  node2   |              gbase_rh7_003               |       1        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------

[gbase@gbase_rh7_001 gcinstall]$


[gbase@gbase_rh7_001 gcinstall]$ cat /opt/gbase/gcware/config/gcware.conf
totem {
    version: 2
    secauth: off
    nodeid: 001
    interface {
        member {
            memberaddr: gbase_rh7_001
            nodeid: 001
        }
        member {
            memberaddr: gbase_rh7_003
            nodeid: 003
        }
        ringnumber: 0
        bindnetaddr: gbase_rh7_001
        ttl: 1
    }
    transport: udpu
    leader_heartbeat:200
    election_timeout:2000
    server_port:5918
    client_port:5919
    max_message_size:1048576
    max_redolog_size:512
    data_dir:/opt/gbase/gcware/data/gcware
    log_dir:/opt/gbase/gcware/data/gcware
}
logging {
    fileline: off
    to_stderr: no
    to_file: yes
    to_syslog: no
    logfile: /opt/gbase/gcware/log/gcware.log
    gcware_system_log: /opt/gbase/gcluster/log/gcluster/gcware_system.log
    debug: off
    timestamp: on
    logger {
        ident: AMF
        debug: off
        tags: enter|leave|trace1|trace2|trace3|trace4|trace6
    }
}

gcware {
    persistent_interval: 5
    check_interval: 30
    whole_check_interval_num: 20
    cfg_connect_timeout: 5000
    gcluster_port: 5258
    gnode_port: 5050
    syncserver_port: 5288
    node_ssh_port: 22
    check_coordinator_thread_num: 1
    check_dataserver_thread_num: 10
    coordinator {
        member {
            memberaddr: gbase_rh7_001
            nodeid: 001
        }
        member {
            memberaddr: gbase_rh7_003
            nodeid: 003
        }
    }
}
[gbase@gbase_rh7_001 gcinstall]$



[gbase@gbase_rh7_001 gcinstall]$ gccli

GBase client 9.5.2.26.121440. Copyright (c) 2004-2020, GBase.  All Rights Reserved.

gbase> initnodedatamap;
Query OK, 0 rows affected (Elapsed: 00:00:00.74)

gbase> create database testdb;
Query OK, 1 row affected (Elapsed: 00:00:00.02)

gbase> use testdb;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)

gbase> create table t1(id int)distributed by('id');
Query OK, 0 rows affected (Elapsed: 00:00:00.17)

gbase> insert into t1 values(1),(100),(1000),(10000),(100000);
Query OK, 5 rows affected (Elapsed: 00:00:00.17)
Records: 5  Duplicates: 0  Warnings: 0

gbase> select * from t1;
+--------+
| id     |
+--------+
|  10000 |
|      1 |
|    100 |
|   1000 |
| 100000 |
+--------+
5 rows in set (Elapsed: 00:00:00.01)

gbase> ^CAborted

更改IP

不需要停服务

因为IP要换了,连接肯定会断开,对业务肯定有影响,但不需要停数据库服务。

更改网络配置IP

如下例子从10.0.2.103更改为10.0.2.104了。

[root@gbase_rh7_003 ~]# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.103  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::ab19:72ea:2472:cc28  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:8e:d9:28  txqueuelen 1000  (Ethernet)
        RX packets 154449  bytes 159474452 (152.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 46850  bytes 12143385 (11.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 6230  bytes 1041400 (1016.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6230  bytes 1041400 (1016.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:4a:d6:8a  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@gbase_rh7_003 ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
[root@gbase_rh7_003 ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s3
UUID=054d2f84-2976-45a6-baa2-1420019b55f5
DEVICE=enp0s3
ONBOOT=yes
DNS1=114.114.114.114
IPADDR=10.0.2.104
PREFIX=24
GATEWAY=10.0.2.2
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

修改DNS

依然用/etc/hosts作为样例,从103改成了104

[root@gbase_rh7_003 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.2.101  gbase_rh7_001
10.0.2.102  gbase_rh7_002
10.0.2.103  gbase_rh7_003
[root@gbase_rh7_003 ~]# vi /etc/hosts
[root@gbase_rh7_003 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.2.101  gbase_rh7_001
10.0.2.102  gbase_rh7_002
10.0.2.104  gbase_rh7_003
[root@gbase_rh7_003 ~]#

重启网卡服务,让IP生效

service network restart

不需要重启数据库服务

数据库服务不需要重启,原有的连接肯定会报错,但所有新的连接,会从DNS重新获得IP并创建,新发起的业务会正常运行。


[gbase@gbase_rh7_001 ~]$ gcadmin
CLUSTER STATE:         ACTIVE
VIRTUAL CLUSTER MODE:  NORMAL

================================================================
|            GBASE COORDINATOR CLUSTER INFORMATION             |
================================================================
|   NodeName   |   IpAddress   | gcware | gcluster | DataState |
----------------------------------------------------------------
| coordinator1 | gbase_rh7_001 |  OPEN  |   OPEN   |     0     |
----------------------------------------------------------------
| coordinator2 | gbase_rh7_003 |  OPEN  |   OPEN   |     0     |
----------------------------------------------------------------
=========================================================================================================
|                                    GBASE DATA CLUSTER INFORMATION                                     |
=========================================================================================================
| NodeName |                IpAddress                 | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
|  node1   |              gbase_rh7_001               |       1        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------
|  node2   |              gbase_rh7_003               |       1        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------

[gbase@gbase_rh7_001 ~]$


[gbase@gbase_rh7_001 ~]$ gccli testdb

GBase client 9.5.2.26.121440. Copyright (c) 2004-2020, GBase.  All Rights Reserved.

gbase> select * from t1;
+--------+
| id     |
+--------+
|  10000 |
|      1 |
|    100 |
|   1000 |
| 100000 |
+--------+
5 rows in set (Elapsed: 00:00:00.03)

缩容

[gbase@gbase_rh7_001 gcinstall]$ vi gcChangeInfo.xml
[gbase@gbase_rh7_001 gcinstall]$ gcadmin distribution gcChangeInfo.xml p 1 d 0
gcadmin generate distribution ...

[warning]: parameter [d num] is 0, the new distribution will has no segment backup
please ensure this is ok, input [Y,y] or [N,n]: y
gcadmin generate distribution successful

[gbase@gbase_rh7_001 gcinstall]$ gccli

GBase client 9.5.2.26.121440. Copyright (c) 2004-2020, GBase.  All Rights Reserved.
gbase> initnodedatamap;
Query OK, 0 rows affected, 4 warnings (Elapsed: 00:00:00.63)

gbase> rebalance instance;
Query OK, 1 row affected (Elapsed: 00:00:01.02)

等待完成。。。。

gbase> refreshnodedatamap drop 1;
Query OK, 0 rows affected, 4 warnings (Elapsed: 00:00:00.77)

gbase> exit
Bye
[gbase@gbase_rh7_001 gcinstall]$ gcadmin rmdistribution 1
cluster distribution ID [1]
it will be removed now
please ensure this is ok, input [Y,y] or [N,n]: y
gcadmin remove distribution [1] success
[gbase@gbase_rh7_001 gcinstall]$ gcadmin
CLUSTER STATE:         ACTIVE
VIRTUAL CLUSTER MODE:  NORMAL

================================================================
|            GBASE COORDINATOR CLUSTER INFORMATION             |
================================================================
|   NodeName   |   IpAddress   | gcware | gcluster | DataState |
----------------------------------------------------------------
| coordinator1 | gbase_rh7_001 |  OPEN  |   OPEN   |     0     |
----------------------------------------------------------------
| coordinator2 | gbase_rh7_003 |  OPEN  |   OPEN   |     0     |
----------------------------------------------------------------
=========================================================================================================
|                                    GBASE DATA CLUSTER INFORMATION                                     |
=========================================================================================================
| NodeName |                IpAddress                 | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
|  node1   |              gbase_rh7_001               |       2        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------
|  node2   |              gbase_rh7_003               |                | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------

[gbase@gbase_rh7_001 gcinstall]$ vi gcChangeInfo.xml
[gbase@gbase_rh7_001 gcinstall]$ gcadmin rmnodes gcChangeInfo.xml
gcadmin remove nodes ...


gcadmin rmnodes from cluster success

[gbase@gbase_rh7_001 gcinstall]$ gcluster_services all stop
Stopping GCMonit success!
Stopping gcrecover :                                       [  OK  ]
Stopping gcluster :                                        [  OK  ]
Stopping gcware :                                          [  OK  ]
Stopping gbase :                                           [  OK  ]
Stopping syncserver :                                      [  OK  ]

卸载

[gbase@gbase_rh7_001 gcinstall]$ vi demo.options
[gbase@gbase_rh7_001 gcinstall]$ ./unInstall.py --silent=demo.options


These GCluster nodes will be uninstalled.
CoordinateHost:
gbase_rh7_003
DataHost:
gbase_rh7_003
Are you sure to uninstall GCluster ([Y,y]/[N,n])? y
gbase_rh7_003   unInstall gbase_rh7_003 successfully.
Update all coordinator gcware conf.
gbase_rh7_001 update gcware conf successfully.
[gbase@gbase_rh7_001 gcinstall]$ gcluster_services all start
Starting gcware :                                          [  OK  ]
Starting gcluster :                                        [  OK  ]
Starting gcrecover :                                       [  OK  ]
Starting gbase :                                           [  OK  ]
Starting syncserver :                                      [  OK  ]
Starting GCMonit success!
[gbase@gbase_rh7_001 gcinstall]$ gcadmin
CLUSTER STATE:         ACTIVE
VIRTUAL CLUSTER MODE:  NORMAL

================================================================
|            GBASE COORDINATOR CLUSTER INFORMATION             |
================================================================
|   NodeName   |   IpAddress   | gcware | gcluster | DataState |
----------------------------------------------------------------
| coordinator1 | gbase_rh7_001 |  OPEN  |   OPEN   |     0     |
----------------------------------------------------------------
=========================================================================================================
|                                    GBASE DATA CLUSTER INFORMATION                                     |
=========================================================================================================
| NodeName |                IpAddress                 | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
|  node1   |              gbase_rh7_001               |       2        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------

[gbase@gbase_rh7_001 gcinstall]$