diff --git a/content/zh/post/jinlixin/title/img5.png b/content/zh/post/jinlixin/title/img5.png new file mode 100644 index 0000000000000000000000000000000000000000..830c8bc490a1b830e759df1f04b453909a097406 Binary files /dev/null and b/content/zh/post/jinlixin/title/img5.png differ diff --git "a/content/zh/post/jinlixin/\344\275\277\347\224\250BenchmarkSQL\345\216\213\346\265\213openGauss.md" "b/content/zh/post/jinlixin/\344\275\277\347\224\250BenchmarkSQL\345\216\213\346\265\213openGauss.md" new file mode 100644 index 0000000000000000000000000000000000000000..9f39ef0994e3149a305e8d6b085a0b6ca80b43b1 --- /dev/null +++ "b/content/zh/post/jinlixin/\344\275\277\347\224\250BenchmarkSQL\345\216\213\346\265\213openGauss.md" @@ -0,0 +1,157 @@ ++++ + +title = "使用BenchmarkSQL压测openGauss" + +date = "2021-02-05" + +tags = ["使用BenchmarkSQL压测openGauss"] + +archives = "2021-02" + +author = "金立新" + +summary = "使用BenchmarkSQL压测openGauss" + +img = "/zh/post/jinlixin/title/img5.png" + +times = "12:30" + ++++ + +# 使用BenchmarkSQL压测openGauss + +## 安装配置JDK + +1. 官方网站下载JDK:https://www.oracle.com/technetwork/java/javase/downloads/index.html +2. 配置JDK环境解压到JDK到指定路径。 + + ``` + # 解压到JDK到指定路径 + tar -xvf jdk-8u231-linux-x64.tar.gz -C /usr/local + # 配置系统环境变量 + /etc/profile末尾添加内容如下: + export JAVA_HOME=/usr/local/jdk1.8.0_231 + export CLASSPATH=$JAVA_HOME/lib/ + export PATH=$PATH:$JAVA_HOME/bin + # 配置成功测试 + source /etc/profile + java -version + ``` + + +## 安装配置R语言环境 + +1. 下载R。 + + ``` + wget http://lib.stat.cmu.edu/R/CRAN/src/base/R-3/R-3.0.0.tar.gz + ``` + +2. 编译安装R。 + + ``` + a、解压到R到指定路径 + tar -xvf R-3.0.0.tar.gz /opt/software/R + 编译安装R + cd /opt/software/R + ./configure --prefix=/usr/R --with-pcre1 + b、配置系统环境变量 + /etc/profile末尾添加内容如下: + export R_HOME=/usr/R/ + export PATH=$PATH:$R_HOME/bin + c、配置成功测试 + source /etc/profile + R -version + ``` + + >![](public_sys-resources/icon-note.gif) **说明:** + >编译R语言之前需要安装gcc,gcc-gfortran,libXt-devel等包,yum安装需要配置如下yum源:否者会导致依赖缺失。内网无yum环境建议使用源码安装,需要安装的依赖包较少。 + + - base: mirrors.ustc.edu.cn + - centos-sclo-rh: mirrors.aliyun.com + - epel: mirrors.ustc.edu.cn + - extras: mirrors.aliyun.com + - updates: mirrors.aliyun.com + + +## 安装ant + +1. 官方网站下载Ant工程: + + http://ant.apache.org/ + +2. 配置安装解压Ant到指定路径。 + + ``` + tar -xvf apache-ant-1.10.7-bin.tar.gz -C /usr/local/ant + ``` + +3. 配置环境变量与JDK配置方式相同,/etc/profile末尾添加内容如下: + + ``` + export ANT_HOME=/usr/local/ant + export PATH=$PATH:$ANT_HOME/bin + ``` + +4. 配置测试。 + + ``` + source /etc/profile + ant -version + ``` + + +## 配置使用BenchmarkSQL + +1. 下载官方工程(当前最新版本为5.0): + + https://sourceforge.net/projects/benchmarksql/ + +2. 解压到合适的目录。 + + ``` + unzip benchmarksql-5.0.zip + ``` + +3. 使用Ant进行工程编译。 + + ``` + cd benchmarksql-5.0/ //进入benchmarksql根目录 + ant //执行ant命令,ant工具通过根目录下build.xml文件对源码进行编译并打包到/dist目录下 + ``` + +4. 配置BenchmarkSQL。 + + ``` + a、配置props文件 + 进入run目录,会看到多个不同后缀名的props文件,不同的文件配置不同的数据库,由于我们需要压测postgresql和openGauss,openGauss兼容postgresql,需要配置props.pg文件。cp props.pg props.opengauss在配置文件中需要修改的包括conn,user, password(这三项用于连接指定的数据库,因此需要提前在postgresql中创建好对应的DB以及用户) 。配置项具体如下: + db=postgres + driver=org.postgresql.Driver + conn=jdbc:postgresql://192.168.1.155:5432/tpcc + user= + password= //以上为数据库连接信息 + warehouses=100 //数据仓库数量,每个仓库大概为100M,数据量50W。压测并发数量最多为该值的10倍,需要提前规划好 + loadWorkers=8 //导入数据时,同时导入数据的进程数量 + terminals=1000 //并发数,不超过造数时warehouses值的10倍 + runMins=3 //压测时间,分钟为单位 + terminalWarehouseFixed=true //指定每个终端是否绑定固定数仓,值为布尔型 + resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS //报告路径格式 + b、在opengauss社区下载与openGauss实例版本相匹配的的官方驱动,放入benchmarksql/lib/postgres目录下,替换postgresql的驱动,使用官方驱动适配性更好,表现更好。 + ``` + +5. 运行测试。 + + ``` + cd run //进入run目录 + ./runDatabaseBuild.sh props.opengauss //进行测试库创建,数据导入 + ./runBenchmark.sh props.opengauss //执行配置好的测试 + ./runDatabaseDestroy.sh props.opengauss //清理数据 + ``` + +6. 生成报告。 + + 测试结束后,run目录下会生成一个新目录,它的命名格式为 my\_result\_%tY-%tm-%td\_%tH%tM%tS。 + + 使用 generateReport.sh脚本创建具有图形的 HTML 文件:./generateReport.sh my\_result\_2020-11-02\_221047随后会在my\_result\_\* 目录下生成一个html文件和数张图片,下载到本地,在浏览器中打开report.html,可以看到tpmc的曲线和系统硬件监控信息。 + + diff --git "a/content/zh/post/tracy/openGuass\344\270\273\345\244\207\345\210\207\346\215\242\344\271\213switchover\344\270\216failover.md" "b/content/zh/post/tracy/openGuass\344\270\273\345\244\207\345\210\207\346\215\242\344\271\213switchover\344\270\216failover.md" new file mode 100644 index 0000000000000000000000000000000000000000..ea40315b1ba0f231e84e41953626b383f709f035 --- /dev/null +++ "b/content/zh/post/tracy/openGuass\344\270\273\345\244\207\345\210\207\346\215\242\344\271\213switchover\344\270\216failover.md" @@ -0,0 +1,181 @@ ++++ + +title = "openGuass主备切换之switchover与failover" + +date = "2021-02-05" + +tags = ["openGauss主备"] + +archives = "2021-02" + +author = "tracy" + +summary = "openGuass主备切换之switchover与failover" + +img = "/zh/post/tracy/title/img20.png" + +times = "10:30" + ++++ + +# openGuass主备切换之switchover与failover + +## switchover + +在主备机正常时,出于维护的需要,将备机切换为主机,可保证切换过程中数据不丢失。 + +查看集群实例主备状态:1节点为主库,2节点为备库。 + +``` +$ gs_om -t status --detail +[ Cluster State ] +cluster_state : Normal +redistributing : No +current_az : AZ_ALL +[ Datanode State ] +node node_ip instance state | node node_ip instance state +-------------------------------------------------------------------------------------------------------------------------------------------------------------------- +1 cen7-og1-02 192.168.229.53 6001 /opt/openGuass/data/dn P Primary Normal | 2 cen7-og1-03 192.168.229.54 6002 /opt/openGuass/data/dn S Standby Normal +``` + +在备节点执行切换主备操作: + +``` +$ gs_ctl switchover -D /opt/openGuass/data/dn +[2021-01-15 02:44:55.125][1034][][gs_ctl]: gs_ctl switchover ,datadir is /opt/openGuass/data/dn +[2021-01-15 02:44:55.125][1034][][gs_ctl]: switchover term (1) +[2021-01-15 02:44:55.137][1034][][gs_ctl]: waiting for server to switchover.............. +[2021-01-15 02:45:06.250][1034][][gs_ctl]: done +[2021-01-15 02:45:06.250][1034][][gs_ctl]: switchover completed (/opt/openGuass/data/dn) +``` + +确认集群主备状态:1节点为备库,2节点为主库。 + +``` +$ gs_om -t status --detail +[ Cluster State ] +cluster_state : Normal +redistributing : No +current_az : AZ_ALL +[ Datanode State ] +node node_ip instance state | node node_ip instance state +-------------------------------------------------------------------------------------------------------------------------------------------------------------------- +1 cen7-og1-02 192.168.229.53 6001 /opt/openGuass/data/dn P Standby Normal | 2 cen7-og1-03 192.168.229.54 6002 /opt/openGuass/data/dn S Primary Normal +``` + +保存数据库主备机器信息:确保gs\_om -t refreshconf 命令执行成功,否则再次重启会影响数据库状态。 + +``` +$ gs_om -t refreshconf +Generating dynamic configuration file for all nodes. +Successfully generated dynamic configuration file. +``` + +## failover + +在主机异常时,将备机切换为主机。 + +查看集群实例主备状态:1节点为备库,2节点为主库。 + +``` +$ gs_om -t status --detail +[ Cluster State ] +cluster_state : Normal +redistributing : No +current_az : AZ_ALL +[ Datanode State ] +node node_ip instance state | node node_ip instance state +-------------------------------------------------------------------------------------------------------------------------------------------------------------------- +1 cen7-og1-02 192.168.229.53 6001 /opt/openGuass/data/dn P Standby Normal | 2 cen7-og1-03 192.168.229.54 6002 /opt/openGuass/data/dn S Primary Normal +``` + +备节点执行主备切换操作: + +``` +$ gs_ctl failover -D /opt/openGuass/data/dn +[2021-01-15 03:33:13.803][17292][][gs_ctl]: gs_ctl failover ,datadir is /opt/openGuass/data/dn +[2021-01-15 03:33:13.803][17292][][gs_ctl]: failover term (1) +[2021-01-15 03:33:13.810][17292][][gs_ctl]: waiting for server to failover... +[2021-01-15 03:33:14.823][17292][][gs_ctl]: done +[2021-01-15 03:33:14.823][17292][][gs_ctl]: failover completed (/opt/openGuass/data/dn) +``` + +确认集群主备状态:双主状态。 + +``` +$ gs_om -t status --detail +[ Cluster State ] +cluster_state : Unavailable +redistributing : No +current_az : AZ_ALL +[ Datanode State ] +node node_ip instance state | node node_ip instance state +-------------------------------------------------------------------------------------------------------------------------------------------------------------------- +1 cen7-og1-02 192.168.229.53 6001 /opt/openGuass/data/dn P Primary Normal | 2 cen7-og1-03 192.168.229.54 6002 /opt/openGuass/data/dn S Primary Normal +``` + +在确定降为备机的节点关闭并以standy模式启动OpenGuass服务: + +``` +$ gs_ctl start -D /opt/openGuass/data/dn -M standby +[2021-01-15 03:03:08.695][9126][][gs_ctl]: gs_ctl started,datadir is /opt/openGuass/data/dn +[2021-01-15 03:03:08.864][9126][][gs_ctl]: waiting for server to start... +...... +[2021-01-15 03:03:10.921][9126][][gs_ctl]: done +[2021-01-15 03:03:10.921][9126][][gs_ctl]: server started (/opt/openGuass/data/dn) +``` + +确认集群状态:1节点为主库,2节点为备库,但备库需要修复。 + +``` +$ gs_om -t status --detail +[ Cluster State ] +cluster_state : Degraded +redistributing : No +current_az : AZ_ALL +[ Datanode State ] +node node_ip instance state | node node_ip instance state +-------------------------------------------------------------------------------------------------------------------------------------------------------------------- +1 cen7-og1-02 192.168.229.53 6001 /opt/openGuass/data/dn P Primary Normal | 2 cen7-og1-03 192.168.229.54 6002 /opt/openGuass/data/dn S Standby Need repair(WAL) +``` + +在备库所在节点执行修复命令: + +``` +[omm@cen7-og1-03 ~]$ gs_ctl build -D /opt/openGuass/data/dn +[2021-01-15 03:23:57.702][30784][][gs_ctl]: gs_ctl incremental build ,datadir is /opt/openGuass/data/dn +waiting for server to shut down.... done +server stopped +[2021-01-15 03:23:58.726][30784][][gs_ctl]: fopen build pid file "/opt/openGuass/data/dn/gs_build.pid" success +[2021-01-15 03:23:58.726][30784][][gs_ctl]: fprintf build pid file "/opt/openGuass/data/dn/gs_build.pid" success +[2021-01-15 03:23:58.727][30784][][gs_ctl]: fsync build pid file "/opt/openGuass/data/dn/gs_build.pid" success +...... +[2021-01-15 03:24:02.833][30784][dn_6001_6002][gs_ctl]: done +[2021-01-15 03:24:02.833][30784][dn_6001_6002][gs_ctl]: server started (/opt/openGuass/data/dn) +[2021-01-15 03:24:02.833][30784][dn_6001_6002][gs_ctl]: fopen build pid file "/opt/openGuass/data/dn/gs_build.pid" success +[2021-01-15 03:24:02.833][30784][dn_6001_6002][gs_ctl]: fprintf build pid file "/opt/openGuass/data/dn/gs_build.pid" success +[2021-01-15 03:24:02.835][30784][dn_6001_6002][gs_ctl]: fsync build pid file "/opt/openGuass/data/dn/gs_build.pid" success +``` + +确认集群状态:正常。 + +``` +$ gs_om -t status --detail +[ Cluster State ] +cluster_state : Normal +redistributing : No +current_az : AZ_ALL +[ Datanode State ] +node node_ip instance state | node node_ip instance state +-------------------------------------------------------------------------------------------------------------------------------------------------------------------- +1 cen7-og1-02 192.168.229.53 6001 /opt/openGuass/data/dn P Primary Normal | 2 cen7-og1-03 192.168.229.54 6002 /opt/openGuass/data/dn S Standby Normal +``` + +保存数据库主备机器信息:确保gs\_om -t refreshconf 命令执行成功,否则再次重启会影响数据库状态。 + +``` +$ gs_om -t refreshconf +Generating dynamic configuration file for all nodes. +Successfully generated dynamic configuration file. +``` + diff --git a/content/zh/post/tracy/title/img20.png b/content/zh/post/tracy/title/img20.png new file mode 100644 index 0000000000000000000000000000000000000000..ce35c3cd313c8e4ed939ae18b91b9a64767ab504 Binary files /dev/null and b/content/zh/post/tracy/title/img20.png differ