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

openGauss每日一练第 1 天

原创 龙镇君 2022-11-24
186

学习目标:

学习从操作系统层面和使用openGauss工具查看数据库的状态、版本和数据文件目录。

积累:

使用opengauss数据库要习惯使用gs_ctl工具来对数据库状态进行查询和操作。
平时常用的包括
启停数据库 gs_ctl -D $data stop/start/restart
重载配置文件 gs_ctl -D $data reload
查看数据库状态 gs_ctl -D $data status
主备环境的手工切换 gs_ctl switchover/failover -D $data
主备环境重建备实例 gs_ctl build -D $data gs_ctl querybuild
主备环境状态查询 gs_ctl query

注意点

平时比较要注意的是

1、在主备环境下启动数据库使要带-M参数指定启动模式

gs_ctl start -D $data -M primary gs_ctl start -D $data -M standby

今日作业

1.操作系统层面查看数据库进程和线程。如果数据库启动,则有相应的进程和线程。

root@modb:~# ps -ef|grep gauss omm 1 0 0 10:02 ? 00:00:09 gaussdb root 544 539 0 10:36 pts/0 00:00:00 grep gauss root@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 351 ? 00:00:01 pagewriter 1 352 ? 00:00:00 pagewriter 1 353 ? 00:00:00 pagewriter 1 354 ? 00:00:00 pagewriter 1 355 ? 00:00:00 pagewriter 1 356 ? 00:00:00 WALwriter 1 357 ? 00:00:00 WALwriteraux 1 358 ? 00:00:00 AVClauncher 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 372 ? 00:00:00 WLMarbiter 1 373 ? 00:00:00 undorecycler

2.使用gs_ctl工具查看数据库状态,判断数据库是否启动。

omm@modb:~$ gs_ctl status [2022-11-24 10:40:22.170][576][][gs_ctl]: gs_ctl status,datadir is /var/lib/opengauss/data gs_ctl: server is running (PID: 1) /usr/local/opengauss/bin/gaussdb omm@modb:~$ gs_ctl status -D /var/lib/opengauss/data [2022-11-24 10:40:39.812][580][][gs_ctl]: gs_ctl status,datadir is /var/lib/opengauss/data gs_ctl: server is running (PID: 1) /usr/local/opengauss/bin/gaussdb

3.使用gs_ctl 查看数据文件的目录

omm@modb:~$ gs_ctl notify [2022-11-24 10:41:39.634][588][][gs_ctl]: gs_ctl notify ,datadir is /var/lib/opengauss/data [2022-11-24 10:41:39.634][588][][gs_ctl]: the parameter of notify must be specified

4.从环境变量查看数据文件的目录

omm@modb:~$ cat ~/.bashrc|grep -i 'pgdata' export PGDATA=/var/lib/opengauss/data

5.在gsql中查看数据文件目录、数据库版本

omm@modb:~$ gsql -p5432 -d postgres -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. openGauss=# show data_directory ; data_directory ------------------------- /var/lib/opengauss/data (1 row) openGauss=# 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, comp iled by g++ (GCC) 7.3.0, 64-bit (1 row)

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

评论