openGauss进程状态还能这么看,长见识了!果断收藏备用!

通过ps命令查询gaussdb关键字

shell 复制代码
ps ux | grep gaussdb

如上图所示,如果出现omm 19735 1.1 0.5 6138928 671040 ? Ssl 03:52 11:52 /mnt/openGauss/bin/gaussdb -D /mnt/openGauss/data/single_node这条信息就表示openGauss进程是正常的,当时这条信息在不同机器和重启后都是有变化的。

通过telnet命令连接端口号

shell 复制代码
telnet localhost 5432

如上所示,连接输出下面的信息表示openGauss进程是正常的。

shell 复制代码
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

通过gs_ctl命令查看

shell 复制代码
gs_ctl status -D /mnt/openGauss/data/single_node

如上图所示,输出下面的信息表示openGauss进程是正常的。

shell 复制代码
gs_ctl: server is running (PID: 19735)
/mnt/openGauss/bin/gaussdb "-D" "/mnt/openGauss/data/single_node"

通过系统服务方式查看

这种方式有个前天就是你已经配置了服务自启,这里默认你已经正确配置了系统服务。此时你可以使用下面的命令查看。

shell 复制代码
systemctl status openGauss.service

如上图所示,输出了如下信息并且状态是active(running)表示openGauss服务是正常的。

shell 复制代码
● openGauss.service - 華為openGauss數據庫服務...
   Loaded: loaded (/etc/systemd/system/openGauss.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2024-08-27 03:52:22 EDT; 17h ago
  Process: 19730 ExecStop=/usr/local/bin/gs_ctl stop -D /mnt/openGauss/data/single_node (code=exited, status=0/SUCCESS)
  Process: 19732 ExecStart=/usr/local/bin/gs_ctl start -D /mnt/openGauss/data/single_node (code=exited, status=0/SUCCESS)
 Main PID: 19735 (gaussdb)
    Tasks: 36 (limit: 829805)
   Memory: 677.0M
   CGroup: /system.slice/openGauss.service
           └─19735 /mnt/openGauss/bin/gaussdb -D /mnt/openGauss/data/single_node

通过gs_ctl query命令查看

使用方式如下:

shell 复制代码
gs_ctl query -D /mnt/openGauss/data/single_node

如上图所示,输出如下信息表示openGauss进程正常。

shell 复制代码
HA state:           
        local_role                     : Normal
        static_connections             : 0
        db_state                       : Normal
        detail_information             : Normal

 Senders info:       
No information 
 Receiver info:      
No information

通过gsql命令直接登录

gsql是openGauss自带的命令工具。

shell 复制代码
gsql -d postgres -p 5432 -r

如上图所示,表示成功登录到openGauss数据库终端了。
gsql是一个非常重要的命令工具,下面附上具体使用方式。

shell 复制代码
gsql is the openGauss interactive terminal.

Usage:
  gsql [OPTION]... [DBNAME [USERNAME]]

General options:
  -c, --command=COMMAND    run only single command (SQL or internal) and exit
  -d, --dbname=DBNAME      database name to connect to (default: "omm")
  -f, --file=FILENAME      execute commands from file, then exit
  -l, --list               list available databases, then exit
  -v, --set=, --variable=NAME=VALUE
                           set gsql variable NAME to VALUE
  -V, --version            output version information, then exit
  -X, --no-gsqlrc          do not read startup file (~/.gsqlrc)
  -1 ("one"), --single-transaction
                           execute command file as a single transaction
  -?, --help               show this help, then exit

Input and output options:
  -a, --echo-all           echo all input from script
  -e, --echo-queries       echo commands sent to server
  -E, --echo-hidden        display queries that internal commands generate
  -k, --with-key=KEY       the key for decrypting the encrypted file
  -L, --log-file=FILENAME  send session log to file
  -m, --maintenance        can connect to cluster during 2-pc transaction recovery
  -n, --no-libedit        disable enhanced command line editing (libedit)
  -o, --output=FILENAME    send query results to file (or |pipe)
  -q, --quiet              run quietly (no messages, only query output)
  -C, --enable-client-encryption              enable client encryption feature
  -s, --single-step        single-step mode (confirm each query)
  -S, --single-line        single-line mode (end of line terminates SQL command)

Output format options:
  -A, --no-align           unaligned table output mode
  -F, --field-separator=STRING
                           set field separator (default: "|")
  -H, --html               HTML table output mode
  -P, --pset=VAR[=ARG]     set printing option VAR to ARG (see \pset command)
  -R, --record-separator=STRING
                           set record separator (default: newline)
  -r                       if this parameter is set,use libedit 
  -t, --tuples-only        print rows only
  -T, --table-attr=TEXT    set HTML table tag attributes (e.g., width, border)
  -x, --expanded           turn on expanded table output
  -z, --field-separator-zero
                           set field separator to zero byte
  -0, --record-separator-zero
                           set record separator to zero byte
  -2, --pipeline           use pipeline to pass the password, forbidden to use in terminal
                           must use with -c or -f

Connection options:
  -h, --host=HOSTNAME      database server host or socket directory (default: "local socket")
                           allow multi host IP address with comma separator in centralized cluster
  -p, --port=PORT          database server port (default: "5432")
  -U, --username=USERNAME  database user name (default: "omm")
  -W, --password=PASSWORD  the password of specified database user

For more information, type "\?" (for internal commands) or "\help" (for SQL
commands) from within gsql, or consult the gsql section in the openGauss documentation.


相关推荐
极客先躯27 分钟前
高级java每日一道面试题-2025年4月13日-微服务篇[Nacos篇]-Nacos如何处理网络分区情况下的服务可用性问题?
java·服务器·网络·微服务·nacos·高级面试
Paraverse_徐志斌1 小时前
MySQL 线上大表 DDL 如何避免锁表(pt-online-schema-change)
数据库·mysql·ddl·mysql锁·锁表·pt-osc
哈哈幸运2 小时前
MySQL运维三部曲初级篇:从零开始打造稳定高效的数据库环境
linux·运维·数据库·mysql·性能优化
soulermax2 小时前
数字ic后端设计从入门到精通2(含fusion compiler, tcl教学)
java·linux·服务器
黑心老人2 小时前
Mac OS系统下kernel_task占用大量CPU资源导致系统卡顿
linux·运维·服务器·macos
愚公搬代码2 小时前
【愚公系列】《Python网络爬虫从入门到精通》055-Scrapy_Redis分布式爬虫(安装Redis数据库)
数据库·爬虫·python
Thomas_YXQ2 小时前
Unity3D ILRuntime与Scripting Backend整合指南
服务器·开发语言·unity·unity3d
pwzs2 小时前
深入浅出 MVCC:MySQL 并发背后的多版本世界
数据库·后端·mysql
光算科技2 小时前
服务器在国外国内用户访问慢会影响谷歌排名吗?
运维·服务器·c++
Zenexus2 小时前
Linux学习笔记协议篇(六):SPI FLASH设备驱动
linux·笔记·arm