一、ER的部署
(一)环境检查
1.操作系统环境检查
- 虚拟机是centos进行虚拟出来的测试机
[root@node01 install]# uname -a
Linux node01 3.10.0-1160.71.1.el7.x86_64 #1 SMP Tue Jun 28 15:37:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
2.数据库部署信息检查
服务器名称 | 服务器IP | 数据库实例名称 | 数据库版本 | 数据库安装路径 |
---|---|---|---|---|
node01 | 192.168.6.6 | node1 | 3.5.1 | /home/gbasedbt/gbase |
node02 | 192.168.6.7 | node2 | 3.5.1 | /home/gbasedbt/gbase |
- 本次是按照官网上最新的数据库版本3.5.1进行测试部署搭建的
- 数据库是安装192.168.6.6和192.168.6.7上,软件已安装,且实例都已经初始化,实例名称为node1和node2
--192.168.6.6上检查数据库状态
[gbasedbt@node01 ~]$ onstat -g dis
Your evaluation license will expire on 2025-04-01 00:00:00
On-Line -- Up 00:05:34 -- 1650580 Kbytes
There are 1 servers found
Server : node1
Server Number : 127
Server Type : IDS
Server Status : Up
Server Version: GBase Database Server Version 12.10.FC4G1TL
Shared Memory : 0x44000000
GBASEDBTDIR : /home/gbasedbt/gbase
ONCONFIG : /home/gbasedbt/gbase/etc/onconfig.node1
SQLHOSTS : /home/gbasedbt/gbase/etc/sqlhosts.node1
Host : node01
--192.168.6.7上检查数据库状态
[gbasedbt@node02 ~]$ onstat -g dis
Your evaluation license will expire on 2025-04-01 00:00:00
On-Line -- Up 00:05:42 -- 1650580 Kbytes
There are 1 servers found
Server : node2
Server Number : 227
Server Type : IDS
Server Status : Up
Server Version: GBase Database Server Version 12.10.FC4G1TL
Shared Memory : 0x44000000
GBASEDBTDIR : /home/gbasedbt/gbase
ONCONFIG : /home/gbasedbt/gbase/etc/onconfig.node2
SQLHOSTS : /home/gbasedbt/gbase/etc/sqlhosts.node2
Host : node02
(二)环境调整
1.调整时间同步设置
- 192.168.6.6
--设置当前服务器的时区为上海时间
cp /etc/localtime /etc/localtmebak
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
--把当前时间写入到系统中
clock -w
--将系统时间设置为硬件时间,通常在手动更改系统时间后执行
hwclock --systohc
--同意同网段的服务器进行同步时间
echo -e "restrict 20.5.193.0 mask 255.255.255.0" >>/etc/ntp.conf
--重启一下ntpd服务
systemctl restart ntpd
- 192.168.6.7
--设置当前系统时间的时区为上海时间
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
--设置将要与192.168.6.6的服务器进行时间同步
echo -e "server 20.5.193.95" >>/etc/ntp.conf
--设置定时任务美妙都进行时间更新同步
crontab -e
--输入以下内容
*/1 * * * * /usr/sbin/ntpdate 192.168.6.6>>/tmp/up.log
2.数据库互信
--服务器192.168.6.6上
--使用root用户执行以下命令
echo '+ +' >>/etc/hosts.equiv
echo '192.168.6.7' >>/etc/hosts.equiv
echo '192.168.6.6 root' >>/root/.rhosts
echo '192.168.6.7 root' >>/root/.rhosts
echo '192.168.6.6 gbasedbt' >>/root/.rhosts
echo '192.168.6.7 gbasedbt' >>/root/.rhosts
--gbasedbt用户
echo '192.168.6.6 gbasedbt' >>/home/gbasedbt/.rhosts
echo '192.168.6.7 gbasedbt' >>/home/gbasedbt/.rhosts
--服务器192.168.6.7上
--使用root用户执行以下命令
echo '+ +' >>/etc/hosts.equiv
echo '192.168.6.6' >>/etc/hosts.equiv
echo '192.168.6.6 root' >>/root/.rhosts
echo '192.168.6.7 root' >>/root/.rhosts
echo '192.168.6.6 gbasedbt' >>/root/.rhosts
echo '192.168.6.7 gbasedbt' >>/root/.rhosts
--gbasedbt用户
echo '192.168.6.6 gbasedbt' >>/home/gbasedbt/.rhosts
echo '192.168.6.7 gbasedbt' >>/home/gbasedbt/.rhosts
3.数据库sqlhosts文件
ER的数据复制是通过组的形式进行同步的,故sqlhosts文件内应该配置为组的格式
--192.168.6.6
--原格式如下
[gbasedbt@node01 ~]$ cat gbase/etc/sqlhosts.node1
node1 onsoctcp 192.168.6.6 9088
--调整成格式如下
[gbasedbt@node01 ~]$ cat gbase/etc/sqlhosts.node1
er_1 group - - i=1
node1 onsoctcp 192.168.6.6 9088 g=er_1
er_2 group - - i=2
node2 onsoctcp 192.168.6.7 9088 g=er_2
--192.168.6.7
--原格式如下
[gbasedbt@node01 ~]$ cat gbase/etc/sqlhosts.node2
node2 onsoctcp 192.168.6.7 9088
--调整格式如下
[gbasedbt@node02 ~]$ cat gbase/etc/sqlhosts.node2
er_2 group - - i=2
node2 onsoctcp 192.168.6.7 9088 g=er_2
er_1 group - - i=1
node1 onsoctcp 192.168.6.6 9088 g=er_1
4.添加智能大对象空间和ER使用的数据空间
数据库为了模拟脱机行技术,需要创建一个特定的智能大对象空间来存储需要同步的行数据,其是通过参数
CDR_QDATA_SBSPACE进行指定,除此之外还可以指定一个特定的数据空间用来存储syscdr的系统库和事务记录,使用CDR_DBSPACE指定
--192.168.6.6执行
--创建特定的智能大对象空间
[gbasedbt@node01 node1_dbs]$ touch /home/gbasedbt/gbase/node1_dbs/csdr_sbspace1
[gbasedbt@node01 node1_dbs]$ chmod 660 /home/gbasedbt/gbase/node1_dbs/csdr_sbspace1
[gbasedbt@node01 node1_dbs]$ onspaces -c -S csdr_sbdbs -p /home/gbasedbt/gbase/node1_dbs/csdr_sbspace1 -o 0 -s 300000
Your evaluation license will expire on 2025-04-01 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
[gbasedbt@node01 node1_dbs]$ touch /home/gbasedbt/gbase/node1_dbs/csdr_datadbs1
[gbasedbt@node01 node1_dbs]$ chmod 660 /home/gbasedbt/gbase/node1_dbs/csdr_datadbs1
[gbasedbt@node01 node1_dbs]$ onspaces -c -d csdr_datadbs -p /home/gbasedbt/gbase/node1_dbs/csdr_datadbs1 -o 0 -s 300000 -k 16
Your evaluation license will expire on 2025-04-01 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
--192.168.6.7上执行
[gbasedbt@node02 ~]$ touch /home/gbasedbt/gbase/node2_dbs/csdr_sbspace1
[gbasedbt@node02 ~]$ touch /home/gbasedbt/gbase/node2_dbs/csdr_datadbs1
[gbasedbt@node02 ~]$ chmod 660 /home/gbasedbt/gbase/node2_dbs/csdr*
[gbasedbt@node02 ~]$ onspaces -c -S csdr_sbdbs -p /home/gbasedbt/gbase/node2_dbs/csdr_sbspace1 -o 0 -s 300000
Your evaluation license will expire on 2025-04-01 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
[gbasedbt@node02 ~]$ onspaces -c -d csdr_datadbs -p /home/gbasedbt/gbase/node2_dbs/csdr_datadbs1 -o 0 -s 300000 -k 16
Your evaluation license will expire on 2025-04-01 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
- 修改参数将上述创建的数据空间进行应用和使用
--192.168.6.6上执行修改参数
[gbasedbt@node01 node1_dbs]$ sed -i 's/^CDR_QDATA_SBSPACE.*/CDR_QDATA_SBSPACE csdr_sbdbs/g' /home/gbasedbt/gbase/etc/onconfig.node1
[gbasedbt@node01 node1_dbs]$ sed -i 's/^CDR_DBSPACE.*/CDR_DBSPACE csdr_datadbs/g' /home/gbasedbt/gbase/etc/onconfig.node1
--192.168.6.7上执行修改参数
[gbasedbt@node02 ~]$ sed -i 's/^CDR_QDATA_SBSPACE.*/CDR_QDATA_SBSPACE csdr_sbdbs/g' /home/gbasedbt/gbase/etc/onconfig.node2
[gbasedbt@node02 ~]$ sed -i 's/^CDR_DBSPACE.*/CDR_DBSPACE csdr_datadbs/g' /home/gbasedbt/gbase/etc/onconfig.node2
- 修改后参数进行重启
--192.168.6.6上重启数据库(重启需要gbasedbt用户下),mode=5是重启成功
[gbasedbt@node01 node1_dbs]$ onmode -ky
Your evaluation license will expire on 2025-04-01 00:00:00
[gbasedbt@node01 node1_dbs]$ oninit -vy
Your evaluation license will expire on 2025-04-01 00:00:00
Reading configuration file '/home/gbasedbt/gbase/etc/onconfig.node1'...succeeded
Creating /GBASEDBTTMP/.infxdirs...succeeded
。。。
。。。
Starting scheduling system...succeeded
Verbose output complete: mode = 5
--192.168.6.7上重启数据库(重启需要gbasedbt用户下),mode=5是重启成功
[gbasedbt@node02 ~]$ onmode -ky
Your evaluation license will expire on 2025-04-01 00:00:00
[gbasedbt@node02 ~]$ oninit -vy
Your evaluation license will expire on 2025-04-01 00:00:00
Reading configuration file '/home/gbasedbt/gbase/etc/onconfig.node2'...succeeded
Creating /GBASEDBTTMP/.infxdirs...succeeded
Allocating and attaching to shared memory...succeeded
Creating resident pool 63034 kbytes...succeeded
。。。
。。。
Starting scheduling system...succeeded
Verbose output complete: mode = 5
5.创建日志和数据文件夹
针对ER数据同步,需要两个文件夹存储信息,一个是存储事务中止的报错信息日志的文件夹ATS(
Aborted Transaction Spool),一个是存储临时的中间数据集用来同步RIS(
Row Information Spool),本次分别在两个备机上创建
--192.168.6.6上创建,使用gbasedbt用户
[gbasedbt@node01 ~]$ mkdir /home/gbasedbt/gbase/ATS
[gbasedbt@node01 ~]$ mkdir /home/gbasedbt/gbase/RIS
--192.168.6.7上创建,使用gbasedbt用户
[gbasedbt@node02 ~]$ mkdir /home/gbasedbt/gbase/ATS
[gbasedbt@node02 ~]$ mkdir /home/gbasedbt/gbase/RIS
(三)配置ER同步
1.配置ER
--192.168.6.6上执行,-I指定的是sqlhosts的定义的第一个组,-A指定的是事务中断日志,-R指定的数据中转文件夹
cdr define server -I er_1 -A /home/gbasedbt/gbase/ATS/ -R /home/gbasedbt/gbase/RIS/
--192.168.6.7上执行,-S是指定的同步的服务器组
cdr define server -I er_2 -S er_1 -A /home/gbasedbt/gbase/ATS/ -R /home/gbasedbt/gbase/RIS/
2.定义表级别的同步
--192.168.6.6创建带日志的库和测试表,表必须有主键否则会失败
[gbasedbt@node01 ~]$ dbaccess - -
Your evaluation license will expire on 2025-04-01 00:00:00
> create database test with log;
Database created.
> create table test(id int,name varchar);
Table created.
>alter table test add constraint primary key(id) constraint test_pkid;
--192.168.6.7创建带日志的库和测试表,表必须要有主键
[gbasedbt@node02 ~]$ dbaccess - -
Your evaluation license will expire on 2025-04-01 00:00:00
> create database test with log;
Database created.
> create table test(id int,name varchar);
Table created.
>alter table test add constraint primary key(id) constraint test_pkid;
- 添加表级别复制
--192.168.6.6上执行,-C定义复制的名称,"库名@sqlhosts的组名:属主.表名" "select * from 表名"
[gbasedbt@node01 ~]$ cdr define replicate -C ignore test_test "test@er_1:gbasedbt.test" "select * from test" "test@er_2:gbasedbt.test" "select * from test"
Interpreting this replicate as a master replicate.
Verification of test@er_1:gbasedbt.test started
Verification of test@er_1:gbasedbt.test is successful
Verification of test@er_2:gbasedbt.test started
Table 'test@er_2.test' does not contain primary key.
- 启动实时复制
--192.168.6.6上
[gbasedbt@node01 ~]$ cdr start repl test_test
[gbasedbt@node01 ~]$
(四)测试同步
1.测试数据插入和删除
--192.168.6.6插入数据
[gbasedbt@node01 ~]$ dbaccess test -
Your evaluation license will expire on 2025-04-01 00:00:00
Database selected.
> insert into test values(1,'a');
1 row(s) inserted.
--192.168.6.7上查看
[gbasedbt@node02 ~]$ dbaccess test -
Your evaluation license will expire on 2025-04-01 00:00:00
Database selected.
> select * from test;
id name
1 a
1 row(s) retrieved.
--192.168.6.6上删除数据
> delete test;
1 row(s) deleted.
--192.168.6.7上查看
> select * from test;
id name
No rows found.
--192.168.6.7上插入数据
[gbasedbt@node02 ~]$ dbaccess test -
Your evaluation license will expire on 2025-04-01 00:00:00
Database selected.
> insert into test values(1,'a');
1 row(s) inserted.
>
--192.168.6.6上插入数据
[gbasedbt@node01 ~]$ dbaccess test -
Your evaluation license will expire on 2025-04-01 00:00:00
selec
Database selected.
> select * from test;
id name
1 a
1 row(s) retrieved.
>
标签:00,gbase8s,--,192.168,数据表,下发,gbasedbt,home,gbase
From: https://blog.csdn.net/qq_59083851/article/details/137234451