openGauss数据库状态学习
openGauss数据库状态
·
1.从操作系统层面查看数据库进程和线程,判断数据库是否启动。
[omm@ogdb1 ~]$ ps -ef | grep gauss | grep -v grep
omm 33478 1 5 21:34 ? 00:02:00 /og01/og3.1.0/install/app/bin/gaussdb -D /og01/og3.1.0/install/data/dn01
如能看到gaussdb 进程,说明数据库是启动状态 可以通过 ps -Tp 进程ID 查看其线程
[omm@ogdb1 ~]$ ps -Tp 33478
PID SPID TTY TIME CMD
33478 33478 ? 00:00:01 gaussdb
33478 33479 ? 00:00:00 jemalloc_bg_thd
33478 33485 ? 00:00:00 gaussdb
33478 33486 ? 00:00:00 syslogger
33478 33487 ? 00:00:00 jemalloc_bg_thd
33478 33488 ? 00:00:00 alarm
33478 33489 ? 00:00:00 reaper
33478 33490 ? 00:00:00 jemalloc_bg_thd
33478 33491 ? 00:00:00 jemalloc_bg_thd
33478 33517 ? 00:00:00 checkpointer
33478 33518 ? 00:00:00 Spbgwriter
33478 33519 ? 00:00:00 pagewriter
33478 33520 ? 00:00:00 pagewriter
33478 33521 ? 00:00:06 pagewriter
33478 33522 ? 00:00:00 pagewriter
33478 33523 ? 00:00:00 pagewriter
33478 33524 ? 00:00:00 WALwriter
33478 33525 ? 00:00:00 WALwriteraux
33478 33526 ? 00:00:00 AVClauncher
33478 33527 ? 00:00:00 Jobscheduler
33478 33528 ? 00:00:00 asyncundolaunch
33478 33529 ? 00:00:00 globalstats
33478 33530 ? 00:00:00 applylauncher
33478 33531 ? 00:00:00 statscollector
33478 33532 ? 00:00:00 txnsnapcapturer
33478 33533 ? 00:00:00 CfsShrinker
33478 33534 ? 00:00:04 percentworker
33478 33535 ? 00:01:17 ashworker
33478 33536 ? 00:00:12 TrackStmtWorker
33478 33537 ? 00:00:00 auditor
33478 33538 ? 00:00:00 2pccleaner
33478 33539 ? 00:00:00 faultmonitor
33478 33541 ? 00:00:00 undorecycler
2.使用gs_ctl工具查看数据库状态,判断数据库是否启动。
通过 gs_ctl status命令可查看数据库状态,进程ID等相关信息,显示为running 即为启动状态。
[omm@ogdb1 ~]$ gs_ctl status
[2022-11-24 22:47:48.936][42108][][gs_ctl]: gs_ctl status,datadir is /og01/og3.1.0/install/data/dn01
gs_ctl: server is running (PID: 33478)
/og01/og3.1.0/install/app/bin/gaussdb "-D" "/og01/og3.1.0/install/data/dn01"
3.使用gs_ctl 查看数据文件的目录
通过gs_ctl notify 命令可查看数据文件目录,datadir is 后即是文件目录位置。
[omm@ogdb1 ~]$ gs_ctl notify
[2022-11-24 22:48:50.500][42243][][gs_ctl]: gs_ctl notify ,datadir is /og01/og3.1.0/install/data/dn01
[2022-11-24 22:48:50.500][42243][][gs_ctl]: the parameter of notify must be specified
通过gs_om -t status --detail 命令亦可查看数据文件目录等更多相关信息。
[omm@ogdb1 ~]$ gs_om -t status --detail
[ Cluster State ]
cluster_state : Normal
redistributing : No
current_az : AZ_ALL
[ Datanode State ]
node node_ip port instance state
------------------------------------------------------------------------------------------------
1 ogdb1 10.6.0.104 40000 6001 /og01/og3.1.0/install/data/dn01 P Primary Normal
4.从环境变量查看数据文件的目录
通过 grep -i PGDATA ~/.bash_profile 可查看环境变量对应数据文件目录
[omm@ogdb1 ~]$ grep -i PGDATA ~/.bash_profile
export PGDATA=/og01/og3.1.0/install/data/dn01
以下列出全部环境变量值。
[omm@ogdb1 ~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export GPHOME=/og01/og3.1.0/install/om
export PATH=$GPHOME/script/gspylib/pssh/bin:$GPHOME/script:$PATH
export LD_LIBRARY_PATH=$GPHOME/lib:$LD_LIBRARY_PATH
export PYTHONPATH=$GPHOME/lib
export GAUSSHOME=/og01/og3.1.0/install/app
export PATH=$GAUSSHOME/bin:$PATH
export LD_LIBRARY_PATH=$GAUSSHOME/lib:$LD_LIBRARY_PATH
export S3_CLIENT_CRT_FILE=$GAUSSHOME/lib/client.crt
export GAUSS_VERSION=3.1.0
export PGHOST=/og01/og3.1.0/tmp
export PGDATA=/og01/og3.1.0/install/data/dn01
export GAUSSLOG=/og01/log/omm/omm
umask 077
export GAUSS_ENV=2
export GS_CLUSTER_NAME=dbCluster
5.在gsql中查看数据文件目录、数据库版本
登录数据库,通过 show data_directory; 命令可查看目录数据文件目录。
[omm@ogdb1 ~]$ gsql -r -p 40000
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 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
---------------------------------
/og01/og3.1.0/install/data/dn01
(1 row)
通过 select version();,可查看数据库对应版本。
omm=# select version();
version
-----------------------------------------------------------------------------------------------
(openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr on x86_64-unknown-linux-gnu, compiled by g++ (GCC) 7.3.0, 64-bit
(1 row)
更多推荐
已为社区贡献21条内容
所有评论(0)