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

磐维数据库修改监听端口测试

Z·A·Q 2024-11-29
267

测试环境信息

  • 单节点
  • 磐维版本:PanWeiDB_V2.0-S3.0.1_B01

测试步骤

  • 1)停止数据库
[omm@pwdb2 ~]$ gs_om -t stop
Stopping cluster.
=========================================
Successfully stopped cluster.
=========================================
End stop cluster.
  • 2)修改参数
[omm@pwdb2 ~]$ gs_guc set -I all -N all -c "port=17800"
The pw_guc run with the following arguments: [gs_guc -I all -N all -c port=17800 set ].
Begin to perform the total nodes: 1.
Popen count is 1, Popen success count is 1, Popen failure count is 0.
Begin to perform gs_guc for datanodes.
Command count is 1, Command success count is 1, Command failure count is 0.

Total instances: 1. Failed instances: 0.
ALL: Success to perform gs_guc!
  • 3)启动数据库
[omm@pwdb2 ~]$ gs_om -t start
Starting cluster.
=========================================
[SUCCESS] pwdb2
2024-11-27 18:37:46.411 6746ef72.1 [unknown] 47706941952960 [unknown] 0 dn_6001 01000  0 [BACKEND] WARNING:  Error happen when loading license, error code: 2, error message: cannot write data to dir /etc/panweidb/license
2024-11-27 18:37:46.424 6746ef72.1 [unknown] 47706941952960 [unknown] 0 dn_6001 01000  0 [BACKEND] WARNING:  could not create any HA TCP/IP sockets
2024-11-27 18:37:46.424 6746ef72.1 [unknown] 47706941952960 [unknown] 0 dn_6001 01000  0 [BACKEND] WARNING:  could not create any HA TCP/IP sockets-  
=========================================
Successfully started.
  • 4)修改环境变量
[omm@pwdb2 ~]$ vim .panweidb_env 
export PGPORT=17800
[omm@pwdb2 ~]$ source .panweidb_env 
  • 5)登录验证修改
[omm@pwdb2 ~]$ gsql -r
gsql ((PanWeiDB_V2.0-S3.0.1_B01) compiled at 2024-09-29 19:37:43 commit d086caf )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

postgres=# show port;
 port  
-------
 17800
(1 row)
  • 6)查看静态配置文件,可以发现端口信息未同步
[omm@pwdb2 ~]$ gs_om -t view
NodeHeader:
version:301
time:1732700238
nodeCount:1
node:1
============================================================
azName:AZ1
azPriority:1
node :1
nodeName:pwdb2
ssh channel :
sshChannel 1:192.168.1.22
datanodeCount :1
datanodeInstanceType :primary
datanode 1:
datanodeLocalDataPath :/database/panweidb/data
datanodeXlogPath :
datanodeListenIP 1:192.168.1.22
datanodePort :17700
datanodeLocalHAIP 1:192.168.1.22
datanodeLocalHAPort :17700
dn_replication_num: 1
============================================================
  • 7)修改静态配置文件
[omm@pwdb2 ~]$ gs_om -t generateconf --old-values=17700,192.168.1.22 --new-values=17800,192.168.1.22 --distribute
Generating static configuration files for all nodes.
Creating temp directory to store static configuration files.
Successfully created the temp directory.
Generating static configuration files.
Successfully generated static configuration files.
Static configuration files for all nodes are saved in /database/panweidb/tool/script/static_config_files.
Distributing static configuration files to all nodes.
Successfully distributed static configuration files.
  • 8)查看集群状态,端口信息已更新
[omm@pwdb2 ~]$ gs_om -t view
NodeHeader:
version:301
time:1732718076
nodeCount:1
node:1
============================================================
azName:AZ1
azPriority:1
node :1
nodeName:pwdb2
ssh channel :
sshChannel 1:192.168.1.22
datanodeCount :1
datanodeInstanceType :primary
datanode 1:
datanodeLocalDataPath :/database/panweidb/data
datanodeXlogPath :
datanodeListenIP 1:192.168.1.22
datanodePort :17800
datanodeLocalHAIP 1:192.168.1.22
datanodeLocalHAPort :17800
dn_replication_num: 1
============================================================
[omm@pwdb2 ~]$ gs_om -t query
[   Cluster State   ]

cluster_state   : Normal
redistributing  : No
current_az      : AZ_ALL

[  Datanode State   ]

    node node_ip         port      instance     state
---------------------------------------------------------------------
1  pwdb2 192.168.1.22    17800      6001       P Primary Normal

port参数介绍

  • 参数说明:PanWeiDB 服务侦听的 TCP 端口号,该参数属于 POSTMASTER 类型参数。
  • 该参数由安装时的配置文件指定,请勿轻易修改,否则修改后会影响数据库正常通信。取值范围:整型,1~65535
  • 注意事项:
    • 设置端口号时,请设置一个未被占用的端口号。设置多个实例的端口号,不可冲突。
    • 1~1023 为操作系统保留端口号,请不要使用。
    • 通过配置文件安装数据库实例时,配置文件中的端口号需要注意通信矩阵预留端口。如:DN 还需保留 dataPortBase+1 作为内部工具使用端口,保留 dataPortBase+6 作为流引擎消息队列通信端口等。故数据库实例安装阶段,port 最大值为:DN 可设置 65529,同时需要保证端口号不冲突。
    • 通过 gs_guc set 的方式修改了 port 值之后,需要手动修改下静态配置文件 static_config_files 里面的端口信息后,才可以生效。
  • 查看当前主机的端口信息
[root@pwdb2 ~]# netstat -anp|grep 1780
tcp        0      0 192.168.1.22:17800      0.0.0.0:*               LISTEN      9341/panweidb       
tcp        0      0 127.0.0.1:17800         0.0.0.0:*               LISTEN      9341/panweidb       
tcp        0      0 192.168.1.22:17801      0.0.0.0:*               LISTEN      9341/panweidb       
tcp        0      0 127.0.0.1:17801         0.0.0.0:*               LISTEN      9341/panweidb       
tcp6       0      0 ::1:17800               :::*                    LISTEN      9341/panweidb       
tcp6       0      0 ::1:17801               :::*                    LISTEN      9341/panweidb       
unix  2      [ ACC ]     STREAM     LISTENING     2026443  9341/panweidb        /database/panweidb/tmp/.s.PGSQL.17801
unix  2      [ ACC ]     STREAM     LISTENING     2026442  9341/panweidb        /database/panweidb/tmp/.s.PGSQL.17800
[root@pwdb2 ~]# ps -ef|grep 9341|grep -v grep
omm        9341      1  4 22:32 ?        00:00:08 /database/panweidb/app/bin/panweidb -D /database/panweidb/data
  • 使用17801端口也可连接数据库
[omm@pwdb2 ~]$ gsql -p 17801 -d postgres
gsql ((PanWeiDB_V2.0-S3.0.1_B01) compiled at 2024-09-29 19:37:43 commit d086caf )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

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

评论