名称 | 值 |
---|---|
cpu | Intel® Core™ i5-1035G1 CPU @ 1.00GHz |
操作系统 | CentOS Linux release 7.9.2009 (Core) |
内存 | 3G |
逻辑核数 | 2 |
节点1-IP | 192.168.142.10 |
节点2-IP | 192.168.142.11 |
所有部署节点执行此命令。
[root@czg0 pkg]# systemctl stop firewalld
[root@czg0 pkg]# systemctl disable firewalld
所有部署节点进行修改。
将/etc/sysconfig/selinux中的SELINUX设置为disabled。
[root@czg0 pkg]# cat /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@czg0 pkg]# sestatus
SELinux status: disabled
所有部署节点执行此命令。
[root@czg0 pkg]# useradd gbase
[root@czg0 pkg]# passwd gbase
所有部署节点执行此命令。
[root@czg0 pkg]# mkdir -p /opt/Gbase
[root@czg0 pkg]# chown -R gbase:gbase /opt/Gbase
[root@localhost pkg]# tar -xvf GBase8a_MPP_Cluster-License-9.5.3.27-redhat7-x86_64.tar.bz2
每个节点都需要拷贝。
[root@czg0 gcinstall]# scp SetSysEnv.py 192.168.142.11:/opt/
Warning: Permanently added '192.168.142.11' (ECDSA) to the list of known hosts.
SetSysEnv.py 100% 29KB 1.3MB/s 00:00
每个节点都需要执行此脚本。
[root@czg1 opt]# python SetSysEnv.py --dbaUser=gbase --installPrefix=/opt/Gbase --cgroup
执行完最好看一下日志文件:/tmp/SetSysEnv.log
[root@localhost pkg]# cd gcinstall/
[gbase@czg0 gcinstall]$ cat demo.options
installPrefix= /opt/Gbase
coordinateHost = 192.168.142.10,192.168.142.11
coordinateHostNodeID = 234,235,237
dataHost = 192.168.142.10,192.168.142.11
#existCoordinateHost =
#existDataHost =
#existGcwareHost=
gcwareHost = 192.168.142.10,192.168.142.11
#gcwareHostNodeID = 234,235,237
dbaUser = gbase
dbaGroup = gbase
dbaPwd = 'gbase'
rootPwd = 'qwer1234'
#dbRootPwd = ''
#rootPwdFile = rootPwd.json
#characterSet = utf8
#sshPort = 22
参数名 | 描述 |
---|---|
installPrefix | 指定安装目录。 |
coordinateHost | 所有 coordinator 节点 IP 列表,IP 地址之间用“,”分隔。 |
coordinateHostNodeID | 支持对 IPV6 地址的输入,当集群节点为 IPV4 地址,则该参数无效,可不用设置;当集群节点为 IPV6 地址,则用户必须手动设置该参数,该参数为若干个正整数,需要与 coordinateHost 中的 IP 一一对应,用逗号隔开。例如:coordinateHostNodeID = 1,2,3。 |
dataHost | 所有数据节点 IP 列表,IP 地址之间用“,”分隔。 |
existCoordinateHost | 所有已存在的 coordinator 节点 IP 列表,IP 地址之间用“,”分隔。 |
existDataHost | 所有已存在的 data 节点 IP 列表,IP 地址之间用“,”分隔。 |
gcwareHost | 所有gcware节点 IP 列表,IP 地址之间用“,”分隔。 |
dbaUser | 操作系统中的数据库管理员用户,默认gbase。 |
dbaGroup | 操作系统中的数据库管理员用户的用户组,默认gbase。 |
dbaPwd | 操作系统中的数据库管理员用户的密码。 |
rootPwd | 操作系统中的root用户密码。 |
rootPwdFile | 该参数支持 root 用户在多节点不同密码方式,与参数rootPwd 不能同时使用,否则报错。默认密码 111111。 |
dbRootPwd | 数据库 root 用户密码。安装集群时无需设置,仅在集群升级、扩容、节点替换时使用生效。 |
./getesn.py --silent=demo.options --passwordInputMod=pwdsame > License_2023_01_03.txt
写邮件加上附件License_2023_01_03.txt申请试用KEY。
9.5.3.27版本之后是getesn获取指纹信息,之前应该都是gethostsid。
[root@localhost gcinstall]# ./gcinstall.py --silent=demo.options --license_file=你申请下来的试用KEY文件
显示如下表示成功
192.168.142.11 install gcware and cluster on host 192.168.142.11 successfully.
192.168.142.10 install gcware and cluster on host 192.168.142.10 successfully.
Starting all gcluster nodes ...
adding new datanodes to gcware ...
InstallCluster Successfully
[gbase@czg0 gcinstall]$ gcadmin
CLUSTER STATE: ACTIVE
======================================
| GBASE GCWARE CLUSTER INFORMATION |
======================================
| NodeName | IpAddress | gcware |
--------------------------------------
| gcware1 | 192.168.142.10 | OPEN |
--------------------------------------
| gcware2 | 192.168.142.11 | OPEN |
--------------------------------------
========================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
========================================================
| NodeName | IpAddress | gcluster | DataState |
--------------------------------------------------------
| coordinator1 | 192.168.142.10 | OPEN | 0 |
--------------------------------------------------------
| coordinator2 | 192.168.142.11 | OPEN | 0 |
--------------------------------------------------------
===============================================================
| GBASE CLUSTER FREE DATA NODE INFORMATION |
===============================================================
| NodeName | IpAddress | gnode | syncserver | DataState |
---------------------------------------------------------------
| FreeNode1 | 192.168.142.11 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| FreeNode2 | 192.168.142.10 | OPEN | OPEN | 0 |
---------------------------------------------------------------
0 virtual cluster
2 coordinator node
2 free data node
[gbase@czg0 gcinstall]$ gcadmin createvc e vc.xml
[gbase@czg0 gcinstall]$ mv vc.xml vc1.xml
[gbase@czg0 gcinstall]$ cp vc1.xml vc2.xml
192.168.142.10设置为vc1。
192.168.142.11设置为vc2。
[gbase@czg0 gcinstall]$ cat vc1.xml
<?xml version='1.0' encoding="utf-8"?>
<servers>
<rack>
<node ip="192.168.142.10"/>
</rack>
<vc_name name="vc1"/>
<comment message="comment message no more than 60 bytes"/>
</servers>
[gbase@czg0 gcinstall]$ cat vc2.xml
<?xml version='1.0' encoding="utf-8"?>
<servers>
<rack>
<node ip="192.168.142.11"/>
</rack>
<vc_name name="vc2"/>
<comment message="comment message no more than 60 bytes"/>
</servers>
[gbase@czg0 gcinstall]$ gcadmin createvc vc1.xml
parse config file vc1.xml
generate vc id: vc00001
add vc information to cluster
add nodes to vc
gcadmin create vc [vc1] successful
[gbase@czg0 gcinstall]$ gcadmin createvc vc2.xml
parse config file vc2.xml
generate vc id: vc00002
add vc information to cluster
add nodes to vc
gcadmin create vc [vc2] successful
[gbase@czg0 gcinstall]$ gcadmin
CLUSTER STATE: ACTIVE
======================================
| GBASE GCWARE CLUSTER INFORMATION |
======================================
| NodeName | IpAddress | gcware |
--------------------------------------
| gcware1 | 192.168.142.10 | OPEN |
--------------------------------------
| gcware2 | 192.168.142.11 | OPEN |
--------------------------------------
========================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
========================================================
| NodeName | IpAddress | gcluster | DataState |
--------------------------------------------------------
| coordinator1 | 192.168.142.10 | OPEN | 0 |
--------------------------------------------------------
| coordinator2 | 192.168.142.11 | OPEN | 0 |
--------------------------------------------------------
=========================================================================
| GBASE VIRTUAL CLUSTER INFORMATION |
=========================================================================
| VcName | DistributionId | comment |
-------------------------------------------------------------------------
| vc1 | | comment message no more than 60 bytes |
-------------------------------------------------------------------------
| vc2 | | comment message no more than 60 bytes |
-------------------------------------------------------------------------
2 virtual cluster: vc1, vc2
2 coordinator node
0 free data node
[gbase@czg0 gcinstall]$ gcadmin showcluster vc vc1
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: NORMAL
=========================================================================
| GBASE VIRTUAL CLUSTER INFORMATION |
=========================================================================
| VcName | DistributionId | comment |
-------------------------------------------------------------------------
| vc1 | | comment message no more than 60 bytes |
-------------------------------------------------------------------------
=========================================================================================================
| VIRTUAL CLUSTER DATA NODE INFORMATION |
=========================================================================================================
| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
| node1 | 192.168.142.10 | | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
1 data node
[gbase@czg0 gcinstall]$ gcadmin --help
Usage: gcadmin <command> [arg1[, arg2...]]
1. gcadmin distribution <gcChangeInfo.xml> <p num> [d num] [extension] [pattern 1|2]
[db_user user_name] [db_pwd password] [dba_os_password password]
[vc vc_name] : generate distribution, db_user and db_pwd shall input
if database password changed and new distribution data nodes
more than old distribution
2. gcadmin rmdistribution [ID] [vc vc_name] : remove distribution from vc
3. gcadmin addnodes gcChangeInfo.xml [vc_name | single_vc_add_to_rc] : add nodes to cluster or vc, parameter [single_vc_add_to_rc] used for single vc mode add nodes to root cluster
4. gcadmin rmnodes gcChangeInfo.xml [vc_name | single_vc_rm_to_rc] : remove nodes from cluster or vc, parameter [single_vc_rm_to_rc] used for single vc mode remove nodes from default vc to root cluster
5. gcadmin showdistribution [node | f] [vc vc_name] : show cluster distribution, or segments on nodes when
use parameter [node],
[vc vc_name] is unnecessary if only one vc
6. gcadmin switchmode <mode> [vc vc_name | coordinator] : switch cluster mode, mode take value in
[ normal | readonly | recovery ],
[vc vc_name] is unnecessary if only one vc
7. gcadmin showlock [f] : show current cluster lock information,
include lock name, lock owner ip address, etc
8. gcadmin showddlevent [<tablename segname nodeip> | <tablename nodeip> | <max_fevent_num>]
[f] [vc vc_name] : show cluster ddl fail event,
replicated table segname is [n0],
[vc vc_name] is unnecessary if only one vc
9. gcadmin showdmlevent [<tablename segname nodeip> | <max_fevent_num>] [f] [vc vc_name] : show current cluster dml fail event, replicated table segname is [n0],
[vc vc_name] is unnecessary if only one vc
10. gcadmin showdmlstorageevent [[table_id segname nodeip] | <max_fevent_num>] [f] [vc vc_name] : show current cluster dml storage fail event,
replicated table segname is [n0],
[vc vc_name] is unnecessary if only one vc
11. gcadmin showcluster [c | vc vcname] [d] [g] [f] : show vc or cluster information, include all nodes,
cluster state and cluster node information
12. gcadmin getdistribution <ID> <distribution_info.xml> [vc vc_name] : get distribution information
13. gcadmin setnodestate ip <state> : set one node state,state take value in: failure unavailable normal
14. gcadmin showfailover [f] : show failover information
15. gcadmin showfailoverdetail <commitId> [xml_file_name] : write failover information to file [xml_file_name]
16. gcadmin createvc <create_vc.xml | e example_file_name> : create virtual cluster
17. gcadmin rmvc <vc_name> : remove virtual cluster
18. gcadmin importvc <import_vc.xml | e example_file_name> : import vc_name corresponding vc to current vc
19. gcadmin startvc <vc_name1 vc_name2 ...> <os_dba_user_name> <os_dba_password> : start virtual cluster
20. gcadmin stopvc <vc_name1 vc_name2 ...> <os_dba_user_name> <os_dba_password> : stop virtual cluster
21. gcadmin renamevc <old_vc_name> <new_vc_name> : rename virtual cluster
22. gcadmin rmfeventlog ip : remove all feventlog about ip
23. gcadmin --help : show help info
24. gcadmin -V,--version
[gbase@czg0 gcinstall]$ cp gcChangeInfo.xml gcChangeInfo_vc1.xml
[gbase@czg0 gcinstall]$ cp gcChangeInfo.xml gcChangeInfo_vc2.xml
[gbase@czg0 gcinstall]$ cat gcChangeInfo_vc1.xml
<?xml version="1.0" encoding="utf-8"?>
<servers>
<rack>
<node ip="192.168.142.10"/>
</rack>
</servers>
[gbase@czg0 gcinstall]$ cat gcChangeInfo_vc2.xml
<?xml version="1.0" encoding="utf-8"?>
<servers>
<rack>
<node ip="192.168.142.11"/>
</rack>
</servers>
[gbase@czg0 gcinstall]$ gcadmin distribution gcChangeInfo_vc1.xml p 1 d 0 pattern 1 vc vc1 dba_os_password gbase
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
NOTE: node [192.168.142.10] is coordinator node, it shall be data node too
gcadmin generate distribution successful
[gbase@czg0 gcinstall]$ gcadmin distribution gcChangeInfo_vc2.xml p 1 d 0 pattern 1 vc vc2 dba_os_password gbase
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
NOTE: node [192.168.142.11] is coordinator node, it shall be data node too
check vc vc2 os password
copy system table to 192.168.142.11
gcadmin generate distribution successful
参数 | 描述 |
---|---|
p | 每一个节点的分片数。 |
d | 副本数量。 |
pattern number | 数据分布模式,pattern 1 为负载均衡模式,pattern 2 为高可用模式。默认模式1。 |
注意:
gcChangeInfo.xml 文件中 rack 内 node 数量需要大于参数 p 的值(每个节点存放主分片的数量)
[gbase@czg0 gcinstall]$ gcadmin
CLUSTER STATE: ACTIVE
======================================
| GBASE GCWARE CLUSTER INFORMATION |
======================================
| NodeName | IpAddress | gcware |
--------------------------------------
| gcware1 | 192.168.142.10 | OPEN |
--------------------------------------
| gcware2 | 192.168.142.11 | OPEN |
--------------------------------------
========================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
========================================================
| NodeName | IpAddress | gcluster | DataState |
--------------------------------------------------------
| coordinator1 | 192.168.142.10 | OPEN | 0 |
--------------------------------------------------------
| coordinator2 | 192.168.142.11 | OPEN | 0 |
--------------------------------------------------------
=========================================================================
| GBASE VIRTUAL CLUSTER INFORMATION |
=========================================================================
| VcName | DistributionId | comment |
-------------------------------------------------------------------------
| vc1 | 1 | comment message no more than 60 bytes |
-------------------------------------------------------------------------
| vc2 | 2 | comment message no more than 60 bytes |
-------------------------------------------------------------------------
2 virtual cluster: vc1, vc2
2 coordinator node
0 free data node
[gbase@czg0 gcinstall]$ gcadmin showdistribution vc vc1
Distribution ID: 1 | State: new | Total segment num: 1
Primary Segment Node IP Segment ID Duplicate Segment node IP
========================================================================================================================
| 192.168.142.10 | 1 | |
========================================================================================================================
[gbase@czg0 gcinstall]$ gcadmin showdistribution vc vc2
Distribution ID: 2 | State: new | Total segment num: 1
Primary Segment Node IP Segment ID Duplicate Segment node IP
========================================================================================================================
| 192.168.142.11 | 1 | |
========================================================================================================================
[gbase@czg0 gcinstall]$ gccli -uroot -p
Enter password:
gbase> use vc vc1;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)
gbase> initnodedatamap;
Query OK, 1 row affected (Elapsed: 00:00:00.27)
gbase> use vc vc2;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)
gbase> initnodedatamap;
Query OK, 1 row affected (Elapsed: 00:00:00.30)
gbase> use vc vc1;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)
gbase> create database czg;
Query OK, 1 row affected (Elapsed: 00:00:00.02)
gbase> use czg;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)
gbase> create table test(a int);
Query OK, 0 rows affected (Elapsed: 00:00:00.15)
gbase> create user czg@'%' identified by 'qwer1234';
Query OK, 0 rows affected (Elapsed: 00:00:00.13)
gbase> grant all on *.*.* to czg@'%';
Query OK, 0 rows affected (Elapsed: 00:00:00.02)
gbase> set default_vc for czg = vc2;
Query OK, 0 rows affected (Elapsed: 00:00:00.01)
gbase> select * from gbase.user where user='czg'\G;
*************************** 1. row ***************************
Host: %
User: czg
Password: *D75CC763C5551A420D28A227AC294FADE26A2FF2
Default_VC: vc00002
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Reload_priv: Y
Shutdown_priv: Y
Process_priv: Y
File_priv: Y
Grant_priv: N
References_priv: Y
Index_priv: Y
Alter_priv: Y
Show_db_priv: Y
Super_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Execute_priv: Y
Repl_slave_priv: Y
Unmask_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Create_user_priv: Y
Event_priv: Y
Trigger_priv: Y
Drop_table_priv: Y
Drop_view_priv: Y
Drop_database_priv: Y
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
max_cpus: 0
max_memories: 0
max_tmp_space: 0
resource_group: 0
task_priority: 2
user_limit_storage_size:
user_storage_size: 0
UID: 101
plugin: gbase_native_password
auth_string:
1 row in set (Elapsed: 00:00:00.00)
ERROR:
No query specified
gbase> insert into vc2.primarydb.test4 values(8);
Query OK, 1 row affected (Elapsed: 00:00:00.14)
gbase> select * from vc2.primarydb.test4 where a = 8;
+------+
| a |
+------+
| 8 |
+------+
1 row in set (Elapsed: 00:00:00.02)
gbase> select * from vc1.primarydb.test4 where a = 8;
Empty set (Elapsed: 00:00:00.01)
测试一下登录后直接不带VC的查,看是否能查到。
[gbase@czg0 ~]$ gccli -uczg -pqwer1234
GBase client 9.5.3.27.17c111049. Copyright (c) 2004-2023, GBase. All Rights Reserved.
gbase> select * from primarydb.test4 where a = 8;
+------+
| a |
+------+
| 8 |
+------+
1 row in set (Elapsed: 00:00:00.01)
可以查到,成功。
gbase> set default_vc for czg = null;
Query OK, 0 rows affected (Elapsed: 00:00:00.01)
[gbase@czg0 ~]$ gccli -uczg -pqwer1234
GBase client 9.5.3.27.17c111049. Copyright (c) 2004-2023, GBase. All Rights Reserved.
gbase> select * from primarydb.test4 where a = 8;
ERROR 1818 (HY000): No VC selected.
gbase>
默认VC设置回空,再次登录就提示需要VC啦。