GBase 8s 配置CM连接管理器

DRAUTO参数等于3是自动切换。因此在此我们介绍通过CM(连接管理器)来仲裁控制。CM可以配置一个也可以配置多个,如果在两个数据库节点上部署CM,优先级最高的CM尽量不要与数据库Primary节点在一台服务器上。CM优先级可以通过PRIORITY参数来区分,参数数值越大,优先级越低。CM可以部署在数据库服务器节点上,也可以部署在应用节点上,不管在哪部署都需要配置互信,在实际生产中,推荐在应用节点上部署CM。

安装CSDK

CM集成在CSDK安装包里,因此我们需要主辅节点都部署CSDK。CSDK的版本号需与数据库版本号一致。

以root用户上传并解压安装包:

 tar -xvf /opt/clientsdk_3.3.0_2_36477d_RHEL6_x86_64.tar 
./installclientsdk 
Preparing to install...
Extracting the JRE from the installer archive...
Unpacking the JRE...
Extracting the installation resources from the installer archive...
Configuring the installer for this system''s environment...

Launching installer...

===============================================================================
GBase ClientSDK                                  (created with InstallAnywhere)
-------------------------------------------------------------------------------

Preparing CONSOLE Mode Installation...




===============================================================================
Introduction
------------

The installer will guide you through the installation of GBase Client-SDK 
4.10.FC4G1.

Copyright General Data Corporation 2014, 2023, All rights reserved.

It is strongly recommended that you quit all programs before continuing with 
this installation.

Respond to each prompt to proceed to the next step in the installation.  If you
want to change something on a previous step, type 'back'.

You may cancel this installation at any time by typing 'quit'.


PRESS <ENTER> TO CONTINUE:  '回车'



===============================================================================
License Agreement
-----------------

Installation and Use of GBase Client-SDK Requires Acceptance of the Following 
License Agreement:

Thank you for choosing GBase product!



Please read carefully the following licencing agreement before installing any 
product: TIANJIN GENERAL DATA TECHNOLOGY CO. LTD. LICENSE AGREEMENT



READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED SUPPLEMENTAL LICENSETERMS  
(COLLECTIVELY "AGREEMENT") CAREFULLY BEFORE OPENING THE SOFTWAREMEDIA PACKAGE. 
BY OPENING THE SOFTWARE MEDIA PACKAGE, YOU AGREE TO THE TERMS OF THIS 
AGREEMENT.  IF YOU ARE ACCESSING THE SOFTWARE ELECTRONICALLY, INDICATE YOUR 
ACCEPTANCE OF THESE  TERMS. IF YOU DO NOT AGREE TO ALL THESE TERMS, PROMPTLY 
RETURN THE UNUSED  SOFTWARE TO YOUR PLACE OF PURCHASE FOR A REFUND.

1. LICENSE TO USE. GeneralData grants you a non-exclusive and non-transferable 
license for  the internal use only of the accompanying software and 
documentation and any error corrections  provided by GeneralData(collectively 
"Software"), by the number of users and the class of  computer hardware for 
which the corresponding fee has been paid.

2. RESTRICTIONS. Software is confidential and copyrighted. Title to Software 

PRESS <ENTER> TO CONTINUE: '回车'

and all  associated intellectual property rights is retained by GeneralData 
and/or its licensors. Except as  specifically authorized in any Supplemental 
License Terms, you may not make copies of Software,  other than a single copy 
of Software for archival purposes. Unless enforcement is prohibited by  
applicable law, you may not modify, decompile, or reverse engineer Software. 
You acknowledge  that Software is not designed, licensed or intended for use in
the design, construction, operation  or maintenance of any nuclear facility. 
GeneralData disclaims any express or implied warranty  of fitness for such 
uses. No right, title or interest in or to any trademark, service mark, logo or
trade name of GeneralData or its licensors is granted under this Agreement.

3. DISCLAIMER OF WARRANTY. Unless specified in this agreement, all express of 
implied  conditions, representations and warranties, including any implied 
warranty of merchantability,  fitness for aparticular purpose or 
non-infringement are disclaimed, except to theextent that  these disclaimers 
are held to be legally invalid.

4. LIMITATION OF LIABILITY. To the extent not prohibited by law, in no event 
will GeneralData  or its licensors be liable for any lost revenue, profit or 
data, or for special, indirect,  consequential, incidental orpunitive damages, 
however caused regardless of the theory of liability,  arising out of or 
related to the use of or inability to use software, even if GeneralData has 

PRESS <ENTER> TO CONTINUE: '回车'

been  advised of the possibility of such damages. In no event will 
GeneralData''s libility to you, whether  incontract, tort(including negligence),
or otherwise, exceed the amount paid by you for Software  under this Agreement.
The foregoing limitations will apply even if the above stated warranty  fails 
of itsessential purpose.

5. TERMINATION. This Agreement is effective until terminated. You may terminate
this  Agreement at any time by destroying all copies of Software. This 
Agreement will terminate  immediately without noticefrom GeneralData if you 
fail to comply with any provision of this  Agreement. Upon Termination, you 
must destroy all copies of Software.



6. EXPORT REGULATIONS. All Software and technical data delivered under this 
Agreement are  subject to US export control laws and may be subject to export 
or import regulations in other  countries. You agree to comply strictly with 
all such laws and regulations and acknowledge that  you have the responsibility
to obtain such licenses to export, re-export, or import as may be  required 
after delivery to you.

7. CHINESE GOVERNMENT RESTRICTED. If Software is being acquired by or on behalf

PRESS <ENTER> TO CONTINUE: '回车'

of the  Chinese Government, then the Government''s rights in Software and 
accompanying documentation  will be only as set forth in this Agreement.

8. GOVERNING LAW. Any action related to this Agreement will be governed by 
Chinese law:  ''COPYRIGHT LAW OF THE PEOPLE''S REPUBLIC OF CHINA", "PATENT LAW OF
THE PEOPLE''S  REPUBLIC OF CHINA", "TRADEMARK LAW OF THE PEOPLE''S REPUBLIC OF 
CHINA", "COMPUTER  SOFTWARE PROTECTION REGULATIONS OF THE PEOPLE''S REPUBLIC OF 
CHINA". No choice of  law rules of any jurisdiction will apply.''

9. SEVERABILITY. If any provision of this Agreement is held to be 
unenforceable, this  Agreement will remain in effect with the provision 
omitted, unless omission would frustrate the  intent of the parties, in which 
case this Agreement will immediately terminate.

10. INTEGRATION. This Agreement is the entire agreement between you and 
GeneralData  relating to its subject matter. It supersedes all prior or 
contemporaneous oral or written  communications, proposals, representations and
warranties and prevails over any conflicting or  additional terms of any quote,
order, acknowledgment, or other communication between the  parties relating to 
its subject matter during the term of this Agreement. No modification of this  
Agreement will be binding, unless in writing and signed by an authorize 
depresentative of each  party. When the translation document has the different 

PRESS <ENTER> TO CONTINUE: '回车'

meaning or has the conflicting views with  Chinese original text conflict, 
should take the laws and regulations promulgation unit as well as  the 
GeneralData issue Chinese original text as the standard.



All trademarks and registered trademarks mentioned herein are the  property of 
their respective owners.



DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N): 'y'



===============================================================================
Installation Location
---------------------

Where Would You Like to Install GBase Client-SDK 4.10.FC4G1?

  Default Install Folder: /opt/GBASE/gbase

ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT
      : /opt/gbase

INSTALL FOLDER IS: /opt/gbase    #输入数据库的安装路径
   IS THIS CORRECT? (Y/N): y



===============================================================================
Installation Features
---------------------




===============================================================================
Choose Product Features
-----------------------

ENTER A COMMA_SEPARATED LIST OF NUMBERS REPRESENTING THE FEATURES YOU WOULD 
LIKE TO SELECT, OR DESELECT. TO VIEW A FEATURE''S DESCRIPTION, ENTER 
'?<NUMBER>'.  PRESS <RETURN> WHEN YOU ARE DONE:

    1- [X] GBase Client SDK
    2-  |-[X] GBase Object Interface for C++
    3-     |-[X] GBase Object Interface for C++ Demos
    4-  |-[X] GBase ESQL/C
    5-     |-[X] GBase ESQL/C Demos
    6-     |-[X] 7.2 Application Compatibility Module
    7-  |-[X] GBase LIBDMI for Client Applications
    8-  |-[X] GBase ODBC Driver
    9-     |-[X] GBase ODBC Driver Demos
   10-  |-[X] GBase Common Database Utilities
   11- [X] Global Language Support (GLS)
   12-  |-[X] West European and Americas
   13-  |-[X] Chinese

Please choose the Features to be installed by this installer.:  #回车默认



===============================================================================
Installation Summary
--------------------

Type 'back' to go to the previous step or 'quit' to cancel the installation. 
Please review the following before continuing:

Product Name:
    GBase Client-SDK

Install Folder:
    /opt/gbase

Product Features:
    GBase Client SDK,
    GBase Object Interface for C++,
    GBase Object Interface for C++ Demos,
    GBase ESQL/C,
    GBase ESQL/C Demos,
    7.2 Application Compatibility Module,
    GBase LIBDMI for Client Applications,
    GBase ODBC Driver,
    GBase ODBC Driver Demos,
    GBase Common Database Utilities,
    Global Language Support (GLS),
    West European and Americas,
    Chinese

Disk Space Information (for Installation Target): 
    Required:  265,155,051 Bytes
    Available: 25,088,147,456 Bytes

PRESS <ENTER> TO CONTINUE: '回车'



===============================================================================
Installing...
-------------

 [==================|==================|==================|==================]
 [------------------|------------------|------------------|------------------]



===============================================================================
Installation Complete
---------------------

Congratulations. GBase Client-SDK 4.10.FC4G1 has been successfully installed 
to:

/opt/gbase

GBase 8s V8.8


PRESS <ENTER> TO EXIT THE INSTALLER: '回车'

CM安装完毕!

配置SQLHOSTS文件

配置SQLHOSTS文件的时候,我们可以直接把之前数据库的sqlhosts文件的基础之上进行修改,添加CM的信息即可(可以直接复制以下内容到自己的sqlhosts文件中,修改IP地址后使用)。如下:

#主节点的sqlhosts文件
[gbasedbt@prim ~]$ cat /opt/gbase/etc/sqlhosts.prim 
#dbservername   nettype         hostname      servicename   options
db_group        group           -                   -       i=10
prim            onsoctcp        192.168.66.201      9088    g=db_group
rhac            onsoctcp        192.168.66.202      9088    g=db_group
cm_read         group           -                   -       i=2,c=0    
oltp_read1      onsoctcp        192.168.66.201      9200    g=cm_read
oltp_read2      onsoctcp        192.168.66.202      9200    g=cm_read
cm_update       group           -                   -       i=3,c=0    
oltp_update1    onsoctcp        192.168.66.201      9300    g=cm_update
oltp_update2    onsoctcp        192.168.66.202      9300    g=cm_update

#辅节点的sqlhosts
[gbasedbt@rhac tmp]$ cat /opt/gbase/etc/sqlhosts.rhac 
#dbservername   nettype         hostname      servicename   options
db_group        group           -                   -       i=10
prim            onsoctcp        192.168.66.201      9088    g=db_group
rhac            onsoctcp        192.168.66.202      9088    g=db_group
cm_read         group           -                   -       i=2,c=0      
oltp_read1      onsoctcp        192.168.66.201      9200    g=cm_read
oltp_read2      onsoctcp        192.168.66.202      9200    g=cm_read
cm_update       group           -                   -       i=3,c=0      
oltp_update1    onsoctcp        192.168.66.201      9300    g=cm_update
oltp_update2    onsoctcp        192.168.66.202      9300    g=cm_update

配置CM文件

接下来,需要配置文件,在安装录下的etc目录下有 cmsm.cfg.sample.all,也就是配置文件的模板,可以根据需求,按此文件进行配置。为方便,也可以直接复制以下内容,并修改IP等内容使用。演示中,在主节点创建了名称为cmsm1.cfg的文件,辅节点创建了名称为cmsm2.cfg的文件。具体如下:

[gbasedbt@prim etc]$ cat cmsm1.cfg 
NAME            CM1
LOGFILE         \${GBASEDBTDIR}/tmp/cm1.log
SQLHOSTS        LOCAL
CM_TIMEOUT                      40
SECONDARY_EVENT_TIMEOUT         25 #warning! Must less than EVENT_TIMEOUT
EVENT_TIMEOUT                   30
LOG     1
DEBUG   0


CLUSTER CLUSTER1
{
  GBASEDBTSERVER        db_group
  SLA oltp_update1             DBSERVERS=PRI    WORKERS=16      MODE=redirect
  SLA oltp_read1               DBSERVERS=(SDS,HDR,RSS)  WORKERS=16      MODE=redirect
  FOC ORDER=ENABLE TIMEOUT=10 RETRY=1 PRIORITY=2
}


# 辅节点
[gbasedbt@rhac tmp]$ cat /opt/gbase/etc/cmsm2.cfg 
NAME            CM2
LOGFILE         \${GBASEDBTDIR}/tmp/cm2.log
SQLHOSTS        LOCAL
CM_TIMEOUT                      40
SECONDARY_EVENT_TIMEOUT         25 #warning! Must less than EVENT_TIMEOUT
EVENT_TIMEOUT                   30
LOG     1
DEBUG   0


CLUSTER CLUSTER2
{
  GBASEDBTSERVER        db_group
  SLA oltp_update2             DBSERVERS=PRI    WORKERS=16      MODE=redirect
  SLA oltp_read2               DBSERVERS=(SDS,HDR,RSS)  WORKERS=16      MODE=redirect
  FOC ORDER=ENABLE TIMEOUT=10 RETRY=1 PRIORITY=1
}
注意:CM配置文件中的PRIORITY是CM的优先级,数字越大,优先级越小。我们把优先级高的(也就是熟悉小的)CM部署在辅节点,因此cmsm2.cfg文件中 PRIORITY=1;cmsm1.cfg文件中PRIORITY=2。

修改ONCONFIG文件

配置完CM文件,我们还需确认一下ONCONFIG文件中的两个参数:DRAUTO、HA_FOC_ORDER。

DRAUTO参数是确定故障切换方式的参数,部署CM,让CM来控制故障转移,需要把DRAUTO参数设置成3。
HA_FOC_ORDER参数是故障转移规则,该值默认值为SDS,HDR,RSS;也就是说如果主节点发生故障,SDS节点会首先成为主节点,若没有SDS或者SDS节点也发生故障HDR节点成为主节点,之后是RSS节点。其中SDS是指SSC节点,HDR是指HAC节点,RSS是指RHAC节点。

配置完CM:

需要确保DRAUTO的值为3;
HA_FOC_ORDER参数可以使用默认值,不做修改。但是若修改了,如本次演示中把默认值改成了RSS,就要确保我的集群是RHAC集群。也就是说确保SSC对应SDS、HAC对应HDR、RHAC对应RSS。

启动CM

编辑好SQLHOSTS文件和配置文件之后,就可以启动CM来监听数据库状态了。
CM的启动命令如下:

# 主节点
[gbasedbt@prim etc]$ oncmsm -c $GBASEDBTDIR/etc/cmsm1.cfg

辅节点

[gbasedbt@rhac tmp]$ oncmsm -c $GBASEDBTDIR/etc/cmsm2.cfg
这种启动方式需要每个节点单独输入,不太方便,因此,我们建议把CM配置文件写入环境变量中并source环境变量,如下最后一行所示:

[gbasedbt@rhac tmp]$ cat /home/gbasedbt/profile.rhac 
export GBASEDBTSERVER=rhac
export GBASEDBTDIR=/opt/gbase
export GBASEDBTSQLHOSTS=/opt/gbase/etc/sqlhosts.rhac
export ONCONFIG=onconfig.rhac
export PATH=/opt/gbase/bin:$PATH
export DB_LOCALE=zh_CN.utf8
export CLIENT_LOCALE=zh_CN.utf8
export GL_USEGLU=1
export CMCONFIG=/opt/gbase/etc/cmsm2.cfg        #将CM配置文件的路径写入环境变量中
[gbasedbt@rhac tmp]$ source /home/gbasedbt/profile.rhac    #刷新环境变量
之后,我们就可以直接用 oncmsm来启动CM了,如下所示:


#主节点
[gbasedbt@prim etc]$ oncmsm 
13:52:16 Warning: cannot process logfile \/opt/gbase/tmp/cm1.log
13:52:16 set CM_TIMEOUT 40
13:52:16 set global SECONDARY_EVENT_TIMEOUT 25
13:52:16 set global EVENT_TIMEOUT 30
13:52:16 SLA oltp_update1 listener mode REDIRECT
13:52:16 SLA oltp_read1 listener mode REDIRECT
13:52:16 Connection Manager name is CM1
Connection Manager started successfully              #标志着CM成功启动
Please check GBase Connection Manager log file: /opt/gbase/tmp/CM1.4184.log


#辅节点
[gbasedbt@rhac tmp]$ oncmsm 
13:52:08 Warning: cannot process logfile \/opt/gbase/tmp/cm2.log
13:52:08 set CM_TIMEOUT 40
13:52:08 set global SECONDARY_EVENT_TIMEOUT 25
13:52:08 set global EVENT_TIMEOUT 30
13:52:08 SLA oltp_update2 listener mode REDIRECT
13:52:08 SLA oltp_read2 listener mode REDIRECT
13:52:08 Connection Manager name is CM2 
Connection Manager started successfully              #标志着CM成功启动
Please check GBase Connection Manager log file: /opt/gbase/tmp/CM2.4198.log

验证CM已启动,并且已连上数据库

验证CM 连上数据库用 gstat -g cmsm命令,我们可以分别在主节点和辅节点执行该命令查看状态
  • 13
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值