这是本节的多页打印视图。 .
模块:ETCD
ETCD 是一个分布式的、可靠的键-值存储,用于存放系统中最为关键的数据。 配置 | 管理 | 剧本 | 监控 | 参数
Pigsty 使用 etcd 作为 DCS:分布式配置存储(或称为分布式共识服务)。这对于 PostgreSQL 的高可用性与自动故障转移至关重要。
在安装任何 PGSQL 模块之前,你必须先安装 ETCD 模块,因为 patroni 和 vip-manager 会依赖 etcd 模块,除非你决定使用外部的现有 etcd 集群。
在安装 ETCD 模块前,你无需安装 NODE 模块,但应当确保本地 CA 是可用的(INFRA.CA):因为 etcd 需要可信任的 CA 才能签发证书。
配置
在执行实际部署之前,你必须先定义一个 etcd 集群。关于 etcd 的一些参数。
建议在正式的生产环境使用至少三节点,这样可以容忍一个实例失效
单节点
在配置清单中定义一个 etcd 组,它将创建一个单例 etcd 实例。
对于开发、测试和演示,一个实例足够了,但在正式的生产环境中最好不要这样做。
三节点
你可以在多个节点上部署 etcd 集群,避免单点失效。
五节点或更多实例的配置依此类推,请使用奇数个实例数量,避免出现裁决失效的情况。
管理
以下是一些 etcd 管理的常见任务说明,更多问题请参考 FAQ:ETCD。
- 创建集群:如何初始化 etcd 集群?
- 销毁集群:如何销毁 etcd 集群?
- 环境变量:如何配置 etcd 客户端,以访问 etcd 服务器集群?
- 重载配置:如何更新客户端使用的 etcd 服务器成员列表?
- 添加成员:如何向现有 etcd 集群添加新成员?
- 移除成员:如何从 etcd 集群移除老成员?
创建集群
要创建一个集群,在配置清单中定义好后,执行 etcd.yml 剧本即可。
注意,Pigsty 的 etcd 模块提供了防误删保护机制。在默认配置下, etcd_clean 配置打开,且 etcd_safeguard 配置关闭,
那么执行此剧本的过程中即使遇到存活的etcd实例,也会强制移除,在这种情况下 etcd.yml 剧本是真正幂等的。这种配置对于开发,测试,以及生产环境紧急强制重建 etcd 集群来说是有用的。
对于生产环境已经初始化好的 etcd 集群,可以打开防误删保护,避免误删现有的 etcd 实例。此时当剧本检测到存活 etcd 实例时会主动中止,避免误删现有 etcd 实例,您可以使用命令行参数来覆盖这一行为。
销毁集群
要销毁一个 etcd 集群,只需使用 etcd.yml 剧本的 etcd_clean 子任务即可。执行此命令前请务必三思!
使用 etcd_clean 子任务会尊重 etcd_safeguard 防误删保险的配置,使用 etcd_purge 子任务则会无视一切清理现有 etcd 集群。
环境变量
Pigsty 默认使用 etcd v3 API,以下是etcd客户端配置环境变量的示例。
配置好客户端环境变量后,你可以使用以下命令进行 etcd CRUD 操作:
重载配置
如果 etcd 集群的成员发生变化,我们需要刷新对 etcd 服务端点的引用,目前 Pigsty 中有四处 etcd 引用:
要在现有etcd成员上刷新 etcd 配置文件 /etc/etcd/etcd.conf:
刷新 etcdctl 客户端环境变量:
在 patroni 上更新 etcd 端点引用:
在 vip-manager 上更新 etcd 端点引用(如果你正在使用 PGSQL L2 VIP 才需要执行此操作):
添加成员
ETCD 参考: 添加成员
向现有的 etcd 集群添加新成员通常需要五个步骤:
简短版本
- 执行
etcdctl member add命令,通知现有集群即将有新成员加入(使用学习者模式) - 更新配置清单,将新实例写入配置文件
etcd组中。 - 使用
etcd_init=existing的方式初始化新的 etcd 实例,使其加入现有集群而不是创建一个新集群(非常重要) - 将新成员从学习者提升为追随者,正式成为集群中具有投票权的一员。
- 重载配置 以更新客户端使用的 etcd 服务端点。
详细步骤:向etcd集群添加成员
下面是具体操作的详细细节,让我们从一个单实例 etcd 集群开始:
使用 etcd member add 向现有 etcd 集群宣告新的学习者实例 etcd-2 即将到来:
使用 etcdctl member list(或 em list)检查成员列表,我们可以看到一个 unstarted 新成员:
接下来使用 etcd.yml 剧本初始化新的 etcd 实例 etcd-2,完成后,我们可以看到新成员已经启动:
新成员初始化完成并稳定运行后,可以将新成员从学习者提升为追随者:
新成员添加完成,请不要忘记 重载配置 ,让所有客户端也知道新成员的存在。
重复以上步骤,可以添加更多成员。记住,生产环境中至少要使用 3 个成员。
移除成员
要从 etcd 集群中删除一个成员实例,通常需要以下三个步骤:
- 从配置清单中注释/屏蔽/删除该实例,并重载配置,让客户端不再使用该实例。
- 使用
etcdctl member remove <server_id>命令将它从集群中踢除 - 将该实例临时添加回配置清单,使用剧本彻底移除下线该实例,然后永久从配置中删除
详细步骤:从etcd集群移除成员
让我们以一个 3 节点的 etcd 集群为例,从中移除 3 号实例。
为了刷新配置,您需要 注释 要待删除的成员,然后 重载配置,让所有客户端都不要再使用此实例。
然后,您需要使用 etcdctl member remove 命令,将它从集群中踢出去:
最后,您要将该成员临时添加回配置清单中以便运行下线任务,将实例彻底关停移除。
执行完毕后,您可以将其从配置清单中永久删除,移除成员至此完成。
重复以上步骤,可以移除更多成员,与添加成员配合使用,可以对 etcd 集群进行滚动升级搬迁。
剧本
ETCD 模块提供了一个内置的 playbook: etcd.yml,用于安装 etcd 集群。但首先你需要定义它。
etcd.yml
在 etcd.yml 中,提供了以下是可用的任务子集:
etcd_assert:生成 etcd 身份etcd_install:安装 etcd rpm 包etcd_clean:清理现有的 etcd 实例etcd_check:检查 etcd 实例是否在运行etcd_purge:删除正在运行的 etcd 实例和数据
etcd_dir:创建 etcd 数据和配置目录etcd_config:生成 etcd 配置etcd_conf:生成 etcd 主配置etcd_cert:生成 etcd ssl 证书
etcd_launch:启动 etcd 服务etcd_register: 将 etcd 注册到 prometheus
监控
ETCD 模块提供了一个监控面板:Etcd Overview。
ETCD Overview Dashboard
ETCD Overview:ETCD 集群概览
这个监控面板提供了 ETCD 状态的关键信息:最值得关注的是 ETCD Aliveness,它显示了 ETCD 集群整体的服务状态。
红色的条带标识着实例不可用的时间段,而底下蓝灰色的条带标识着整个集群处于不可用的时间段。
参数
ETCD 模块有 10 个相关参数:
| 参数 | 类型 | 级别 | 注释 |
|---|---|---|---|
etcd_seq |
int | I | etcd 实例标识符,必填 |
etcd_cluster |
string | C | etcd 集群名,默认固定为 etcd |
etcd_safeguard |
bool | G/C/A | etcd 防误删保险,阻止清除正在运行的 etcd 实例? |
etcd_clean |
bool | G/C/A | etcd 清除指令:在初始化时清除现有的 etcd 实例? |
etcd_data |
path | C | etcd 数据目录,默认为 /data/etcd |
etcd_port |
port | C | etcd 客户端端口,默认为 2379 |
etcd_peer_port |
port | C | etcd 同伴端口,默认为 2380 |
etcd_init |
enum | C | etcd 初始集群状态,新建或已存在 |
etcd_election_timeout |
int | C | etcd 选举超时,默认为 1000ms |
etcd_heartbeat_interval |
int | C | etcd 心跳间隔,默认为 100ms |
1 - 指标列表
ETCD 模块包含有 177 类可用监控指标。
| Metric Name | Type | Labels | Description |
|---|---|---|---|
| etcd:ins:backend_commit_rt_p99_5m | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd:ins:disk_fsync_rt_p99_5m | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd:ins:network_peer_rt_p99_1m | Unknown | cls, To, ins, instance, job, ip |
N/A |
| etcd_cluster_version | gauge | cls, cluster_version, ins, instance, job, ip |
Which version is running. 1 for ‘cluster_version’ label with current cluster version |
| etcd_debugging_auth_revision | gauge | cls, ins, instance, job, ip |
The current revision of auth store. |
| etcd_debugging_disk_backend_commit_rebalance_duration_seconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_debugging_disk_backend_commit_rebalance_duration_seconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_disk_backend_commit_rebalance_duration_seconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_disk_backend_commit_spill_duration_seconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_debugging_disk_backend_commit_spill_duration_seconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_disk_backend_commit_spill_duration_seconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_disk_backend_commit_write_duration_seconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_debugging_disk_backend_commit_write_duration_seconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_disk_backend_commit_write_duration_seconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_lease_granted_total | counter | cls, ins, instance, job, ip |
The total number of granted leases. |
| etcd_debugging_lease_renewed_total | counter | cls, ins, instance, job, ip |
The number of renewed leases seen by the leader. |
| etcd_debugging_lease_revoked_total | counter | cls, ins, instance, job, ip |
The total number of revoked leases. |
| etcd_debugging_lease_ttl_total_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_debugging_lease_ttl_total_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_lease_ttl_total_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_mvcc_compact_revision | gauge | cls, ins, instance, job, ip |
The revision of the last compaction in store. |
| etcd_debugging_mvcc_current_revision | gauge | cls, ins, instance, job, ip |
The current revision of store. |
| etcd_debugging_mvcc_db_compaction_keys_total | counter | cls, ins, instance, job, ip |
Total number of db keys compacted. |
| etcd_debugging_mvcc_db_compaction_last | gauge | cls, ins, instance, job, ip |
The unix time of the last db compaction. Resets to 0 on start. |
| etcd_debugging_mvcc_db_compaction_pause_duration_milliseconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_debugging_mvcc_db_compaction_pause_duration_milliseconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_mvcc_db_compaction_pause_duration_milliseconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_mvcc_db_compaction_total_duration_milliseconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_debugging_mvcc_db_compaction_total_duration_milliseconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_mvcc_db_compaction_total_duration_milliseconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_mvcc_events_total | counter | cls, ins, instance, job, ip |
Total number of events sent by this member. |
| etcd_debugging_mvcc_index_compaction_pause_duration_milliseconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_debugging_mvcc_index_compaction_pause_duration_milliseconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_mvcc_index_compaction_pause_duration_milliseconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_mvcc_keys_total | gauge | cls, ins, instance, job, ip |
Total number of keys. |
| etcd_debugging_mvcc_pending_events_total | gauge | cls, ins, instance, job, ip |
Total number of pending events to be sent. |
| etcd_debugging_mvcc_range_total | counter | cls, ins, instance, job, ip |
Total number of ranges seen by this member. |
| etcd_debugging_mvcc_slow_watcher_total | gauge | cls, ins, instance, job, ip |
Total number of unsynced slow watchers. |
| etcd_debugging_mvcc_total_put_size_in_bytes | gauge | cls, ins, instance, job, ip |
The total size of put kv pairs seen by this member. |
| etcd_debugging_mvcc_watch_stream_total | gauge | cls, ins, instance, job, ip |
Total number of watch streams. |
| etcd_debugging_mvcc_watcher_total | gauge | cls, ins, instance, job, ip |
Total number of watchers. |
| etcd_debugging_server_lease_expired_total | counter | cls, ins, instance, job, ip |
The total number of expired leases. |
| etcd_debugging_snap_save_marshalling_duration_seconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_debugging_snap_save_marshalling_duration_seconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_snap_save_marshalling_duration_seconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_snap_save_total_duration_seconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_debugging_snap_save_total_duration_seconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_snap_save_total_duration_seconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_debugging_store_expires_total | counter | cls, ins, instance, job, ip |
Total number of expired keys. |
| etcd_debugging_store_reads_total | counter | cls, action, ins, instance, job, ip |
Total number of reads action by (get/getRecursive), local to this member. |
| etcd_debugging_store_watch_requests_total | counter | cls, ins, instance, job, ip |
Total number of incoming watch requests (new or reestablished). |
| etcd_debugging_store_watchers | gauge | cls, ins, instance, job, ip |
Count of currently active watchers. |
| etcd_debugging_store_writes_total | counter | cls, action, ins, instance, job, ip |
Total number of writes (e.g. set/compareAndDelete) seen by this member. |
| etcd_disk_backend_commit_duration_seconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_disk_backend_commit_duration_seconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_disk_backend_commit_duration_seconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_disk_backend_defrag_duration_seconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_disk_backend_defrag_duration_seconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_disk_backend_defrag_duration_seconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_disk_backend_snapshot_duration_seconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_disk_backend_snapshot_duration_seconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_disk_backend_snapshot_duration_seconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_disk_defrag_inflight | gauge | cls, ins, instance, job, ip |
Whether or not defrag is active on the member. 1 means active, 0 means not. |
| etcd_disk_wal_fsync_duration_seconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_disk_wal_fsync_duration_seconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_disk_wal_fsync_duration_seconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_disk_wal_write_bytes_total | gauge | cls, ins, instance, job, ip |
Total number of bytes written in WAL. |
| etcd_grpc_proxy_cache_hits_total | gauge | cls, ins, instance, job, ip |
Total number of cache hits |
| etcd_grpc_proxy_cache_keys_total | gauge | cls, ins, instance, job, ip |
Total number of keys/ranges cached |
| etcd_grpc_proxy_cache_misses_total | gauge | cls, ins, instance, job, ip |
Total number of cache misses |
| etcd_grpc_proxy_events_coalescing_total | counter | cls, ins, instance, job, ip |
Total number of events coalescing |
| etcd_grpc_proxy_watchers_coalescing_total | gauge | cls, ins, instance, job, ip |
Total number of current watchers coalescing |
| etcd_mvcc_db_open_read_transactions | gauge | cls, ins, instance, job, ip |
The number of currently open read transactions |
| etcd_mvcc_db_total_size_in_bytes | gauge | cls, ins, instance, job, ip |
Total size of the underlying database physically allocated in bytes. |
| etcd_mvcc_db_total_size_in_use_in_bytes | gauge | cls, ins, instance, job, ip |
Total size of the underlying database logically in use in bytes. |
| etcd_mvcc_delete_total | counter | cls, ins, instance, job, ip |
Total number of deletes seen by this member. |
| etcd_mvcc_hash_duration_seconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_mvcc_hash_duration_seconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_mvcc_hash_duration_seconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_mvcc_hash_rev_duration_seconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_mvcc_hash_rev_duration_seconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_mvcc_hash_rev_duration_seconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_mvcc_put_total | counter | cls, ins, instance, job, ip |
Total number of puts seen by this member. |
| etcd_mvcc_range_total | counter | cls, ins, instance, job, ip |
Total number of ranges seen by this member. |
| etcd_mvcc_txn_total | counter | cls, ins, instance, job, ip |
Total number of txns seen by this member. |
| etcd_network_active_peers | gauge | cls, ins, Local, instance, job, ip, Remote |
The current number of active peer connections. |
| etcd_network_client_grpc_received_bytes_total | counter | cls, ins, instance, job, ip |
The total number of bytes received from grpc clients. |
| etcd_network_client_grpc_sent_bytes_total | counter | cls, ins, instance, job, ip |
The total number of bytes sent to grpc clients. |
| etcd_network_peer_received_bytes_total | counter | cls, ins, instance, job, ip, From |
The total number of bytes received from peers. |
| etcd_network_peer_round_trip_time_seconds_bucket | Unknown | cls, To, ins, instance, job, le, ip |
N/A |
| etcd_network_peer_round_trip_time_seconds_count | Unknown | cls, To, ins, instance, job, ip |
N/A |
| etcd_network_peer_round_trip_time_seconds_sum | Unknown | cls, To, ins, instance, job, ip |
N/A |
| etcd_network_peer_sent_bytes_total | counter | cls, To, ins, instance, job, ip |
The total number of bytes sent to peers. |
| etcd_server_apply_duration_seconds_bucket | Unknown | cls, version, ins, instance, job, le, success, ip, op |
N/A |
| etcd_server_apply_duration_seconds_count | Unknown | cls, version, ins, instance, job, success, ip, op |
N/A |
| etcd_server_apply_duration_seconds_sum | Unknown | cls, version, ins, instance, job, success, ip, op |
N/A |
| etcd_server_client_requests_total | counter | client_api_version, cls, ins, instance, type, job, ip |
The total number of client requests per client version. |
| etcd_server_go_version | gauge | cls, ins, instance, job, server_go_version, ip |
Which Go version server is running with. 1 for ‘server_go_version’ label with current version. |
| etcd_server_has_leader | gauge | cls, ins, instance, job, ip |
Whether or not a leader exists. 1 is existence, 0 is not. |
| etcd_server_health_failures | counter | cls, ins, instance, job, ip |
The total number of failed health checks |
| etcd_server_health_success | counter | cls, ins, instance, job, ip |
The total number of successful health checks |
| etcd_server_heartbeat_send_failures_total | counter | cls, ins, instance, job, ip |
The total number of leader heartbeat send failures (likely overloaded from slow disk). |
| etcd_server_id | gauge | cls, ins, instance, job, server_id, ip |
Server or member ID in hexadecimal format. 1 for ‘server_id’ label with current ID. |
| etcd_server_is_leader | gauge | cls, ins, instance, job, ip |
Whether or not this member is a leader. 1 if is, 0 otherwise. |
| etcd_server_is_learner | gauge | cls, ins, instance, job, ip |
Whether or not this member is a learner. 1 if is, 0 otherwise. |
| etcd_server_leader_changes_seen_total | counter | cls, ins, instance, job, ip |
The number of leader changes seen. |
| etcd_server_learner_promote_successes | counter | cls, ins, instance, job, ip |
The total number of successful learner promotions while this member is leader. |
| etcd_server_proposals_applied_total | gauge | cls, ins, instance, job, ip |
The total number of consensus proposals applied. |
| etcd_server_proposals_committed_total | gauge | cls, ins, instance, job, ip |
The total number of consensus proposals committed. |
| etcd_server_proposals_failed_total | counter | cls, ins, instance, job, ip |
The total number of failed proposals seen. |
| etcd_server_proposals_pending | gauge | cls, ins, instance, job, ip |
The current number of pending proposals to commit. |
| etcd_server_quota_backend_bytes | gauge | cls, ins, instance, job, ip |
Current backend storage quota size in bytes. |
| etcd_server_read_indexes_failed_total | counter | cls, ins, instance, job, ip |
The total number of failed read indexes seen. |
| etcd_server_slow_apply_total | counter | cls, ins, instance, job, ip |
The total number of slow apply requests (likely overloaded from slow disk). |
| etcd_server_slow_read_indexes_total | counter | cls, ins, instance, job, ip |
The total number of pending read indexes not in sync with leader’s or timed out read index requests. |
| etcd_server_snapshot_apply_in_progress_total | gauge | cls, ins, instance, job, ip |
1 if the server is applying the incoming snapshot. 0 if none. |
| etcd_server_version | gauge | cls, server_version, ins, instance, job, ip |
Which version is running. 1 for ‘server_version’ label with current version. |
| etcd_snap_db_fsync_duration_seconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_snap_db_fsync_duration_seconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_snap_db_fsync_duration_seconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_snap_db_save_total_duration_seconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_snap_db_save_total_duration_seconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_snap_db_save_total_duration_seconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_snap_fsync_duration_seconds_bucket | Unknown | cls, ins, instance, job, le, ip |
N/A |
| etcd_snap_fsync_duration_seconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_snap_fsync_duration_seconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| etcd_up | Unknown | cls, ins, instance, job, ip |
N/A |
| go_gc_duration_seconds | summary | cls, ins, instance, quantile, job, ip |
A summary of the pause duration of garbage collection cycles. |
| go_gc_duration_seconds_count | Unknown | cls, ins, instance, job, ip |
N/A |
| go_gc_duration_seconds_sum | Unknown | cls, ins, instance, job, ip |
N/A |
| go_goroutines | gauge | cls, ins, instance, job, ip |
Number of goroutines that currently exist. |
| go_info | gauge | cls, version, ins, instance, job, ip |
Information about the Go environment. |
| go_memstats_alloc_bytes | gauge | cls, ins, instance, job, ip |
Number of bytes allocated and still in use. |
| go_memstats_alloc_bytes_total | counter | cls, ins, instance, job, ip |
Total number of bytes allocated, even if freed. |
| go_memstats_buck_hash_sys_bytes | gauge | cls, ins, instance, job, ip |
Number of bytes used by the profiling bucket hash table. |
| go_memstats_frees_total | counter | cls, ins, instance, job, ip |
Total number of frees. |
| go_memstats_gc_cpu_fraction | gauge | cls, ins, instance, job, ip |
The fraction of this program’s available CPU time used by the GC since the program started. |
| go_memstats_gc_sys_bytes | gauge | cls, ins, instance, job, ip |
Number of bytes used for garbage collection system metadata. |
| go_memstats_heap_alloc_bytes | gauge | cls, ins, instance, job, ip |
Number of heap bytes allocated and still in use. |
| go_memstats_heap_idle_bytes | gauge | cls, ins, instance, job, ip |
Number of heap bytes waiting to be used. |
| go_memstats_heap_inuse_bytes | gauge | cls, ins, instance, job, ip |
Number of heap bytes that are in use. |
| go_memstats_heap_objects | gauge | cls, ins, instance, job, ip |
Number of allocated objects. |
| go_memstats_heap_released_bytes | gauge | cls, ins, instance, job, ip |
Number of heap bytes released to OS. |
| go_memstats_heap_sys_bytes | gauge | cls, ins, instance, job, ip |
Number of heap bytes obtained from system. |
| go_memstats_last_gc_time_seconds | gauge | cls, ins, instance, job, ip |
Number of seconds since 1970 of last garbage collection. |
| go_memstats_lookups_total | counter | cls, ins, instance, job, ip |
Total number of pointer lookups. |
| go_memstats_mallocs_total | counter | cls, ins, instance, job, ip |
Total number of mallocs. |
| go_memstats_mcache_inuse_bytes | gauge | cls, ins, instance, job, ip |
Number of bytes in use by mcache structures. |
| go_memstats_mcache_sys_bytes | gauge | cls, ins, instance, job, ip |
Number of bytes used for mcache structures obtained from system. |
| go_memstats_mspan_inuse_bytes | gauge | cls, ins, instance, job, ip |
Number of bytes in use by mspan structures. |
| go_memstats_mspan_sys_bytes | gauge | cls, ins, instance, job, ip |
Number of bytes used for mspan structures obtained from system. |
| go_memstats_next_gc_bytes | gauge | cls, ins, instance, job, ip |
Number of heap bytes when next garbage collection will take place. |
| go_memstats_other_sys_bytes | gauge | cls, ins, instance, job, ip |
Number of bytes used for other system allocations. |
| go_memstats_stack_inuse_bytes | gauge | cls, ins, instance, job, ip |
Number of bytes in use by the stack allocator. |
| go_memstats_stack_sys_bytes | gauge | cls, ins, instance, job, ip |
Number of bytes obtained from system for stack allocator. |
| go_memstats_sys_bytes | gauge | cls, ins, instance, job, ip |
Number of bytes obtained from system. |
| go_threads | gauge | cls, ins, instance, job, ip |
Number of OS threads created. |
| grpc_server_handled_total | counter | cls, ins, instance, grpc_code, job, grpc_method, grpc_type, ip, grpc_service |
Total number of RPCs completed on the server, regardless of success or failure. |
| grpc_server_msg_received_total | counter | cls, ins, instance, job, grpc_type, grpc_method, ip, grpc_service |
Total number of RPC stream messages received on the server. |
| grpc_server_msg_sent_total | counter | cls, ins, instance, job, grpc_type, grpc_method, ip, grpc_service |
Total number of gRPC stream messages sent by the server. |
| grpc_server_started_total | counter | cls, ins, instance, job, grpc_type, grpc_method, ip, grpc_service |
Total number of RPCs started on the server. |
| os_fd_limit | gauge | cls, ins, instance, job, ip |
The file descriptor limit. |
| os_fd_used | gauge | cls, ins, instance, job, ip |
The number of used file descriptors. |
| process_cpu_seconds_total | counter | cls, ins, instance, job, ip |
Total user and system CPU time spent in seconds. |
| process_max_fds | gauge | cls, ins, instance, job, ip |
Maximum number of open file descriptors. |
| process_open_fds | gauge | cls, ins, instance, job, ip |
Number of open file descriptors. |
| process_resident_memory_bytes | gauge | cls, ins, instance, job, ip |
Resident memory size in bytes. |
| process_start_time_seconds | gauge | cls, ins, instance, job, ip |
Start time of the process since unix epoch in seconds. |
| process_virtual_memory_bytes | gauge | cls, ins, instance, job, ip |
Virtual memory size in bytes. |
| process_virtual_memory_max_bytes | gauge | cls, ins, instance, job, ip |
Maximum amount of virtual memory available in bytes. |
| promhttp_metric_handler_requests_in_flight | gauge | cls, ins, instance, job, ip |
Current number of scrapes being served. |
| promhttp_metric_handler_requests_total | counter | cls, ins, instance, job, ip, code |
Total number of scrapes by HTTP status code. |
| scrape_duration_seconds | Unknown | cls, ins, instance, job, ip |
N/A |
| scrape_samples_post_metric_relabeling | Unknown | cls, ins, instance, job, ip |
N/A |
| scrape_samples_scraped | Unknown | cls, ins, instance, job, ip |
N/A |
| scrape_series_added | Unknown | cls, ins, instance, job, ip |
N/A |
| up | Unknown | cls, ins, instance, job, ip |
N/A |
2 - 常见问题
ETCD集群如果不可用了会有什么影响?
ETCD 对于 PGSQL 集群的高可用至关重要,而 etcd 本身的可用性是通过使用多个节点来保证的。使用3节点的 etcd 集群允许最多一个节点宕机,而其他两个节点仍然可以正常工作; 使用五节点的 ETCD 集群则可以容忍两个节点失效。如果超过一半的 ETCD 节点宕机,ETCD 集群及其服务将不可用。在 Patroni 3.0 之前,这可能导致 PGSQL 全局故障;所有的主节点将被降级并拒绝写请求。
自从 pigsty 2.0 起,默认启用了 patroni 3.0 的 DCS 容错模式, 当 etcd 集群不可用时,如果 PostgreSQL 集群主库可以感知到所有成员,就会 锁定 PGSQL 集群状态。
在这种情况下,PGSQL 集群仍然可以正常工作,但您必须尽快恢复 ETCD 集群。(毕竟如果etcd宕机,您就无法通过 patroni 配置PostgreSQL集群了)
如何使用一个外部的已经存在的 ETCD 集群?
配置清单中硬编码了所使用 etcd 的分组名为 etcd,这个分组里的成员将被用作 PGSQL 的 DCS 服务器。您可以使用 etcd.yml 对它们进行初始化,或直接假设它是一个已存在的外部 etcd 集群。
要使用现有的外部 etcd 集群,只要像往常一样定义它们即可,您可以跳过 etcd.yml 剧本的执行,因为集群已经存在,不需要部署。
但您必须确保一点:现有 etcd 集群证书是由同一 CA 签名颁发的。否则客户端是无法使用 Pigsty 自签名的 CA 颁发的证书来访问这套 ETCD 的。
如何向现有ETCD集群添加新的成员?
详细过程,请参考向 etcd 集群添加成员
如何从现有ETCD集群中移除成员?
详细过程,请参考从 etcd 集群中移除成员
