惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
Recorded Future
Recorded Future
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
M
MIT News - Artificial intelligence
云风的 BLOG
云风的 BLOG
Y
Y Combinator Blog
N
News | PayPal Newsroom
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Help Net Security
Help Net Security
博客园 - Franky
SecWiki News
SecWiki News
Recent Announcements
Recent Announcements
T
Troy Hunt's Blog
The Register - Security
The Register - Security
The Last Watchdog
The Last Watchdog
Webroot Blog
Webroot Blog
S
Security Affairs
博客园 - 司徒正美
S
Schneier on Security
I
InfoQ
博客园_首页
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Threat Research - Cisco Blogs
Forbes - Security
Forbes - Security
腾讯CDC
N
Netflix TechBlog - Medium
N
News and Events Feed by Topic
Cloudbric
Cloudbric
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
A
About on SuperTechFans
Engineering at Meta
Engineering at Meta
Recent Commits to openclaw:main
Recent Commits to openclaw:main
B
Blog
V
Vulnerabilities – Threatpost
C
Check Point Blog
Google DeepMind News
Google DeepMind News
Google Online Security Blog
Google Online Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cisco Blogs
Schneier on Security
Schneier on Security
O
OpenAI News
K
Kaspersky official blog

博客园 - MSSQL123

PostgreSQL 18 新特性 skip scan,一个鸡肋的功能 PostgreSQL 17 流复制中开启逻辑复制槽同步,以及逻辑槽的故障转移 记一次PostgreSQL交叉表crosstab行转列导致的OOM TiDB 扩容与缩容 PostgreSQL 高可用集群 patroni 自动故障转移测试 Ubuntu 20 环境下 patroni 自动化安装,一分钟快速搭建 patroni 集群 Ubuntu 20 环境下 pg_auto_failover 自动化安装,一分钟快速搭建pg_auto_failover集群 PostgreSQL的消息队列扩展pgmq 磁盘IO延迟和队列深度的关系 TiDB 最小拓扑架构集群安装 PostgreSQL 逻辑复制中的同步和异步模式以及其表现 prometheus 的 altermanager Silences静默告警,优雅地抑制告警 “世界上百分之99的博士和他们的论文都是垃圾”,原本以为这个观点偏激 pg_auto_failover 在多种场景下自动故障转移的验证 pgbouncer连接池设置与压力测试的最大连接数测试 pg_auto_failover 自动故障转移参数 博文阅读密码验证 - 博客园 pg_auto_failover 高可用中,PostgreSQL实例配置文件的加载步骤 pg_auto_failover集群monitor节点的高可用 prometheus监控Linux Server node_exporter代理安装和配置 prometheus监控windows window_exporter代理安装和配置 Prometheus 和 Grafana 监控 PostgreSQL 记一次MySQL binlog日志导致磁盘空间占满的问题 SQLServer 2019 标准版在虚拟机上无法充分利用CPU的问题诊断 Windows Failover Cluster集群中的EventId 1196错误日志 SqlServer 事务复制(transaction replication)的复制位点信息 SqlServer 事务复制的两个参数immediate_sync,allow_anonymous MySQL,SqlServer,PostgreSQL中,如何实现锁定一张表 PostgreSQL pg_auto_failover 高可用 2:pg_auto_failover集群运维 PostgreSQL pg_auto_failover 高可用 1:pg_auto_failover集群搭建 PostgreSQL patroni 高可用 4:HAProxy和Keepalived实现读写分离 PostgreSQL patroni 高可用 3:patroni 运维
pg_auto_failover 环境变量导致的show命令错误
MSSQL123 · 2025-11-07 · via 博客园 - MSSQL123

今天遇到一个看似奇怪的问题,经过反复的重启,甚至重启操作系统,重装pg_auto_failover,都没有解决,冷静下来思考之后,才发现是环境变量导致的,有必要记录一下

环境

一个ubuntu的pg_auto_failover monitor节点,通过源码编译安装的,monitor节点的实例是自定义端口号,monitor 节点初始化命令如下
pg_autoctl create monitor --pgdata /usr/local/pgsql16/pg9300/data/ --auth trust --ssl-self-signed --hostname ubuntu16 --pgport 9300

异常

之后启动pgautofailover服务,一切正常,但是当执行pg_autoctl show uri的时候,发现不对劲了,提示错误说:
Failed to connect to "postgres://autoctl_node@ubuntu03:5432/pg_auto_failover?sslmode=require", retrying until the server is ready
乖乖,我可是明确地定义的--pgport 9300端口号啊,autoctl为什么去找ubuntu03:5432???

这台虚拟机是通过克隆而来的,已经克隆N多层了,不知道源头的系统究竟是哪个,但是修改了hosts文件等,已经完全重命名了,当前主机名为ubuntu16,为什么pg_autoctl show uri会找ubuntu03:5432?
经过反复检查/etc/hosts,/etc/hostname等,都没有问题,都是新的主机名ubuntu16。
经过重启,重装pg_auto_failover服务等等都没有解决。


冷静下来思考了一下,这里报错,既然pg_autoctl 找的是5432端口的实例,5432是默认的实例端口号,那么极有可能是找不到当前实例,问题就出在配置上。
后面检查了一下/etc/profile,果然有问题,原来PGDATA=/usr/local/pgsql16/pg9000/data/是一个不存在的路径,
可以推断出来,当环境变量的PGDATA不存在的时候,会找默认的环境变量,难怪是5432端口号,随后将这个环境变量修改成pgautofailover的monitor节点的数据路径之后,问题解决。

export LANG=en_US.utf8
export PGDATA=/usr/local/pgsql16/pg9000/data/--问题就出在这里,这是克隆的原始的机器上的配置,当前monitor节点的数据目录是/usr/local/pgsql16/pg9300/data/
export PGHOME=/usr/local/pgsql16/server
export PATH=/usr/local/pgsql16/server/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/pgsql16/server/lib

image

但还是有一个问题,始终不知道默认寻找的主机名从哪里来?