连接数据库的客户端工具包括 gsql、Data Studio、应用程序接口(如 ODBC 和 JDBC)和
psql。
gsql 是 GaussDB 200 自带的客户端工具。使用 gsql 连接数据库,可以交互式地
输入、编辑、执行 SQL 语句。
Data Studio 是一款 GUI 工具,使用 Data Studio 连接数据库,可以调试、执行
SQL 语句和存储过程。
用户可以使用标准的数据库应用程序接口(如 ODBC 和 JDBC),开发基于
GaussDB 200 的应用程序。
psql 是开源客户端工具。使用 psql 连接数据库,可以交互式地输入、编辑、执
行 SQL 语句。
确认连接信息
客户端工具通过 CN 连接数据库。因此连接前,需获取 CN 所在服务器的 IP 地址及 CN 的
端口号信息。客户端工具可以通过任何一个 CN 连接数据库。
操作步骤
步骤 1 以操作系统用户 omm 登录 GaussDB 200 集群任一主机。执行 source $
{BIGDATA_HOME}/mppdb/.mppdbgs_profile 命令启动环境变量。
步骤 2 使用“gs_om -t status –detail”命令查询集群各实例情况。
gs_om -t status --detail
[ Coordinator State ]
node node_ip instance state
-----------------------------------------------------------------------------
1 plat1 192.168.0.11 5001 /srv/BigData/mppdb/data1/coordinator Normal
2 plat2 192.168.0.12 5002 /srv/BigData/mppdb/data1/coordinator Normal
3 plat3 192.168.0.13 5003 /srv/BigData/mppdb/data1/coordinator Normal
如上部署了 CN 实例的服务器 IP 地址分别为 192.168.10.11、192.168.10.12 和
192.168.0.13。CN 数据路径为“/srv/BigData/mppdb/data1/coordinator”。
步骤 3 确认 CN 的端口号。
在 步骤 2 查到的 CN 数据路径下的 postgresql.conf 文件中查看端口号信息。示例如下:
cat /srv/BigData/mppdb/data1/coordinator/postgresql.conf | grep port
port = 25308 # (change requires restart)
#comm_sctp_port = 1024 # Assigned by installation (change requires restart)
#comm_control_port = 10001 # Assigned by installation (change requires restart)
# supported by the operating system:
# e.g. 'localhost=10.145.130.2 localport=12211 remotehost=10.145.130.3 remoteport=12212,
localhost=10.145.133.2 localport=12213 remotehost=10.145.133.3 remoteport=12214'
# e.g. 'localhost=10.145.130.2 localport=12311 remotehost=10.145.130.4 remoteport=12312,
localhost=10.145.133.2 localport=12313 remotehost=10.145.133.4 remoteport=12314'
# %r = remote host and port
alarm_report_interval = 10
gtm_port = 6000 # Port of GTM
gtm_port1 = 6500 # Port1 of GTM
pooler_port = 8001
support_extended_features=true
25308 为 CN 的端口号。