【openGauss2.1.0实现X-Tuner进行参数调优】

openGauss2.1.0实现X-Tuner进行参数调优

    • 一、环境说明
    • 二、参数调优步骤

openGauss2.1.0作为一款全新的开源关系型数据库,在性能方面具有很大的优势。通过使用X-Tuner工具,可以对openGauss2.1.0的参数进行优化,以提高其性能。

一、环境说明

  1. 华为云ECS 鲲鹏架构 8vCPU 32G
  2. 操作系统:openEuler20.03TLS
  3. 数据库版本:openGauss2.1.0

二、参数调优步骤

以下是openGauss2.1.0利用X-Tuner进行参数优化的步骤:

  1. 安装X-Tuner工具

    如果不是源码安装openGauss,而是使用编译好的openGauss安装包安装,则X-Tuner是openGauss2.1.0自带的一款工具。在安装openGauss2.1.0时,X-Tuner也会被一同安装。具体安装可以参考:【基于openEuler上安装单机openGauss2.1.0企业版】

    如果是源码安装,则需要单独安装X-Tuner,可参考:【基于openEuler 20.03 和openGauss2.1.0环境中安装X-Tuner】
    本文是基于这种方式进行测试

  2. 参数调优前,使用【omm用户】先执行TPCH脚本queries.sql(该文件是在【openGauss2.1.0 TPC-C数据导入】产生的),记录下脚本执行时间,这个过程可能需要花费十多分钟的时间,请耐心等待。

    [omm@sjmopengauss01 queries]$  gsql -d tpch -p 5432 -r -f /opt/software/tpch-kit/dbgen/queries/queries.sql > /opt/software/tpch-kit/dbgen/queries/queries01.log
    

    执行结束后,查看queries01.log:

    tail -10 /opt/software/tpch-kit/dbgen/queries/queries01.log
    

    结果如下:

    ……
    total time: 1190160  ms
    
  3. 设置X-Tuner工具
    切换到【root用户】,利用X-Tuner获得参数优化建议,执行如下命令,需要输入正确的omm数据库用户密码及omm操作系统用户密码(密码为关卡一中创建omm时设置的用户密码)。

    gs_xtuner recommend --db-name tpch --db-user omm --port 5432 --host 127.0.0.1 --host-user omm
    

    注意上述命令执行时需要输入数据库密码和当前数据库所在主机的密码。
    执行结果如下:

    [root@sjmopengauss01 ~]# gs_xtuner recommend --db-name tpch --db-user omm --port 5432 --host 127.0.0.1 --host-user omm
    Please input the password of database:  #此次输入数据库密码
    Please input the password of host:  # 此处输入host-user后面的用户的登录密码
    Start to recommend knobs. Just a moment, please.
    ***************************************************************** Knob Recommendation Report *****************************************************************
    INFO:
    +---------------------------------------+--------------------------+
    |                 Metric                |          Value           |
    +---------------------------------------+--------------------------+
    |             workload_type             |            ap            |
    |         dirty_background_bytes        |            0             |
    |          current_locks_count          |           0.0            |
    |      current_prepared_xacts_count     |           0.0            |
    |         fetched_returned_ratio        |  0.0005785625290161765   |
    |         average_connection_age        |         0.015156         |
    | checkpoint_proactive_triggering_ratio |    0.0330097087378641    |
    |             cache_hit_rate            |    0.1942159297710038    |
    |        checkpoint_avg_sync_time       |    0.566990291262136     |
    |               nb_gaussdb              |            1             |
    |          current_connections          |           1.0            |
    |              min_free_mem             |          112640          |
    |      shared_buffer_heap_hit_rate      |    12.503635086409243    |
    |           all_database_size           |     1511078.8203125      |
    |             temp_file_size            |     1617.81002869898     |
    |             max_processes             |           203            |
    |          track_activity_size          |          203.0           |
    |                used_mem               |       209986048.0        |
    |            read_write_ratio           |    28.662076606117495    |
    |         rollback_commit_ratio         |  3.400469829314437e-05   |
    |            current_free_mem           |         30957760         |
    |            write_tup_speed            |     320.757764805979     |
    |              os_mem_total             |         32116096         |
    |          search_modify_ratio          |    363442.1821084965     |
    |  checkpoint_dirty_writing_time_window |          450.0           |
    |      shared_buffer_toast_hit_rate     |    57.31707317073171     |
    |      shared_buffer_tidx_hit_rate      |     79.4392523364486     |
    |              os_cpu_count             |            8             |
    |               block_size              |           8.0            |
    |                 uptime                |     8.32598471666667     |
    |                ap_index               |           8.5            |
    |             read_tup_speed            |     9194.14576082865     |
    |       shared_buffer_idx_hit_rate      |    99.66851198714228     |
    |                 is_hdd                |          False           |
    |           enable_autovacuum           |           True           |
    |                is_64bit               |           True           |
    |              load_average             | [0.02, 0.01375, 0.04375] |
    +---------------------------------------+--------------------------+
    p.s: The unit of storage is kB.
    WARN:
    [0]. The value of wal_buffers is a bit high. Generally, an excessively large value does not bring better performance. You can also set this parameter to -1. The database automatically performs adaptation.
    [1]. Detect that your appointed workload does not seem to a TP workload, hence disable enable_mergejoin is better.
    [2]. The number of CPU cores is a little small. Please do not run too high concurrency. You are recommended to set max_connections based on the number of CPU cores. If your job/workload does not consume much CPU, you can also increase it.
    [3]. Detect that your appointed workload does not seem to a TP workload, hence disable enable_nestloop is better.
    [4]. The database runs for a short period of time, and the database description may not be accumulated. The recommendation result may be inaccurate.
    [5]. The total size of all databases is less than the memory size. Therefore, it is unnecessary to set shared_buffers to a large value.
    BAD:
    [0]. We only found 1 gaussdb process(es). In this case, your 'max_process_memory' setting is heavily small.
    [1]. Most applications do not use XA prepared transactions, so should set the max_prepared_transactions to 0. If you do require prepared transactions, you should set this equal to max_connections to avoid blocking. May require increasing kernel memory parameters.
    ****************************************************************** Recommended Knob Settings ******************************************************************
    +---------------------------+-----------+----------+----------+---------+
    |            name           | recommend |   min    |   max    | restart |
    +---------------------------+-----------+----------+----------+---------+
    | default_statistics_target |    1000   |   100    |   1000   |  False  |
    |    effective_cache_size   |  21602334 |  188888  | 21602334 |  False  |
    |  effective_io_concurrency |    200    |   150    |   250    |  False  |
    |      enable_mergejoin     |    off    |    0     |    1     |  False  |
    |      enable_nestloop      |    off    |    0     |    1     |  False  |
    |      max_connections      |    370    |    50    |   741    |   True  |
    | max_prepared_transactions |    370    |    50    |   741    |   True  |
    |     max_process_memory    |  28803112 | 22402420 | 28803112 |   True  |
    |      random_page_cost     |    1.0    |   1.0    |   2.0    |  False  |
    |       shared_buffers      |   188888  |  188892  |  217224  |   True  |
    |        wal_buffers        |    5902   |   2048   |   5902   |   True  |
    +---------------------------+-----------+----------+----------+---------+
    [root@sjmopengauss01 ~]#
    

    再次切换到【omm用户】,根据以上【Recommended Knob Settings 】内容,进行参数优化:

    [omm@sjmopengauss01 ~]$ gs_guc set -D /opt/software/openGauss/data/ -c "shared_buffers = 188888" -c "max_connections = 370" -c "effective_cache_size = 21602334" -c "effective_io_concurrency = 200" -c "wal_buffers = 5902" -c "random_page_cost = 1.0" -c "default_statistics_target = 1000"
    

    执行结果如下:

    [omm@sjmopengauss01 queries]$ gs_guc set -D /opt/software/openGauss/data/ -c "shared_buffers = 188888" -c "max_connections = 370" -c "effective_cache_size = 21602334" -c "effective_io_concurrency = 200" -c "wal_buffers = 5902" -c "random_page_cost = 1.0" -c "default_statistics_target = 1000"
    The gs_guc run with the following arguments: [gs_guc -D /opt/software/openGauss/data/ -c shared_buffers = 188888 -c max_connections = 370 -c effective_cache_size = 21602334 -c effective_io_concurrency = 200 -c wal_buffers = 5902 -c random_page_cost = 1.0 -c default_statistics_target = 1000 set ].
    NOTICE: This parameter has no effect on GaussDB Kernel allocated shared memory size, it does not use the kernel disk buffer, it is only used to estimate. The values are used to calculate the disk page, each page is usually 8192 bytes. Higher than the default value may result in the use of index scans, lower values may result in the selection order of scan.
    NOTICE: Every time a transaction is committed, the contents of WAL buffers are written to disk, it is set to a large value will not bring significant performance gains. If you set it to hundreds of megabytes, you may have written to the disk to improve performance on the server a lot of real-time transaction commits. According to experience, the default value is sufficient for most situations.
    expected instance path: [/opt/software/openGauss/data/postgresql.conf]
    gs_guc set: shared_buffers=188888: [/opt/software/openGauss/data/postgresql.conf]
    gs_guc set: max_connections=370: [/opt/software/openGauss/data/postgresql.conf]
    gs_guc set: effective_cache_size=21602334: [/opt/software/openGauss/data/postgresql.conf]
    gs_guc set: effective_io_concurrency=200: [/opt/software/openGauss/data/postgresql.conf]
    gs_guc set: wal_buffers=5902: [/opt/software/openGauss/data/postgresql.conf]
    gs_guc set: random_page_cost=1.0: [/opt/software/openGauss/data/postgresql.conf]
    gs_guc set: default_statistics_target=1000: [/opt/software/openGauss/data/postgresql.conf]Total instances: 1. Failed instances: 0.
    Success to perform gs_guc!
    

    使用omm用户,重启数据库:

    [omm@sjmopengauss01 queries]$ gs_ctl restart -D /opt/software/openGauss/data -Z single_node -l logfile
    

    查看调优后的参数,执行如下命令:

    [omm@sjmopengauss01 ~]$ cd /opt/software/openGauss/data
    [omm@sjmopengauss01 data]$ cat postgresql.conf|grep -E 'shared_buffers|max_connections|effective_cache_size|effective_io_concurrency|wal_buffers|random_page_cost|default_statistics_target'
    

    结果如下:

    [omm@sjmopengauss01 data]$ cat postgresql.conf|grep -E 'shared_buffers|max_connections|effective_cache_size|effective_io_concurrency|wal_buffers|random_page_cost|default_statistics_target'
    max_connections = 370                   # (change requires restart)
    # Note:  Increasing max_connections costs ~400 bytes of shared memory per
    shared_buffers = 188888                 # min 128kB
    bulk_write_ring_size = 2GB              # for bulkload, max shared_buffers
    #standby_shared_buffers_fraction = 0.3 #control shared buffers use in standby, 0.1-1.0
    effective_io_concurrency = 200          # 1-1000; 0 disables prefetching
    wal_buffers = 5902                      # min 32kB
    random_page_cost = 1.0                  # same scale as above
    effective_cache_size = 21602334
    default_statistics_target = 1000        # range 1-10000
    # max_locks_per_transaction * (max_connections + max_prepared_transactions)
    [omm@sjmopengauss01 data]$
    
  4. 参数调优后,再次使用【omm用户】先执行TPCH脚本queries.sql,查看最终的所消耗的时间,结果如下:

    [omm@sjmopengauss01 queries]$  gsql -d tpch -p 5432 -r -f /opt/software/tpch-kit/dbgen/queries/queries.sql > /opt/software/tpch-kit/dbgen/queries/queries02.log
    

    等待执行完毕,查看queries02.log:

    tail -10 /opt/software/tpch-kit/dbgen/queries/queries02.log
    

    结果如下:

    ……
    total time: 1153799 ms

    比未进行参数调优时耗时少了36361 ms,差不多半分钟时间。如果系统要求性能较高,在高并发和大业务量的场景下,虽缩短了半分钟时间,但从整体上看,性能还是有不少的提升。
    由此,可以看出,总时长比调优前少许多,说明本次的参数调优建议是可取的。
    总之,openGauss2.1.0利用X-Tuner进行参数优化可以有效提高其性能,使其更加适合企业级数据管理。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/60100.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Javaweb入门

Spring Spring发展到今天已经形成一种开发生态圈,Spring提供若干个子项目,每个项目用于完成特定的功能。 Spring Boot可以帮助我们非常快速的构建应用程序、简化开发、提高效率 SpringBootWeb入门 需求:使用Spring Boot开发一个web应用&a…

软件测试面试怎样介绍自己的测试项目?会问到什么程度?

想知道面试时该怎样介绍测试项目?会问到什么程度?那就需要换位思考,思考HR在这个环节想知道什么。 HR在该环节普遍想获得的情报主要是下面这2个方面: 1)应聘者的具体经验和技术能力, 2)应聘者的…

Vector 动态数组(迭代器)

C数据结构与算法 目录 本文前驱课程 1 C自学精简教程 目录(必读) 2 Vector<T> 动态数组&#xff08;模板语法&#xff09; 本文目标 1 熟悉迭代器设计模式&#xff1b; 2 实现数组的迭代器&#xff1b; 3 基于迭代器的容器遍历&#xff1b; 迭代器语法介绍 对迭…

新版HBuilderX在uni_modules创建搜索search组件

1、创建自定义组件 my-search 新版HBuilder没有了 component 文件夹&#xff0c;但是有 uni_modules 文件夹&#xff0c;用来创建组件&#xff1a; 右键 uni_modules 文件夹&#xff0c;点击 新建uni_modules创建在弹出框&#xff0c;填写组件名字&#xff0c;例如&#xff1a…

netmap安装使用

文章目录 1、安装编译netmap2、使用netmap3、运行编写自己的代码 1、安装编译netmap github地址 git clone https://github.com/luigirizzo/netmap 1、进入目录 cd netmap-master/LINUX 2、安装编译环境 apt-get install build-essential 3、初始化配置环境 ./configure 出现这…

【linux命令讲解大全】003.掌握文件属性与权限:chattr和chgrp工具的使用

文章目录 chattr补充说明语法选项实例 chgrp补充说明语法选项参数实例 从零学 python chattr 用来改变文件属性 补充说明 chattr命令用来改变文件属性。这项指令可改变存放在ext2文件系统上的文件或目录属性&#xff0c;这些属性共有以下8种模式&#xff1a; 语法 chattr …

【记录】手机QQ和电脑QQ里的emoji种类有什么差异?

版本 手机 QQ&#xff1a;V 8.9.76.12115 电脑 QQ&#xff1a;QQ9.7.15&#xff08;29157&#xff09; 偶然发现&#xff0c;有一种emoji手机上怎么找都找不到&#xff0c;一开始以为自己失忆了&#xff0c;后来发现这种emoji只在电脑上有。 接下来简单说一下找emoji差异的方式…

第 3 章 栈和队列(顺序栈,算法 3.3)

1. 背景说明&#xff1a; 若迷宫 maze 中存在从入口 start 到出口 end 的通道&#xff0c;则求得一条存放在栈中(从栈底到栈顶)&#xff0c;并返回 TRUE&#xff1b;否则返回 FALSE&#xff0c;注意&#xff0c;该解并非最优解&#xff0c; 最优解需要求得最短路径且可能并非…

C#将text文本中的单双行分开单独保存

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 文本的分割1.设定text文件的名称为02.文本导出 文本的分割 1.设定text文件的名称为0 代码如下&#xff1a; using System; using System.Collections.Generic; us…

axios 使用FormData格式发送GET请求

如果你需要使用&#xff0c;FormData格式&#xff0c;发送GET请求 将参数拼接到 FormData对象 中&#xff0c;使用 URLSearchParams 将FormData对象转换为查询参数字符串&#xff0c;并将其拼接到URL中&#xff0c;这样就能以FormData格式发送GET请求给服务器 注意&#xff1…

Java XPath 使用(2023/08/29)

Java XPath 使用&#xff08;2023/08/29&#xff09; 文章目录 Java XPath 使用&#xff08;2023/08/29&#xff09;1. 前言2. 技术选型3. 技术实现 1. 前言 众所周知&#xff0c;Java 语言适合应用于 Web 开发领域&#xff0c;不擅长用来编写爬虫。但在 Web 开发过程中有时又…

读SQL学习指南(第3版)笔记06_连接和集合

1. 连接 1.1. 笛卡儿积 1.1.1. 交叉连接&#xff08;cross join&#xff09; 1.1.2. 查询并没有指定两个数据表应该如何连接&#xff0c;数据库服务器就生成了笛卡儿积 1.1.2.1. 两个数据表的所有排列组合 1.1.3. 很少会用到&#xff08;至少不会特意用到&#xff09; 1.…

layui框架学习(43:文件上传模块-下)

上一篇文章介绍文件上传模块使用示例时介绍了done和error事件&#xff0c;这两个事件是在文件上传成功&#xff08;原文&#xff1a;在上传接口请求完毕后触发&#xff0c;但文件不一定是上传成功的&#xff09;及上传失败&#xff08;原文&#xff1a;请求上传出现异常&#x…

深入浅出AXI协议(3)——握手过程

一、前言 在之前的文章中我们快速地浏览了一下AXI4协议中的接口信号&#xff0c;对此我们建议先有一个简单的认知&#xff0c;接下来在使用到的时候我们还会对各种信号进行一个详细的讲解&#xff0c;在这篇文章中我们将讲述AXI协议的握手协议。 二、握手协议概述 在前面的文章…

《Kubernetes部署篇:Ubuntu20.04基于二进制安装安装cri-containerd-cni》

一、背景 由于客户网络处于专网环境下&#xff0c; 使用kubeadm工具安装K8S集群&#xff0c;由于无法连通互联网&#xff0c;所有无法使用apt工具安装kubeadm、kubelet、kubectl&#xff0c;当然你也可以使用apt-get工具在一台能够连通互联网环境的服务器上下载cri-tools、cont…

Python-使用xlsxwriter创建单元格下拉列表(数据校验)

在一个B/S系统中&#xff0c;用户经常需要从以Excel的方式填写后导入&#xff0c;此时网页上需要提供Excel填写的模板&#xff0c;将所需填写的字段以及所处的列的位置固定下来。其中&#xff0c;避免用户随意填写导致系统后台校验出错&#xff0c;对于某些字段&#xff0c;系统…

【运维】hadoop3.0.3集群安装(一)多节点安装

文章目录 一.Purpose二. Prerequisites三. Installation1. 节点规划2. Configuring Hadoop in Non-Secure Mode3. 准备工作4. 配置core-site.xmlhdfs-site.xmlyarn-site.xmlmapred-site.xmlworkers 4. 分发配置、创建文件夹5. 格式化6. 操作进程6.1. hdfs启动停止 6.2. yarn启动…

PyQt6 GUI界面设计和Nuitka包生成exe程序(全笔记)

PyQt6 GUI界面设计和Nuitka包,生成exe程序全笔记 目录一、PyQt6包安装1.1 进行环境配置和安装1.2 检查包是否安装成功。1.3 运行desinger.exe二、GUI界面设计,写程序,并能运行成功。三、Nuitka打包生成exe程序3.1 做Nuitka安装准备工作(1)安装C编译器,设置环境变量3.2 安…