一、环境介绍

  1. 软件环境

    类别 版本 下载链接 备注

    OS openEuler 20.03 (LTS) https://repo.openeuler.org/openEuler-20.03-LTS/ISO/aarch64/openEuler-20.03-LTS-aarch64-dvd.iso 操作系统

    BenchmarkSQL 5.0 https://sourceforge.net/projects/benchmarksql/files/latest/download驱动版本:postgresql-9.3-1102.jdbc41.jar 模拟 TPCC 压力的程序驱动为程序自带的 pg 驱动

    Golang go1.18 linux/arm64 https://golang.google.cn/dl/go1.18.1.linux-arm64.tar.gz https://gitee.com/opengauss/openGauss-connector-go-pq/blob/master/example/multi_ip/multi_ip.go https://gitee.com/opengauss/openGauss-connector-go-pq/tags 模拟应用连接的程序

    openGauss 3.0.0 https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.0.0/arm/openGauss-3.0.0-openEuler-64bit-all.tar.gz 数据库
  2. 硬件环境

    主机 CPU 规格 硬盘 职责

    node1 Kunpeng-920 虚拟机 16c/64g 通用型 SSD 主库

    node2 Kunpeng-920 虚拟机 16c/64g 通用型 SSD 同步备库

    go 程序

    node3 Kunpeng-920 虚拟机 16c/64g 通用型 SSD 异步备库 BenchmarkSQL 程序
  3. 架构图

二、测试场景

  1. go 程序多 IP 连接测试 RTO

    原理:CM 检测主库发生故障,不可访问时会自动选新主,go 驱动通过 target_session_attrs=read-write 控制只连主库,通过 SQL select sysdate,pg_is_in_recovery(); 查询结果时间戳查看 RTO

go 程序代码

[root@cloud001-0003 go]# cat 1.go

// Copyright 2021 Bin Liu bin.liu@enmotech.com

package main

import (

"database/sql"

"fmt"

_ "gitee.com/opengauss/openGauss-connector-go-pq"

"log"

"os"

"os/signal"

"syscall"

"time"

)

/*

需要有访问dbe_perf.global_instance_time的权限

CREATE USER dbuser_monitor with login monadmin PASSWORD 'Mon@1234';

grant usage on schema dbe_perf to dbuser_monitor;

grant select on dbe_perf.global_instance_time to dbuser_monitor;

CGO_ENABLED=0 GOOS=linux GOARCH=arm64

*/

var (

dsnExample = DSN="postgres://gaussdb:secret@foo,bar,baz/mydb?sslmode=disable" DSN="postgres://gaussdb:secret@foo:1,bar:2,baz:3/mydb?sslmode=disable" DSN="user=gaussdb password=***** host=foo,bar,baz port=5432 dbname=mydb sslmode=disable" DSN="user=gaussdb password=***** host=foo,bar,baz port=5432,5432,5433 dbname=mydb sslmode=disable"

)

func main() {

os.Setenv("DSN", "postgres://gaussdb:Enmo12345@...:26000,...:26000,...:26000/postgres?"+

"sslmode=disable&loggerLevel=debug&target_session_attrs=read-write")

connStr := os.Getenv("DSN")

if connStr == "" {

fmt.Println("please define the env DSN. example:\n" + dsnExample)

return

}

fmt.Println("DNS:", connStr)

db, err := sql.Open("opengauss", connStr)

if err != nil {

log.Fatal(err)

}

var (

newTimer = time.NewTicker(1 * time.Second)

doClose = make(chan struct{}, 1)

)

    go func() {
for {
select {
case <-newTimer.C:
if err := getNodeName(db); err != nil {
fmt.Println(err)
}
case <-doClose:
newTimer.Stop()
return
}
}
}() sigChan := make(chan os.Signal, 2)
signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL) //nolint:staticcheck
defer signal.Stop(sigChan)
<-sigChan
doClose <- struct{}{}

}

func getNodeName(db *sql.DB) error {

var err error

// tx, err := db.Begin()

// if err != nil {

// return err

// }

// defer tx.Commit()

var sysdate string

var pgIsInRecovery bool

var nodeName string

err = db.QueryRow("select sysdate,pg_is_in_recovery();").

Scan(&sysdate, &pgIsInRecovery)

if err != nil {

return err

}

var channel string

    // err = db.QueryRow("select channel from pg_stat_get_wal_senders() limit 1 ").
// Scan(&channel)
fmt.Println(sysdate, nodeName, pgIsInRecovery, channel)
// if err != nil {
// return err
// }
return nil

}

模拟数据库故障

[omm@cloud001-0002 data]$ mv db1/ db1.bak

go 程序连接数据库及重连时间

时间差

2022/04/11 16:02:13.614273 connector.go:222: info dialing server host ... port 26000

2022/04/11 16:02:20.683716 connector.go:145: debug find instance host ... port 26000

RTO时间7s

2. BenchmarkSQL 多 IP 连接测试 RTO

原理:CM 检测主库发生故障,不可访问时会自动选新主,jdbc 驱动通过 target_session_type=master 控制只连主库,通过 SQL 程序执行时间戳查看 RTO

BenchmarkSQL 模拟负载及重连时间

时间差

16:02:13,561 [Thread-8] ERROR jTPCCTData : Unexpected SQLException in STOCK_LEVELsage: 153MB / 897MB

16:02:20,834 [Thread-57] FATAL jTPCCTerminal : Unexpected SQLException on rollback: This connection has been closed.

RTO时间7.273s

3. 数据库端观测时间

数据库日志

时间差

2022-04-11 16:02:13.253 tid=1795056 StartAndStop ERROR: data path disc writable test failed, /opt/mogdb/data/data/db1.

2022-04-11 16:02:20.438 tid=1815697 LOG: failover msg from cm_server, data_dir :/opt/mogdb/data/data/db1 nodetype is 2

RTO时间7.185s

总结

在有负载情况(tpcc 压测产生负载,数据库服务器 CPU 占用 50%左右)进行主库宕机测试,

以主库宕机为起始点,备库成功作为新主库启动成功为终止点 RTO 为 7.185s

以主库宕机为起始点,模拟 TPCC 压测的 benchmarkSQL 程序成功重新连接到新主库为终止点 RTO 为 7.273s

以主库宕机为起始点,模拟其它应用连接数据库的 go 程序成功重新连接到新主库为终止点 7s

由于 go 程序至精确到 s,猜测实际时间为 7.185s 以上

综上所述 openGauss Cluster Manager RTO 约为 7s 左右

openGauss Cluster Manager RTO Test的更多相关文章

  1. Spark运行模式_spark自带cluster manager的standalone cluster模式(集群)

    这种运行模式和"Spark自带Cluster Manager的Standalone Client模式(集群)"还是有很大的区别的.使用如下命令执行应用程序(前提是已经启动了spar ...

  2. Service Fabric Cluster Manager

    作者:潘罡 (Van Pan)@ Microsoft 我们回到Service Fabric最底层的话题,谈谈Service Fabric是怎么工作的. 首先,我们回到下面的文档,看看Service F ...

  3. Spark运行模式_Spark自带Cluster Manager的Standalone Client模式(集群)

    终于说到了体现分布式计算价值的地方了! 和单机运行的模式不同,这里必须在执行应用程序前,先启动Spark的Master和Worker守护进程.不用启动Hadoop服务,除非你用到了HDFS的内容. 启 ...

  4. Redis Cluster架构优化

    Redis Cluster架构优化 在<全面剖析Redis Cluster原理和应用>中,我们已经详细剖析了现阶段Redis Cluster的缺点: 无中心化架构 Gossip消息的开销 ...

  5. SQL Server 2016 Failover Cluster + ALwaysOn

    SQL Server 2016 Failover Cluster + ALwaysOn 环境的搭建 近期公司为了提高服务的可用性,就想到了部署AlwaysOn,之前的环境只是部署了SQL Server ...

  6. <Spark><Running on a Cluster>

    Introduction 之前学习的时候都是通过使用spark-shell或者是在local模式运行spark 这边我们首先介绍Spark分布式应用的架构,然后讨论在分布式clusters中运行Spa ...

  7. Spark运行模式_基于YARN的Resource Manager的Client模式(集群)

    现在越来越多的场景,都是Spark跑在Hadoop集群中,所以为了做到资源能够均衡调度,会使用YARN来做为Spark的Cluster Manager,来为Spark的应用程序分配资源. 在执行Spa ...

  8. spark第三篇:Cluster Mode Overview 集群模式预览

    Spark applications run as independent sets of processes on a cluster, coordinated by the SparkContex ...

  9. The evolution of cluster scheduler architectures--转

    原文地址:http://www.firmament.io/blog/scheduler-architectures.html cluster schedulers are an important c ...

  10. Redis 5.0 redis-cli --cluster help说明

    背景: Redis Cluster 在5.0之后取消了ruby脚本 redis-trib.rb的支持(手动命令行添加集群的方式不变),集合到redis-cli里,避免了再安装ruby的相关环境.直接使 ...

随机推荐

  1. 【Azure 应用服务】Azure Function Python函数中,如何获取Event Hub Trigger的消息Event所属于的PartitionID呢?

    问题描述 在通过Azure Function消费Event Hub中的消息时,我们从Function 的 Trigger Details 日志中,可以获得当前Funciton中处理的消息是哪一个分区( ...

  2. 【XInput】手柄模拟鼠标运作之 .NET P/Invoke 和 UWP-API 方案

    上一篇中,老周简单肤浅地介绍了 XInput API 的使用,并模拟了鼠标移动,左.右键单击和滚轮.本篇,咱们用 .NET 代码来完成相同的效果. 说起来也是倒霉,博文写了一半,电脑忽然断电了.不知道 ...

  3. C/C++ 的 指针/引用 传参

    #include <stdio.h> //指针传值 void addOne(int *a) { printf("%8p\n",a); *a = *a+1; } //引用 ...

  4. RocketMQ(10) 消息类型

    一.普通消息 1. 消息发送方式分类 Producer对于消息的发送方式也有多种选择,不同的方式会产生不同的系统效果. 同步发送消息: 同步发送消息是指,Producer发出⼀条消息后,会在收到MQ返 ...

  5. Lua中pair和ipair的区别

    Lua中pair和ipair的区别? 二者都是Lua中内置的迭代器,可以对数组或table进行遍历. 在正常的数组或table的遍历中,二者没有区别. tableNormal={"this& ...

  6. Linux 系统错误码 errno 剖析

    一.errno 介绍 1.1 errno 简介 Linux 中系统调用的错误都存储于错误码 errno 中.errno 由操作系统维护,存储就近发生的错误,即下一次的错误码会覆盖掉上一次的错误. er ...

  7. 轻松驾驭Python格式化:5个F-String实用技巧分享

    F-String(格式化字符串字面值)是在Python 3.6中引入的,它是一种非常强大且灵活的字符串格式化方法. 它允许你在字符串中嵌入表达式,这些表达式在运行时会被求值并转换为字符串,这种特性使得 ...

  8. Redis稳定性之战:AOF日志支撑数据持久化

    ★ Redis24篇集合 1 介绍 AOF(Append Only File)持久化:以独立日志的方式存储了 Redis 服务器的顺序指令序列,并只记录对内存进行修改的指令. 当Redis服务发生雪崩 ...

  9. Educational Codeforces Round 141:C. Yet Another Tournament

    一.来源:Problem - C - Codeforces 二.题面 三.思路 读题: 其他人的胜场由位次决定,对于第i位,其胜场为i-1 人数为\(5·10^5\),不是5(看错了) 每个人和自己比 ...

  10. typescript 解决变量多类型访问属性报错--工作随记

    一个变量类型允许是多个类型,如果访问某个类型的属性,编辑器会直接提示错误 比如 变量 tuple 可能为string 或 number 类型,如果直接访问tuple.toFixed const mix ...