暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

openGauss 每日一练第 1 天|openGauss 数据库状态查看

原创 代野(Tank) 2022-11-28
1681

第一届的活动没能有时间来参加,第二届我来了。

第一课学习内容是“openGauss 数据库状态查看”,目的是掌握从操作系统层面和使用 openGauss 工具查看数据库的状态、版本和数据文件目录。

gs_ctl 工具

openGauss gs_ctl 工具可参考其在线文档的描述,贴出部分信息如下:

gs_ctl 是 openGauss 提供的数据库服务控制工具,可以用来启停数据库服务和查询数据库状态。主要供 openGauss 管理模块调用。

gs_ctl 工具由操作系统用户 omm 执行。

  • 启动、停止、重启openGauss节点。
  • 在不停止数据库的情况下,重新加载配置文件(postgresql.conf,pg_hba.conf)。
  • 主备切换、主备状态查询、重建和重建状态查询。

在使用之前,建议通过帮助明令快速了解下相关参数,共分为 10 种类型,如 option 参数、start 和 restart 模式的参数、stop 和 restart 模式的参数等。输出内容较多,这里不贴输出内容。

gs_ctl --help

课程作业

  1. 从操作系统层面查看数据库进程和线程,判断数据库是否启动
omm@modb:~$ ps -ef|grep gauss omm 1 0 0 22:23 ? 00:00:09 gaussdb omm 528 419 0 22:57 pts/0 00:00:00 grep gauss omm@modb:~$ ps -Tp 1 PID SPID TTY TIME CMD 1 1 ? 00:00:00 gaussdb 1 293 ? 00:00:00 jemalloc_bg_thd 1 299 ? 00:00:00 gaussdb 1 300 ? 00:00:00 syslogger 1 301 ? 00:00:00 jemalloc_bg_thd 1 302 ? 00:00:00 alarm 1 303 ? 00:00:00 reaper 1 304 ? 00:00:00 jemalloc_bg_thd 1 305 ? 00:00:00 jemalloc_bg_thd 1 349 ? 00:00:00 checkpointer 1 350 ? 00:00:00 Spbgwriter 1 352 ? 00:00:00 pagewriter 1 351 ? 00:00:01 pagewriter 1 353 ? 00:00:00 pagewriter 1 354 ? 00:00:00 pagewriter 1 355 ? 00:00:00 pagewriter 1 357 ? 00:00:00 WALwriteraux 1 358 ? 00:00:00 AVClauncher 1 356 ? 00:00:00 WALwriter 1 359 ? 00:00:00 Jobscheduler 1 360 ? 00:00:00 asyncundolaunch 1 361 ? 00:00:00 globalstats 1 362 ? 00:00:00 applylauncher 1 363 ? 00:00:00 statscollector 1 364 ? 00:00:01 percentworker 1 365 ? 00:00:03 ashworker 1 366 ? 00:00:00 TrackStmtWorker 1 367 ? 00:00:00 auditor 1 368 ? 00:00:00 2pccleaner 1 369 ? 00:00:00 faultmonitor 1 370 ? 00:00:00 WLMworker 1 371 ? 00:00:00 WLMmonitor 1 373 ? 00:00:00 undorecycler 1 372 ? 00:00:00 WLMarbiter
  1. 使用 gs_ctl 工具查看数据库状态,判断数据库是否启动
omm@modb:~$ gs_ctl status [2022-11-28 22:58:01.421][538][][gs_ctl]: gs_ctl status,datadir is /var/lib/opengauss/data gs_ctl: server is running (PID: 1) /usr/local/opengauss/bin/gaussdb
  1. 使用 gs_ctl 查看数据文件的目录
omm@modb:~$ gs_ctl notify [2022-11-28 22:58:11.039][542][][gs_ctl]: gs_ctl notify ,datadir is /var/lib/opengauss/data [2022-11-28 22:58:11.039][542][][gs_ctl]: the parameter of notify must be specified
  1. 从环境变量查看数据文件的目录
omm@modb:~$ cat ~/.bashrc export PATH=$GAUSSHOME/bin:$PATH export LD_LIBRARY_PATH=$GAUSSHOME/lib:$LD_LIBRARY_PATH export PGDATA=/var/lib/opengauss/data ##(部分内容省略)
  1. 在 gsql 中查看数据文件目录、数据库版本
root@modb:~# su - omm omm@modb:~$ gsql -r gsql ((openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:00 commit 0 last mr ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. omm=# show data_directory ; data_directory ------------------------- /var/lib/opengauss/data (1 row) omm=# select version(); version ------------------------------------------------------------------------------------------------------------------------------------------------------- (openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:00 commit 0 last mr on aarch64-unknown-linux-gnu, compiled by g++ (GCC) 7.3.0, 64-bit (1 row) omm=#

总结

本节课程内容不多也比较好上手,在线实验室操作比较快捷,没有遇到什么问题。
对于日常维护操作,option 类的参数使用频率较高,共包含 14 个参数,整理脑图如下,供大家参考。

image.png
更详细内容参考 https://docs.opengauss.org/zh/docs/3.1.0/docs/Toolreference/gs_ctl.html

最后修改时间:2022-11-29 08:31:58
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论