2026/2/17 2:33:42
网站建设
项目流程
wordpress后台加站点图标,wordpress邮件验证码,wordpress th7好卡,河南省建设厅村镇建设处网站我们的文章会在微信公众号IT民工的龙马人生和博客网站 ( www.htz.pw )同步更新 #xff0c;欢迎关注收藏#xff0c;也欢迎大家转载#xff0c;但是请在文章开始地方标注文章出处#xff0c;谢谢#xff01; 由于博客中有大量代码#xff0c;通过页面浏览效果更佳。 需求…我们的文章会在微信公众号IT民工的龙马人生和博客网站 ( www.htz.pw )同步更新 欢迎关注收藏也欢迎大家转载但是请在文章开始地方标注文章出处谢谢由于博客中有大量代码通过页面浏览效果更佳。需求说明来自一次跟朋友的聊天提到YashanDB的OM管理组件是否可以改端口号。这是一个很新颖的问题也觉得很有意思。在过去的运维和测试过程中常做的修改都是修改IP地址或者数据库的监听端口还很少去思考管理端口的修改。怀着对这个问题的好奇决定研究一下如何修改。YashanDB在部署过程中具备自定义端口的功能所以可以推断安装完成后也可以自定义修改端口。连上VPN开始搜索相关资料结果没有搜到类似的需求和操作文档。既然没有现成的又到晚上12点了不打扰研发同事就只能自己研究一下。下面分享一下自己研究的过程和汇总的内容。本文档只限于技术测试请勿用于生产环境和业务测试环境。如生产环境有类似的需求请直接联系YashanDB。测试环境介绍测试环境采用主从架构数据库版本为23.4.6.100操作系统为麒麟V10数据库运行状态如下[yashankylin01 .yasboot]$ yasboot cluster status -c yashandb -d ------------------------------------------------------------------------------------------------------------------------------------------------------------- | hostid | node_type | nodeid | pid | instance_status | database_status | database_role | listen_address | source_node | data_path | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | host0001 | db | 1-1:1 | 1572 | open | normal | primary | 10.10.10.125:1688 | - | /data/yashan/yasdb_data/db-1-1 | ---------------------------------------------------------------------------------------------------------------------------------------------------- | host0002 | db | 1-2:2 | 1697 | open | normal | standby | 10.10.10.126:1688 | 1-1:1 | /data/yashan/yasdb_data/db-1-2 | ----------------------------------------------------------------------------------------------------------------------------------------------------修改OM端口下面将研究后修改OM端口的操作命令汇总如下需要在主从的所有节点上执行[yashankylin01 .yasboot]$ sed -i s/1675/3675/ /data/yashan/yasdb_home/23.4.6.100/om/yashandb/conf/yasom.toml [yashankylin01 .yasboot]$ sed -i s/1675/3675/ /home/yashan/.yasboot/yashandb.env [yashankylin01 .yasboot]$ ps -ef|grep -E yasom|yasagent|grep -v grep|awk {print $2}|xargs kill -9测试过程下面的测试基于猜想进行的验证过程。寻找配置文件YashanDB管理组件在安装过程中支持自定义端口并且是提前编译好的Go语言二进制文件。因此自定义的端口号可能是写入配置文件中而非写入静态的二进制文件中。[rootkylin01 om]# find /data/yashan/ -type f |grep -Ei conf|toml|xargs -i grep -E 10.10 {} ARCHIVE_DEST_1SERVICE10.10.10.126:1689 NODE_ID1-2:2 LISTEN_ADDR10.10.10.125:1688 REPLICATION_ADDR10.10.10.125:1689 ListenAddr 10.10.10.125:1676 listen_addr 10.10.10.125:167510.10.10.125:1675 就是当前OM的IP地址和端口号。查询yasboot日志OM可以通过yasboot来启动这说明yasboot执行的命令肯定包含对应的IP地址和端口号信息。相关日志如下2026-01-16 23:57:52 DEBUG [yasboot] exec.go:63 exec: bash -c ps auxww | grep -w /data/yashan/yasdb_home/23.4.6.100/bin/yasom | grep -v -w grep | awk {print$2} starting 2026-01-16 23:57:52 DEBUG [yasboot] exec.go:63 exec: bash -c export YASDB_OM_ADDR10.10.10.125:1675; /data/yashan/yasdb_home/23.4.6.100/bin/yasom -c yashandb -l 10.10.10.125:1675 -d starting 2026-01-16 23:57:53 DEBUG [monit] exec.go:63 exec: bash -c /data/yashan/yasdb_home/23.4.6.100/om/bin/monit -c /data/yashan/yasdb_home/23.4.6.100/om/monit/monitrc monitor yasom starting可以找到下面这行记录表明YashanDB启动时执行的命令。在执行命令前设置了环境变量YASDB_OM_ADDR10.10.10.125:1675。bash -c export YASDB_OM_ADDR10.10.10.125:1675; /data/yashan/yasdb_home/23.4.6.100/bin/yasom -c yashandb -l 10.10.10.125:1675 -d starting跟踪Yasboot获取值的途径通过操作系统strace命令可以跟踪到yasboot执行过程中打开的文件信息newfstatat(AT_FDCWD, /home/yashan/.yasboot/yashandb.env, {st_modeS_IFREG|0664, st_size184, ...}, AT_SYMLINK_NOFOLLOW) 0 openat(AT_FDCWD, /home/yashan/.yasboot/yashandb.env, O_RDONLY|O_CLOEXEC) 3 fcntl(3, F_GETFL) 0x8000 (flags O_RDONLY|O_LARGEFILE) fcntl(3, F_SETFL, O_RDONLY|O_NONBLOCK|O_LARGEFILE) 0 epoll_ctl(4, EPOLL_CTL_ADD, 3, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32377487362, u649181517284579999746}}) -1 EPERM (Operation not permitted) fcntl(3, F_GETFL) 0x8800 (flags O_RDONLY|O_NONBLOCK|O_LARGEFILE) fcntl(3, F_SETFL, O_RDONLY|O_LARGEFILE) 0 read(3, cluster\yashandb\\nom_addr\10.1..., 512) 184 read(3, , 328) 0 close(3) 0 newfstatat(AT_FDCWD, /data/yashan/yasdb_home/23.4.6.100/om/yashandb/conf/yasom.toml, {st_modeS_IFREG|0600, st_size615, ...}, AT_SYMLINK_NOFOLLOW) 0 newfstatat(AT_FDCWD, /home/yashan/.yasboot/yashandb_yasdb_home/bin/bash, 0xc0004b3628, 0) -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, /usr/local/bin/bash, 0xc0004b36f8, 0) -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, /usr/bin/bash, {st_modeS_IFREG|0755, st_size1166952, ...}, 0) 0 syscall_0x1b7(0xffffffffffffff9c, 0xc0003341d0, 0x1, 0x200, 0, 0) -1 ENOSYS (Function not implemented) newfstatat(AT_FDCWD, /usr/bin/bash, {st_modeS_IFREG|0755, st_size1166952, ...}, 0) 0通过newfstatat打开了yashandb.env文件同时通过read读取了文件中的cluster和om_addr的值。查询yashandb.env的值env文件中保存了环境变量yasboot通过这个配置文件来获取OM的信息。[yashankylin01 .yasboot]$ cat yashandb.env clusteryashandb om_addr10.10.10.125:3675 version23.4.6.100 same_versionfalse base_path/data/yashan/yasdb_home/23.4.6.100 max_ac_sql_size209715200 max_ac_sql_rows1000000yasom.toml文件内容listen_addr参数记录了OM的配置信息可以推断OM在启动时会自动读取这个文件的配置信息。[yashankylin01 ~]$ vi /data/yashan/yasdb_home/23.4.6.100/om/yashandb/conf/yasom.toml listen_addr 10.10.10.125:1675 pprof_addr 0.0.0.0:7890 sync_interval 5 sync_mode async sync_retry_time 3 mode Release [db] driver sqlite3 url /data/yashan/yasdb_home/23.4.6.100/om/yashandb/data/cod_domor.db?cachesharedmoderwc max_open_conns 1 auto_migrate true [log] level 0 max_age 7 max_size 104857600 max_backups 30 path /data/yashan/log/om/yashandb log_path /data/yashan/log/om/yashandb/yasom.log err_log_path /data/yashan/log/om/yashandb/yasom-panic.log start_log /data/yashan/log/om/yashandb/yasom-start.log console truesqlite3的内容通过sqlite3的dump命令可以发现数据库中还写入了om_addr的信息。[yashankylin01 ~]$ cat /tmp/cod_domor.txt |grep 1675 INSERT INTO kv_config VALUES(om_addr,10.10.10.125:1675,4,2026-01-16 23:39:20.60364739608:00,2026-01-16 23:39:20.60364739608:00,NULL);验证env与yasom.toml哪个生效前面提到env文件很可能是给yasboot使用的yasom.toml里面才是真正的OM监听参数的配置文件。因此这里简单测试一下env与yasom.toml配置不同的端口号时哪个会生效。修改env端口在所有的节点上执行下面命令sed -i s/3675/1675/ /home/yashan/.yasboot/yashandb.env ps -ef|grep -E yasom|yasagent|grep -v grep|awk {print $2}|xargs kill -9查询进程监控进程会自动启动服务。yasom进程启动时有一个-l参数指定了10.10.10.125和1675。[yashankylin01 ~]$ ps -ef|grep yasom yashan 11765 1 0 11:47 ? 00:00:00 /data/yashan/yasdb_home/23.4.6.100/bin/yasom -c yashandb -l 10.10.10.125:1675 -d确认端口确认yasom进程占用的端口号。这里可以看到端口号是3675而不是1675。[rootkylin01 ~]# netstat -anp|grep 11765 tcp 0 0 10.10.10.125:3675 0.0.0.0:* LISTEN 11765/yasom参数-l指定的IP地址和端口号看起来没有生效而是直接读取yasom.toml中的配置文件。查看YASOM参数在-h帮助信息中可以看到-l参数表示OM监听的IP地址和端口号。但从实际测试结果可以推断出-l参数在监听端口配置上没有生效不确定是否有其他作用。[yashankylin01 ~]$ yasom -h Usages: yasom [flags] command yasom daemon process, version: Release 23.4.6.100 Flags: -h,--help Show detailed help information. --init start process with initialization -c,--cluster run with cluster -l,--listen listen on address -k,--secret-key listen rpc secret key -d,--daemon start process in daemon --secondary start yasom as secondary mode -L,--log-path log path --web start om with web mode Commands: completion generate completion scription Run yasom COMMAND --help for more information on a command.查看集群状态这里可以看到端口1675无法访问[yashankylin01 ~]$ yasboot cluster status -c yashandb dial tcp 10.10.10.125:1675: connect: connection refusedyasboot的日志如下2026-01-17 11:50:12 DEBUG [yasboot] rpcclient.go:102 yashandb connecting om: 10.10.10.125:1675 2026-01-17 11:50:12 ERROR [yasboot] client.go:233 failed to dial server: dial tcp 10.10.10.125:1675: connect: connection refused这个ERROR级别的日志信息简洁而精确。结论OM监听端口的修改直接修改yasom.toml文件即可。验证功能通过上面的修改简单验证yasboot对集群的操作功能是否正常[yashankylin01 .yasboot]$ yasboot cluster status -c yashandb -d ------------------------------------------------------------------------------------------------------------------------------------------------------------- | hostid | node_type | nodeid | pid | instance_status | database_status | database_role | listen_address | source_node | data_path | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | host0001 | db | 1-1:1 | 1572 | open | normal | primary | 10.10.10.125:1688 | - | /data/yashan/yasdb_data/db-1-1 | ---------------------------------------------------------------------------------------------------------------------------------------------------- | host0002 | db | 1-2:2 | 1697 | open | normal | standby | 10.10.10.126:1688 | 1-1:1 | /data/yashan/yasdb_data/db-1-2 | ---------------------------------------------------------------------------------------------------------------------------------------------------- [yashankylin01 .yasboot]$ yasboot cluster stop -c yashandb ---------------------------------------------------------------------------------------------------------- | type | uuid | name | hostid | index | status | return_code | progress | cost | ---------------------------------------------------------------------------------------------------------- | task | 64896ec574dd1cb0 | StopYasdbCluster | - | yashandb | SUCCESS | 0 | 100 | 6 | -------------------------------------------------------------------------------------------------- task completed, status: SUCCESS [yashankylin01 .yasboot]$ yasboot cluster start -c yashandb ----------------------------------------------------------------------------------------------------------- | type | uuid | name | hostid | index | status | return_code | progress | cost | ----------------------------------------------------------------------------------------------------------- | task | 338cc4218c196c97 | StartYasdbCluster | - | yashandb | SUCCESS | 0 | 100 | 4 | --------------------------------------------------------------------------------------------------- task completed, status: SUCCESS/------------------作者介绍----------------------姓名黄廷忠个人博客: (http://www.htz.pw)CSDN地址: (https://blog.csdn.net/wwwhtzpw)博客园地址: (https://www.cnblogs.com/www-htz-pw)------------------------------------------------/