首页 > 其他分享 >gbase8s数据表级别的同步(部分数据的下发等功能)一

gbase8s数据表级别的同步(部分数据的下发等功能)一

时间:2024-04-01 20:33:40浏览次数:23  
标签:00 gbase8s -- 192.168 数据表 下发 gbasedbt home gbase

一、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数据库实例名称数据库版本数据库安装路径
node01192.168.6.6node13.5.1/home/gbasedbt/gbase
node02192.168.6.7node23.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

相关文章

  • Gbase8s数据库保姆级安装部署 一
       一、单机安装部署(一)安装之前的环境检查和准备(本次安装以官网最新版本3.5.1为例)1.检查环境和操作系统和安装包是否匹配gbase8s数据库一般以是以CPU架构为主要区分点,主要分为x86架构和arm架构两种:X86:Intel(centos)、兆芯和海光arm:鲲鹏和飞腾--检查操作系统--本次操......
  • 【专题】2024年消费趋势报告合集汇总PDF分享(附原数据表)
    原文链接:https://tecdat.cn/?p=35549原文出处:拓端数据部落公众号随着科技的不断进步和消费者需求的日益多样化,2024年的中国市场将迎来一系列重要的变革与机遇。在消费电子和家电行业,中国作为全球重要的制造基地,将继续引领创新潮流,推动产品智能化、环保化和健康化的发展。同时,ESG......
  • 【专题】2024年3月数字化行业报告合集汇总PDF分享(附原数据表)
    原文链接:https://tecdat.cn/?p=35531原文出处:拓端数据部落公众号在科技浪潮的推动下,人工智能行业正在经历着前所未有的变革与发展。从自然语言处理到数字社交,再到AI数字人、绿色智能制造等多个领域,人工智能正逐渐渗透到我们生活的各个角落。然而,这一过程中也伴随着新的挑战和问......
  • 【专题】2022年中国制造业数字化转型研究报告PDF合集分享(附原数据表)
    报告链接:http://tecdat.cn/?p=32145本文中所说的制造业数字化转型,指的是在制造企业的设计、生产、管理、销售及服务的每一个环节中,将新一代信息技术应用到制造企业的设计、生产、管理、销售及服务的每一个环节中,并可以以每一个环节中产生的数据为基础,展开控制、监测、检测、预测......
  • pandas笔记(五)-- 部门工资最高的员工(数据表的合并与分组)
    题目描述输入employee表和department表,查询部门工资最高的员工,按任意顺序返回结果表测试用例employee表:idnamesalarydepartmentId1Joe7000012Jim9000013Henry8000024Sam6000025Max900001department表:idname1IT......
  • sqlite删除数据表
    1.如何删除表在SQLite中,删除表的SQL语句是DROPTABLE。如果你想要在Python中使用SQLite库(如sqlite3)来删除一个表,你可以按照以下步骤操作:连接到SQLite数据库。创建一个cursor对象。执行DROPTABLE语句。提交事务。关闭cursor和连接。下面是一个删除表的Python示例代码:import......
  • 【专题】展望人工智能银行:当银行遇到AI报告PDF合集分享(附原数据表)
    报告链接:http://tecdat.cn/?p=32210在2016年,AlphaGo机器人打败了18届世界棋王李世石,成为了世界棋坛上最伟大的人物。阅读原文,获取专题报告全文,解锁154份文末人工智能银行相关报告。围棋是一种非常复杂的棋类,它要求有很强的直觉,想像力和策略性的思考,而这一切在很长一段时间里都......
  • 【专题】2024抖音春日热点报告-餐饮篇报告合集PDF分享(附原数据表)
    原文链接:https://tecdat.cn/?p=35422原文出处:拓端数据部落公众号2023年,中国经济表现稳健,零售消费稳定增长,尤其国内旅游市场迅速回暖,人们出行频率回升,酒店、餐饮和旅游服务的消费需求稳步攀升,为相关行业复苏提供了强大动力。据文化和旅游部数据显示,全年国内旅游总人次和收入均实......
  • 数据表示——原码/反码/补码/移码
    计算机中的数值信息分成整数和实数两大类。整数不使用小数点,或者说小数点总是隐含在个位数的右边,所以整数也称为“定点数”。相应地,实数也称为“浮点数”。计算机在存储或运算时,需要采用一种编码形式表示数值,这种表示方式就分为原码、反码和补码。1.原码最高位是符号位......
  • 【专题】2024年中国物流地产市场趋势及展望报告合集PDF分享(附原数据表)
    原文链接:https://tecdat.cn/?p=35388原文出处:拓端数据部落公众号2023年,中国物流地产市场在压力之下呈现出波动的复苏态势,市场需求展现出结构性的变化特点。展望未来,物流地产市场将逐渐走向恢复,但不同区域市场之间的表现可能会更加分化。经济的新业态和新动能将为物流地产市场带......