MXDB:MatrixDB演示

4节点的MatrixDB部署配置文件,使用一个Master与3对数据节点

  1. ---
  2. ######################################################################
  3. # File : pigsty.yml
  4. # Desc : Pigsty matrixdb 4-node exmaple file
  5. # Link : https://pigsty.cc/#/v-config
  6. # Ctime : 2020-05-22
  7. # Mtime : 2022-05-22
  8. # Copyright (C) 2018-2022 Ruohang Feng (rh@vonng.com)
  9. ######################################################################
  10. ######################################################################
  11. # 1. mx-mdw-1 : 10.10.10.10 (2 Core | 4GB) mx-mdw-1(m)
  12. # 2. mx-sdw-1 : 10.10.10.11 (1 Core | 1GB) mx-seg1-1(p) mx-seg2-2(r)
  13. # 3. mx-sdw-2 : 10.10.10.12 (1 Core | 1GB) mx-seg2-1(p) mx-seg3-2(r)
  14. # 4. mx-sdw-3 : 10.10.10.13 (1 Core | 1GB) mx-seg3-1(p) mx-seg1-2(r)
  15. ######################################################################
  16. all:
  17. ##################################################################
  18. # CLUSTERS #
  19. ##################################################################
  20. # meta nodes, nodes, pgsql, redis, pgsql clusters are defined as
  21. # k:v pair inside `all.children`. Where the key is cluster name
  22. # and value is cluster definition consist of two parts:
  23. # `hosts`: cluster members ip and instance level variables
  24. # `vars` : cluster level variables
  25. ##################################################################
  26. children: # groups definition
  27. #================================================================#
  28. # Meta Nodes: Admin Controller #
  29. #================================================================#
  30. meta: # meta nodes are defined in this special group "meta"
  31. vars:
  32. meta_node: true # mark this group as meta nodes
  33. ansible_group_priority: 99 # overwrite with the highest priority
  34. nginx_enabled: true # setup repo & underlying nginx
  35. nameserver_enabled: false # setup dnsmasq
  36. prometheus_enabled: true # setup prometheus
  37. grafana_enabled: true # setup grafana
  38. loki_enabled: true # setup loki
  39. docker_enabled: true # setup docker
  40. dcs_safeguard: false # protect dcs server from fat fingers
  41. hosts: # add nodes to group 'meta'
  42. 10.10.10.10: { }
  43. # 10.10.10.11: { nginx_enabled: false }
  44. # 10.10.10.12: { nginx_enabled: false }
  45. #================================================================#
  46. #================================================================#
  47. # GPSQL Clusters #
  48. #================================================================#
  49. #----------------------------------#
  50. # cluster: mx-mdw (gp master)
  51. #----------------------------------#
  52. mx-mdw:
  53. hosts:
  54. 10.10.10.10: { pg_seq: 1, pg_role: primary , nodename: mx-mdw-1 }
  55. vars:
  56. gp_role: master # this cluster is used as greenplum master
  57. pg_shard: mx # pgsql sharding name & gpsql deployment name
  58. pg_cluster: mx-mdw # this master cluster name is mx-mdw
  59. pg_databases:
  60. - { name: matrixmgr , extensions: [ { name: matrixdbts } ] }
  61. - { name: meta }
  62. pg_users:
  63. - { name: meta , password: DBUser.Meta , pgbouncer: true }
  64. - { name: dbuser_monitor , password: DBUser.Monitor , roles: [ dbrole_readonly ], superuser: true }
  65. pgbouncer_enabled: true # enable pgbouncer for greenplum master
  66. pgbouncer_exporter_enabled: false # enable pgbouncer_exporter for greenplum master
  67. pg_exporter_params: 'host=127.0.0.1&sslmode=disable' # use 127.0.0.1 as local monitor host
  68. #----------------------------------#
  69. # cluster: mx-sdw (gp master)
  70. #----------------------------------#
  71. mx-sdw:
  72. hosts:
  73. 10.10.10.11:
  74. nodename: mx-sdw-1 # greenplum segment node
  75. pg_instances: # greenplum segment instances
  76. 6000: { pg_cluster: mx-seg1, pg_seq: 1, pg_role: primary , pg_exporter_port: 9633 }
  77. 6001: { pg_cluster: mx-seg2, pg_seq: 2, pg_role: replica , pg_exporter_port: 9634 }
  78. 10.10.10.12:
  79. nodename: mx-sdw-2
  80. pg_instances:
  81. 6000: { pg_cluster: mx-seg2, pg_seq: 1, pg_role: primary , pg_exporter_port: 9633 }
  82. 6001: { pg_cluster: mx-seg3, pg_seq: 2, pg_role: replica , pg_exporter_port: 9634 }
  83. 10.10.10.13:
  84. nodename: mx-sdw-3
  85. pg_instances:
  86. 6000: { pg_cluster: mx-seg3, pg_seq: 1, pg_role: primary , pg_exporter_port: 9633 }
  87. 6001: { pg_cluster: mx-seg1, pg_seq: 2, pg_role: replica , pg_exporter_port: 9634 }
  88. vars:
  89. gp_role: segment # these are nodes for gp segments
  90. pg_shard: mx # pgsql sharding name & gpsql deployment name
  91. pg_cluster: mx-sdw # these segment clusters name is mx-sdw
  92. pg_preflight_skip: true # skip preflight check (since pg_seq & pg_role & pg_cluster not exists)
  93. pg_exporter_config: pg_exporter_basic.yml # use basic config to avoid segment server crash
  94. pg_exporter_params: 'options=-c%20gp_role%3Dutility&sslmode=disable' # use gp_role = utility to connect to segments
  95. ####################################################################
  96. # VARS #
  97. ####################################################################
  98. vars: # global variables
  99. version: v1.5.1 # pigsty version string
  100. #================================================================#
  101. # VARS: INFRA #
  102. #================================================================#
  103. #-----------------------------------------------------------------
  104. # CONNECT
  105. #-----------------------------------------------------------------
  106. # INSTANCE level ansible connect parameters
  107. # ansible_user: vagrant # which user to be used (when connecting to remote nodes)
  108. # ansible_port: 22 # which port to be used (when connecting to remote nodes)
  109. # ansible_host: meta # ssh alias host name (when connecting to remote nodes)
  110. # ansible_ssh_private_key_file: ~/.ssh/id_rsa # ssh private key file
  111. # ansible_ssh_common_args: '-o StrictHostKeyChecking=no' # ssh common args
  112. proxy_env: # global proxy env when downloading packages
  113. no_proxy: "localhost,127.0.0.1,10.0.0.0/8,192.168.0.0/16,*.pigsty,*.aliyun.com,mirrors.*,*.myqcloud.com,*.tsinghua.edu.cn"
  114. # http_proxy: # set your proxy here: e.g http://user:pass@proxy.xxx.com
  115. # https_proxy: # set your proxy here: e.g http://user:pass@proxy.xxx.com
  116. # all_proxy: # set your proxy here: e.g http://user:pass@proxy.xxx.com
  117. #-----------------------------------------------------------------
  118. # CA
  119. #-----------------------------------------------------------------
  120. ca_method: create # create|copy|recreate
  121. ca_subject: "/CN=root-ca" # self-signed CA subject
  122. ca_homedir: /ca # ca cert directory
  123. ca_cert: ca.crt # ca public key/cert
  124. ca_key: ca.key # ca private key
  125. #-----------------------------------------------------------------
  126. # NGINX
  127. #-----------------------------------------------------------------
  128. nginx_enabled: true # build local repo on this node
  129. nginx_port: 80 # repo listen address, must same as repo_address
  130. nginx_home: /www # default repo home dir
  131. nginx_upstream: # domain names and upstream servers
  132. - { name: home , domain: pigsty , endpoint: "10.10.10.10:80" }
  133. - { name: grafana , domain: g.pigsty , endpoint: "10.10.10.10:3000" }
  134. - { name: loki , domain: l.pigsty , endpoint: "10.10.10.10:3100" }
  135. - { name: prometheus , domain: p.pigsty , endpoint: "10.10.10.10:9090" }
  136. - { name: alertmanager , domain: a.pigsty , endpoint: "10.10.10.10:9093" }
  137. - { name: consul , domain: c.pigsty , endpoint: "127.0.0.1:8500" }
  138. - { name: matrixdb , domain: mx.pigsty , endpoint: "127.0.0.1:8240" }
  139. nginx_indexes: # application nav links on home page
  140. - { name: MatrixDB , url : 'http://mx.pigsty' , comment: 'MatrixDB Installer' }
  141. - { name: Explain , url : '/pev2' , comment: 'postgres explain visualizer' }
  142. - { name: Package , url : '/pigsty' , comment: 'local yum repo packages' }
  143. - { name: PG Logs , url : '/logs' , comment: 'postgres raw csv logs' }
  144. - { name: Schemas , url : '/schema' , comment: 'schemaspy summary report' }
  145. - { name: Reports , url : '/report' , comment: 'pgbadger summary report' }
  146. #-----------------------------------------------------------------
  147. # REPO
  148. #-----------------------------------------------------------------
  149. repo_name: pigsty # repo name, pigsty by default
  150. repo_address: pigsty # external address to this repo (ip:port or url)
  151. repo_rebuild: false # force re-download packages
  152. repo_remove: true # remove existing upstream repo
  153. repo_upstreams: # where to download packages?
  154. - name: base
  155. description: CentOS-$releasever - Base
  156. gpgcheck: no
  157. baseurl:
  158. - https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
  159. - http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
  160. - http://mirror.centos.org/centos/$releasever/os/$basearch/
  161. - name: updates
  162. description: CentOS-$releasever - Updates
  163. gpgcheck: no
  164. baseurl:
  165. - https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
  166. - http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
  167. - http://mirror.centos.org/centos/$releasever/updates/$basearch/
  168. - name: extras
  169. description: CentOS-$releasever - Extras
  170. baseurl:
  171. - https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
  172. - http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
  173. - http://mirror.centos.org/centos/$releasever/extras/$basearch/
  174. gpgcheck: no
  175. - name: epel
  176. description: CentOS $releasever - epel
  177. gpgcheck: no
  178. baseurl:
  179. - https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/$basearch
  180. - http://mirrors.aliyun.com/epel/$releasever/$basearch
  181. - http://download.fedoraproject.org/pub/epel/$releasever/$basearch
  182. - name: grafana
  183. description: Grafana Official Yum Repo
  184. enabled: yes
  185. gpgcheck: no
  186. baseurl:
  187. - https://mirrors.tuna.tsinghua.edu.cn/grafana/yum/rpm
  188. - https://packages.grafana.com/oss/rpm
  189. - name: prometheus
  190. description: Prometheus and exporters
  191. gpgcheck: no
  192. baseurl: https://packagecloud.io/prometheus-rpm/release/el/$releasever/$basearch
  193. - name: pgdg-common
  194. description: PostgreSQL common RPMs for RHEL/CentOS $releasever - $basearch
  195. gpgcheck: no
  196. baseurl:
  197. - http://mirrors.tuna.tsinghua.edu.cn/postgresql/repos/yum/common/redhat/rhel-$releasever-$basearch
  198. - https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-$releasever-$basearch
  199. - name: pgdg14
  200. description: PostgreSQL 14 for RHEL/CentOS $releasever - $basearch
  201. gpgcheck: no
  202. baseurl:
  203. - https://mirrors.tuna.tsinghua.edu.cn/postgresql/repos/yum/14/redhat/rhel-$releasever-$basearch
  204. - https://download.postgresql.org/pub/repos/yum/14/redhat/rhel-$releasever-$basearch
  205. - name: timescaledb
  206. description: TimescaleDB for RHEL/CentOS $releasever - $basearch
  207. gpgcheck: no
  208. baseurl:
  209. - https://packagecloud.io/timescale/timescaledb/el/7/$basearch
  210. - name: centos-sclo
  211. description: CentOS-$releasever - SCLo
  212. gpgcheck: no
  213. #mirrorlist: http://mirrorlist.centos.org?arch=$basearch&release=$releasever&repo=sclo-sclo
  214. baseurl: http://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/sclo/
  215. - name: centos-sclo-rh
  216. description: CentOS-$releasever - SCLo rh
  217. gpgcheck: no
  218. #mirrorlist: http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-rh
  219. baseurl: http://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/rh/
  220. - name: nginx
  221. description: Nginx Official Yum Repo
  222. skip_if_unavailable: true
  223. gpgcheck: no
  224. baseurl: http://nginx.org/packages/centos/$releasever/$basearch/
  225. - name: harbottle # for latest consul & kubernetes
  226. description: Copr repo for main owned by harbottle
  227. skip_if_unavailable: true
  228. gpgcheck: no
  229. baseurl: https://download.copr.fedorainfracloud.org/results/harbottle/main/epel-$releasever-$basearch/
  230. - name: pg_probackup # for pg_probackup
  231. description: PG_PROBACKUP Centos packages for PostgresPro Standard and Enterprise - $basearch
  232. skip_if_unavailable: true
  233. gpgcheck: no
  234. baseurl: https://repo.postgrespro.ru/pg_probackup-forks/rpm/latest/centos-$releasever-$basearch
  235. - name: docker-ce # for latest docker
  236. description: Docker CE Stable - $basearch
  237. skip_if_unavailable: true
  238. gpgcheck: no
  239. baseurl:
  240. - https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/stable
  241. - https://download.docker.com/linux/centos/$releasever/$basearch/stable
  242. repo_packages: # which packages to be included # what to download #
  243. - epel-release nginx wget yum-utils yum createrepo sshpass zip unzip # ---- boot ---- #
  244. - ntp chrony uuid lz4 bzip2 nc pv jq vim-enhanced make patch bash lsof wget git tuned perf ftp lrzsz rsync # ---- node ---- #
  245. - numactl grubby sysstat dstat iotop bind-utils net-tools tcpdump socat ipvsadm telnet ca-certificates keepalived # ----- utils ----- #
  246. - readline zlib openssl openssh-clients libyaml libxml2 libxslt libevent perl perl-devel perl-ExtUtils* # --- deps:pg --- #
  247. - readline-devel zlib-devel uuid-devel libuuid-devel libxml2-devel libxslt-devel openssl-devel libicu-devel # --- deps:devel -- #
  248. - grafana prometheus2 pushgateway alertmanager mtail consul consul_exporter consul-template etcd dnsmasq # ----- meta ----- #
  249. - node_exporter nginx_exporter blackbox_exporter redis_exporter # ---- exporter --- #
  250. - ansible python python-pip python-psycopg2 # - ansible & py3 - #
  251. - python3 python3-psycopg2 python36-requests python3-etcd python3-consul python36-urllib3 python36-idna python36-pyOpenSSL python36-cryptography
  252. - patroni patroni-consul patroni-etcd pgbouncer pg_cli pgbadger pg_activity tail_n_mail # -- pgsql common - #
  253. - pgcenter boxinfo check_postgres emaj pgbconsole pg_bloat_check pgquarrel barman barman-cli pgloader pgFormatter pitrery pspg pgxnclient PyGreSQL
  254. - postgresql14* postgis32_14* citus_14* pglogical_14* timescaledb-2-postgresql-14 pg_repack_14 wal2json_14 # -- pg14 packages -#
  255. - pg_qualstats_14 pg_stat_kcache_14 pg_stat_monitor_14 pg_top_14 pg_track_settings_14 pg_wait_sampling_14 pg_probackup-std-14
  256. - pg_statement_rollback_14 system_stats_14 plproxy_14 plsh_14 pldebugger_14 plpgsql_check_14 pgmemcache_14 # plr_14
  257. - mysql_fdw_14 ogr_fdw_14 tds_fdw_14 sqlite_fdw_14 firebird_fdw_14 hdfs_fdw_14 mongo_fdw_14 osm_fdw_14 pgbouncer_fdw_14
  258. - hypopg_14 geoip_14 rum_14 hll_14 ip4r_14 prefix_14 pguri_14 tdigest_14 topn_14 periods_14
  259. - bgw_replstatus_14 count_distinct_14 credcheck_14 ddlx_14 extra_window_functions_14 logerrors_14 mysqlcompat_14 orafce_14
  260. - repmgr_14 pg_auth_mon_14 pg_auto_failover_14 pg_background_14 pg_bulkload_14 pg_catcheck_14 pg_comparator_14
  261. - pg_cron_14 pg_fkpart_14 pg_jobmon_14 pg_partman_14 pg_permissions_14 pg_prioritize_14 pgagent_14
  262. - pgaudit16_14 pgauditlogtofile_14 pgcryptokey_14 pgexportdoc_14 pgfincore_14 pgimportdoc_14 powa_14 pgmp_14 pgq_14
  263. - pgquarrel-0.7.0-1 pgsql_tweaks_14 pgtap_14 pgtt_14 postgresql-unit_14 postgresql_anonymizer_14 postgresql_faker_14
  264. - safeupdate_14 semver_14 set_user_14 sslutils_14 table_version_14 # pgrouting_14 osm2pgrouting_14
  265. - clang coreutils diffutils rpm-build rpm-devel rpmlint rpmdevtools bison flex # gcc gcc-c++ # - build utils - #
  266. - docker-ce docker-compose kubelet kubectl kubeadm kubernetes-cni helm # - cloud native- #
  267. - ed mlocate parted krb5-devel apr apr-util audit parquet-libs-3.0.0 arrow-libs-3.0.0 # --- deps:gpsql -- #
  268. repo_url_packages: # extra packages from url
  269. - https://github.com/Vonng/loki-rpm/releases/download/v2.5.0/loki-2.5.0.x86_64.rpm
  270. - https://github.com/Vonng/loki-rpm/releases/download/v2.5.0/promtail-2.5.0.x86_64.rpm
  271. - https://github.com/Vonng/pg_exporter/releases/download/v0.5.0/pg_exporter-0.5.0.x86_64.rpm
  272. - https://github.com/cybertec-postgresql/vip-manager/releases/download/v1.0.2/vip-manager-1.0.2-1.x86_64.rpm
  273. - https://github.com/Vonng/haproxy-rpm/releases/download/v2.5.7/haproxy-2.5.7-1.el7.x86_64.rpm
  274. - https://github.com/Vonng/pigsty-pkg/releases/download/misc/redis-6.2.7-1.el7.remi.x86_64.rpm
  275. - https://github.com/dalibo/pev2/releases/download/v0.24.0/pev2.tar.gz
  276. - https://github.com/Vonng/pigsty-pkg/releases/download/misc/polysh-0.4-1.noarch.rpm
  277. - https://github.com/greenplum-db/gpdb/releases/download/6.20.3/open-source-greenplum-db-6.20.3-rhel7-x86_64.rpm # -- gpsql --#
  278. - https://github.com/Vonng/pigsty-pkg/releases/download/misc/matrixdb-4.4.0.community-1.el7.x86_64.rpm # - matrix - #
  279. #-----------------------------------------------------------------
  280. # NAMESERVER
  281. #-----------------------------------------------------------------
  282. nameserver_enabled: false # setup dnsmasq
  283. dns_records: # dynamic dns record resolved by dnsmasq
  284. - 10.10.10.2 pg-meta # sandbox vip for pg-meta
  285. - 10.10.10.3 pg-test # sandbox vip for pg-test
  286. - 10.10.10.10 pg-meta-1 # sandbox instance pg-meta-1
  287. - 10.10.10.11 pg-test-1 # sandbox instance node-1
  288. - 10.10.10.12 pg-test-2 # sandbox instance node-2
  289. - 10.10.10.13 pg-test-3 # sandbox instance node-3
  290. #-----------------------------------------------------------------
  291. # PROMETHEUS
  292. #-----------------------------------------------------------------
  293. prometheus_enabled: true # setup prometheus
  294. prometheus_data_dir: /data/prometheus/data
  295. prometheus_options: '--storage.tsdb.retention=15d'
  296. prometheus_reload: false # reload prometheus instead of recreate it?
  297. prometheus_sd_method: static # service discovery method: static|consul
  298. prometheus_sd_interval: 5s # service discovery refresh interval
  299. prometheus_scrape_interval: 10s # global scrape & evaluation interval
  300. prometheus_scrape_timeout: 8s # scrape timeout
  301. #-----------------------------------------------------------------
  302. # EXPORTER
  303. #-----------------------------------------------------------------
  304. exporter_install: none # none|yum|binary, none by default
  305. exporter_repo_url: '' # if set, repo will be added to /etc/yum.repos.d/
  306. exporter_metrics_path: /metrics # default metric path for pg related exporter
  307. #-----------------------------------------------------------------
  308. # GRAFANA
  309. #-----------------------------------------------------------------
  310. grafana_enabled: true # enable grafana? only works on meta nodes
  311. grafana_endpoint: http://10.10.10.10:3000 # grafana endpoint url
  312. grafana_admin_username: admin # default grafana admin username
  313. grafana_admin_password: pigsty # default grafana admin password
  314. grafana_database: sqlite3 # default grafana database type: sqlite3|postgres
  315. grafana_pgurl: postgres://dbuser_grafana:DBUser.Grafana@meta:5436/grafana
  316. grafana_plugin_method: install # none|install|always, none will skip plugin install
  317. grafana_plugin_cache: /www/pigsty/plugins.tgz # path to grafana plugins cache tarball
  318. grafana_plugin_list: # plugins that will be downloaded via grafana-cli
  319. - marcusolsson-csv-datasource
  320. - marcusolsson-json-datasource
  321. - marcusolsson-treemap-panel
  322. grafana_plugin_git: # plugins that will be downloaded via git
  323. - https://github.com/Vonng/vonng-echarts-panel
  324. #-----------------------------------------------------------------
  325. # LOKI
  326. #-----------------------------------------------------------------
  327. loki_enabled: true # enable loki? only works on meta nodes
  328. loki_clean: false # whether remove existing loki data
  329. loki_endpoint: http://10.10.10.10:3100/loki/api/v1/push # where to push data
  330. loki_options: '-config.file=/etc/loki.yml -config.expand-env=true'
  331. loki_data_dir: /data/loki # default loki data dir
  332. loki_retention: 15d # log retention period
  333. #-----------------------------------------------------------------
  334. # DCS
  335. #-----------------------------------------------------------------
  336. dcs_name: pigsty # consul dc name
  337. dcs_servers: # dcs server dict in name:ip format
  338. meta-1: 10.10.10.10 # using existing external dcs cluster is recommended for HA
  339. # meta-2: 10.10.10.11 # node with ip in dcs_servers will be initialized as dcs servers
  340. # meta-3: 10.10.10.12 # it's recommend to reuse meta nodes as dcs servers if no ad hoc cluster available
  341. dcs_registry: consul # where to register services: none | consul | etcd | both
  342. dcs_safeguard: false # if true, running dcs will NOT be removed
  343. dcs_clean: true # if true, running dcs will be purged during node init, DANGEROUS
  344. #-----------------------------------------------------------------
  345. # CONSUL
  346. #-----------------------------------------------------------------
  347. consul_enabled: true # enable consul server/agent by default?
  348. consul_data_dir: /data/consul # consul data dir (/data/consul by default)
  349. #-----------------------------------------------------------------
  350. # ETCD
  351. #-----------------------------------------------------------------
  352. etcd_enabled: true # enable etcd server by default?
  353. etcd_data_dir: /data/etcd # etcd data dir (/data/etcd by default)
  354. #================================================================#
  355. # VARS: NODES #
  356. #================================================================#
  357. # global variables for nodes (including meta)
  358. #-----------------------------------------------------------------
  359. # NODE_IDENTITY
  360. #-----------------------------------------------------------------
  361. meta_node: false # node with meta_node flag will be marked as admin node
  362. # nodename: # [OPTIONAL] # node instance identity, used as `ins`, hostname by default
  363. node_cluster: nodes # [OPTIONAL] # node cluster identity, used as `cls`, 'nodes' by default
  364. nodename_overwrite: true # overwrite node's hostname with nodename?
  365. nodename_exchange: true # exchange nodename among play hosts?
  366. #-----------------------------------------------------------------
  367. # NODE_DNS
  368. #-----------------------------------------------------------------
  369. node_etc_hosts_default: # static dns records in /etc/hosts
  370. - 10.10.10.10 meta pigsty p.pigsty g.pigsty a.pigsty c.pigsty l.pigsty
  371. - 10.10.10.10 api.pigsty adm.pigsty cli.pigsty ddl.pigsty lab.pigsty git.pigsty sss.pigsty
  372. node_etc_hosts: [] # extra static dns records in /etc/hosts
  373. node_dns_method: add # add (default) | none (skip) | overwrite (remove old settings)
  374. node_dns_servers: # dynamic nameserver in /etc/resolv.conf
  375. - 10.10.10.10
  376. node_dns_options: # dns resolv options
  377. - options single-request-reopen timeout:1 rotate
  378. - domain service.consul
  379. #-----------------------------------------------------------------
  380. # NODE_REPO
  381. #-----------------------------------------------------------------
  382. node_repo_method: local # none|local: ad local repo|public: add upstream directly
  383. node_repo_remove: true # remove existing repo on nodes?
  384. node_repo_local_urls: # list local repo url, if node_repo_method = local
  385. - http://pigsty/pigsty.repo
  386. - http://pigsty/matrix.repo
  387. node_packages: [ ] # extra packages for all nodes
  388. node_packages_default: # common packages for all nodes
  389. - wget,sshpass,ntp,chrony,tuned,uuid,lz4,make,patch,bash,lsof,wget,unzip,git,ftp,vim-minimal,ca-certificates
  390. - numactl,grubby,sysstat,dstat,iotop,bind-utils,net-tools,tcpdump,socat,ipvsadm,telnet,tuned,nc,pv,jq,perf
  391. - readline,zlib,openssl,openssl-libs,openssh-clients,python3,python36-requests,node_exporter,consul,etcd,promtail
  392. node_packages_meta: # extra packages for meta nodes
  393. - grafana,prometheus2,alertmanager,loki,nginx_exporter,blackbox_exporter,pushgateway,redis,postgresql14
  394. - nginx,ansible,pgbadger,python-psycopg2,dnsmasq,coreutils,diffutils,polysh,docker-ce,docker-compose
  395. node_packages_meta_pip: jupyterlab
  396. #-----------------------------------------------------------------
  397. # NODE_TUNE
  398. #-----------------------------------------------------------------
  399. node_disable_firewall: true # disable firewall
  400. node_disable_selinux: true # disable selinux
  401. node_disable_numa: false # disable numa (node reboot required)
  402. node_disable_swap: false # disable swap, use with caution
  403. node_static_network: true # keep dns resolver settings after reboot
  404. node_disk_prefetch: false # setup disk prefetch on HDD to increase performance
  405. node_kernel_modules: [ softdog, br_netfilter, ip_vs, ip_vs_rr, ip_vs_rr, ip_vs_wrr, ip_vs_sh ]
  406. node_tune: tiny # install and activate tuned profile: none|oltp|olap|crit|tiny
  407. node_sysctl_params: { } # set additional sysctl parameters, k:v format
  408. #-----------------------------------------------------------------
  409. # NODE_ADMIN
  410. #-----------------------------------------------------------------
  411. node_data_dir: /data # main data directory
  412. node_admin_enabled: true # create a default admin user defined by `node_admin_*` ?
  413. node_admin_uid: 88 # uid and gid for this admin user
  414. node_admin_username: dba # name of this admin user, dba by default
  415. node_admin_ssh_exchange: true # exchange admin ssh key among each pgsql cluster ?
  416. node_admin_pk_current: true # add current user's ~/.ssh/id_rsa.pub to admin authorized_keys ?
  417. node_admin_pk_list: # ssh public keys to be added to admin user (REPLACE WITH YOURS!)
  418. - 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC7IMAMNavYtWwzAJajKqwdn3ar5BhvcwCnBTxxEkXhGlCO2vfgosSAQMEflfgvkiI5nM1HIFQ8KINlx1XLO7SdL5KdInG5LIJjAFh0pujS4kNCT9a5IGvSq1BrzGqhbEcwWYdju1ZPYBcJm/MG+JD0dYCh8vfrYB/cYMD0SOmNkQ== vagrant@pigsty.com'
  419. #-----------------------------------------------------------------
  420. # NODE_TIME
  421. #-----------------------------------------------------------------
  422. node_timezone: Asia/Hong_Kong # default node timezone, empty will not change
  423. node_ntp_enabled: true # enable ntp service? false will leave ntp service untouched
  424. node_ntp_service: ntp # ntp service provider: ntp|chrony
  425. node_ntp_servers: # default NTP servers
  426. - pool cn.pool.ntp.org iburst
  427. - pool pool.ntp.org iburst
  428. - pool time.pool.aliyun.com iburst
  429. - server 10.10.10.10 iburst
  430. - server ntp.tuna.tsinghua.edu.cn iburst
  431. node_crontab_overwrite: true # true will overwrite /etc/crontab, false will append crontab
  432. node_crontab: [ ] # crontab entries in /etc/crontab
  433. #-----------------------------------------------------------------
  434. # DOCKER
  435. #-----------------------------------------------------------------
  436. docker_enabled: false # enable docker on all nodes? (you can enable them on meta nodes only)
  437. docker_cgroups_driver: systemd # docker cgroup fs driver
  438. docker_registry_mirrors: [] # docker registry mirror
  439. docker_image_cache: /tmp/docker.tgz # docker images tarball to be loaded if exists
  440. #-----------------------------------------------------------------
  441. # NODE_EXPORTER
  442. #-----------------------------------------------------------------
  443. node_exporter_enabled: true # setup node_exporter on instance
  444. node_exporter_port: 9100 # default port for node exporter
  445. node_exporter_options: '--no-collector.softnet --no-collector.nvme --collector.ntp --collector.tcpstat --collector.processes'
  446. #-----------------------------------------------------------------
  447. # PROMTAIL
  448. #-----------------------------------------------------------------
  449. promtail_enabled: true # enable promtail logging collector?
  450. promtail_clean: false # remove promtail status file? false by default
  451. promtail_port: 9080 # default listen address for promtail
  452. promtail_options: '-config.file=/etc/promtail.yml -config.expand-env=true'
  453. promtail_positions: /var/log/positions.yaml # position status for promtail
  454. #================================================================#
  455. # VARS: PGSQL #
  456. #================================================================#
  457. #-----------------------------------------------------------------
  458. # PG_IDENTITY
  459. #-----------------------------------------------------------------
  460. # pg_cluster: # <CLUSTER> <REQUIRED> : pgsql cluster name
  461. # pg_role: replica # <INSTANCE> <REQUIRED> : pg role : primary, replica, offline
  462. # pg_seq: 0 # <INSTANCE> <REQUIRED> : instance seq number
  463. # pg_instances: {} # <INSTANCE> : define multiple pg instances on node, used by monly & gpsql
  464. # pg_upstream: # <INSTANCE> : replication upstream ip addr
  465. # pg_shard: # <CLUSTER> : pgsql shard name
  466. # pg_sindex: 0 # <CLUSTER> : pgsql shard index
  467. # gp_role: master # <CLUSTER> : gpsql role, master or segment
  468. pg_offline_query: false # <INSTANCE> [FLAG] set to true to enable offline query on this instance (instance level)
  469. pg_backup: false # <INSTANCE> [FLAG] store base backup on this node (instance level, reserved)
  470. pg_weight: 100 # <INSTANCE> [FLAG] default load balance weight (instance level)
  471. pg_hostname: true # [FLAG] reuse postgres identity name as node identity?
  472. pg_preflight_skip: false # [FLAG] skip preflight identity check
  473. #-----------------------------------------------------------------
  474. # PG_BUSINESS
  475. #-----------------------------------------------------------------
  476. # overwrite these variables on <CLUSTER> level
  477. pg_users: [] # business users
  478. pg_databases: [] # business databases
  479. pg_services_extra: [] # extra services
  480. pg_hba_rules_extra: [] # extra hba rules
  481. pgbouncer_hba_rules_extra: [] # extra pgbouncer hba rules
  482. # WARNING: change these in production environment!
  483. pg_admin_username: mxadmin
  484. pg_admin_password: mxadmin
  485. pg_monitor_username: mxadmin
  486. pg_monitor_password: mxadmin
  487. pg_replication_username: mxadmin
  488. pg_replication_password: mxadmin
  489. #-----------------------------------------------------------------
  490. # PG_INSTALL
  491. #-----------------------------------------------------------------
  492. pg_dbsu: postgres # os user for database, postgres by default (unwise to change it)
  493. pg_dbsu_uid: 26 # os dbsu uid and gid, 26 for default postgres users and groups
  494. pg_dbsu_sudo: limit # dbsu sudo privilege: none|limit|all|nopass, limit by default
  495. pg_dbsu_home: /var/lib/pgsql # postgresql home directory
  496. pg_dbsu_ssh_exchange: true # exchange postgres dbsu ssh key among same cluster ?
  497. pg_version: 14 # default postgresql version to be installed
  498. pgdg_repo: false # add pgdg official repo before install (in case of no local repo available)
  499. pg_add_repo: false # add postgres relate repo before install ?
  500. pg_bin_dir: /usr/pgsql/bin # postgres binary dir, default is /usr/pgsql/bin, which use /usr/pgsql -> /usr/pgsql-{ver}
  501. pg_packages: # postgresql related packages. `${pg_version} will be replaced by `pg_version`
  502. - postgresql${pg_version}* # postgresql kernel packages
  503. - postgis32_${pg_version}* # postgis
  504. - citus_${pg_version}* # citus
  505. - timescaledb-2-postgresql-${pg_version} # timescaledb
  506. - pgbouncer pg_exporter pgbadger pg_activity node_exporter consul haproxy vip-manager
  507. - patroni patroni-consul patroni-etcd python3 python3-psycopg2 python36-requests python3-etcd
  508. - python3-consul python36-urllib3 python36-idna python36-pyOpenSSL python36-cryptography
  509. pg_extensions: # postgresql extensions, `${pg_version} will be replaced by actual `pg_version`
  510. - pg_repack_${pg_version} pg_qualstats_${pg_version} pg_stat_kcache_${pg_version} pg_stat_monitor_${pg_version} wal2json_${pg_version}
  511. # - ogr_fdw${pg_version} mysql_fdw_${pg_version} redis_fdw_${pg_version} mongo_fdw${pg_version} hdfs_fdw_${pg_version}
  512. # - count_distinct${version} ddlx_${version} geoip${version} orafce${version}
  513. # - hypopg_${version} ip4r${version} jsquery_${version} logerrors_${version} periods_${version} pg_auto_failover_${version} pg_catcheck${version}
  514. # - pg_fkpart${version} pg_jobmon${version} pg_partman${version} pg_prioritize_${version} pg_track_settings${version} pgaudit15_${version}
  515. # - pgcryptokey${version} pgexportdoc${version} pgimportdoc${version} pgmemcache-${version} pgmp${version} pgq-${version} pgquarrel pgrouting_${version}
  516. # - pguint${version} pguri${version} prefix${version} safeupdate_${version} semver${version} table_version${version} tdigest${version}
  517. #-----------------------------------------------------------------
  518. # PG_BOOTSTRAP
  519. #-----------------------------------------------------------------
  520. pg_safeguard: false # true will disable pg_clean at all, even for pgsql-remove.yml
  521. pg_clean: true # true will clean running postgres during pgsql init (DANGEROUS)
  522. pg_data: /pg/data # postgres data directory (soft link)
  523. pg_fs_main: /data # primary data disk mount point /pg -> {{ pg_fs_main }}/postgres/{{ pg_instance }}
  524. pg_fs_bkup: /data/backups # backup disk mount point /pg/* -> {{ pg_fs_bkup }}/postgres/{{ pg_instance }}/*
  525. pg_dummy_filesize: 64MiB # /pg/dummy hold some disk space for emergency use
  526. pg_listen: '0.0.0.0' # postgres listen address, '0.0.0.0' (all ipv4 addr) by default
  527. pg_port: 5432 # postgres port, 5432 by default
  528. pg_localhost: /var/run/postgresql # localhost unix socket dir for connection
  529. patroni_enabled: true # if not enabled, no postgres cluster will be created
  530. patroni_mode: default # pause|default|remove
  531. pg_dcs_type: consul # which dcs to use: consul or etcd or raft
  532. pg_namespace: /pg # top level key namespace in dcs
  533. patroni_port: 8008 # default patroni port
  534. patroni_watchdog_mode: automatic # watchdog mode: off|automatic|required
  535. pg_conf: tiny.yml # pgsql template: {oltp|olap|crit|tiny}.yml
  536. pg_libs: 'timescaledb, pg_stat_statements, auto_explain' # extensions to be loaded
  537. pg_delay: 0 # apply delay for standby cluster leader
  538. pg_checksum: false # enable data checksum by default
  539. pg_encoding: UTF8 # database cluster encoding, UTF8 by default
  540. pg_locale: C # database cluster local, C by default
  541. pg_lc_collate: C # database cluster collate, C by default
  542. pg_lc_ctype: en_US.UTF8 # database character type, en_US.UTF8 by default (for i18n full-text search)
  543. pgbouncer_enabled: false # if not enabled, pgbouncer will not be created
  544. pgbouncer_port: 6432 # pgbouncer port, 6432 by default
  545. pgbouncer_poolmode: session # pooling mode: session|transaction|statement, transaction pooling by default
  546. pgbouncer_max_db_conn: 100 # max connection to single database, DO NOT set this larger than postgres max conn or db connlimit
  547. #-----------------------------------------------------------------
  548. # PG_PROVISION
  549. #-----------------------------------------------------------------
  550. pg_provision: false # whether provisioning postgres cluster
  551. pg_init: pg-init # init script for cluster template
  552. pg_default_roles:
  553. - { name: dbrole_readonly , login: false , comment: role for global read-only access } # production read-only role
  554. - { name: dbrole_readwrite , login: false , roles: [dbrole_readonly], comment: role for global read-write access } # production read-write role
  555. - { name: dbrole_offline , login: false , comment: role for restricted read-only access (offline instance) } # restricted-read-only role
  556. - { name: dbrole_admin , login: false , roles: [pg_monitor, dbrole_readwrite] , comment: role for object creation } # production DDL change role
  557. - { name: postgres , superuser: true , comment: system superuser } # system dbsu, name is designated by `pg_dbsu`
  558. - { name: dbuser_dba , superuser: true , roles: [dbrole_admin] , comment: system admin user } # admin dbsu, name is designated by `pg_admin_username`
  559. - { name: replicator , replication: true , bypassrls: true , roles: [pg_monitor, dbrole_readonly] , comment: system replicator } # replicator
  560. - { name: dbuser_monitor , roles: [pg_monitor, dbrole_readonly] , comment: system monitor user , parameters: {log_min_duration_statement: 1000 } } # monitor user
  561. - { name: dbuser_stats , password: DBUser.Stats , roles: [dbrole_offline] , comment: business offline user for offline queries and ETL } # ETL user
  562. pg_default_privileges: # - privileges - #
  563. - GRANT USAGE ON SCHEMAS TO dbrole_readonly
  564. - GRANT SELECT ON TABLES TO dbrole_readonly
  565. - GRANT SELECT ON SEQUENCES TO dbrole_readonly
  566. - GRANT EXECUTE ON FUNCTIONS TO dbrole_readonly
  567. - GRANT USAGE ON SCHEMAS TO dbrole_offline
  568. - GRANT SELECT ON TABLES TO dbrole_offline
  569. - GRANT SELECT ON SEQUENCES TO dbrole_offline
  570. - GRANT EXECUTE ON FUNCTIONS TO dbrole_offline
  571. - GRANT INSERT, UPDATE, DELETE ON TABLES TO dbrole_readwrite
  572. - GRANT USAGE, UPDATE ON SEQUENCES TO dbrole_readwrite
  573. - GRANT TRUNCATE, REFERENCES, TRIGGER ON TABLES TO dbrole_admin
  574. - GRANT CREATE ON SCHEMAS TO dbrole_admin
  575. pg_default_schemas: [ monitor ] # default schemas to be created
  576. pg_default_extensions: # default extensions to be created
  577. - { name: 'pg_stat_statements', schema: 'monitor' }
  578. - { name: 'pgstattuple', schema: 'monitor' }
  579. - { name: 'pg_qualstats', schema: 'monitor' }
  580. - { name: 'pg_buffercache', schema: 'monitor' }
  581. - { name: 'pageinspect', schema: 'monitor' }
  582. - { name: 'pg_prewarm', schema: 'monitor' }
  583. - { name: 'pg_visibility', schema: 'monitor' }
  584. - { name: 'pg_freespacemap', schema: 'monitor' }
  585. - { name: 'pg_repack', schema: 'monitor' }
  586. - name: postgres_fdw
  587. - name: file_fdw
  588. - name: btree_gist
  589. - name: btree_gin
  590. - name: pg_trgm
  591. - name: intagg
  592. - name: intarray
  593. pg_reload: true # reload postgres after hba changes
  594. pg_hba_rules: # postgres host-based authentication rules
  595. - title: allow meta node password access
  596. role: common
  597. rules:
  598. - host all all 10.10.10.10/32 md5
  599. - title: allow intranet admin password access
  600. role: common
  601. rules:
  602. - host all +dbrole_admin 10.0.0.0/8 md5
  603. - host all +dbrole_admin 172.16.0.0/12 md5
  604. - host all +dbrole_admin 192.168.0.0/16 md5
  605. - title: allow intranet password access
  606. role: common
  607. rules:
  608. - host all all 10.0.0.0/8 md5
  609. - host all all 172.16.0.0/12 md5
  610. - host all all 192.168.0.0/16 md5
  611. - title: allow local read/write (local production user via pgbouncer)
  612. role: common
  613. rules:
  614. - local all +dbrole_readonly md5
  615. - host all +dbrole_readonly 127.0.0.1/32 md5
  616. - title: allow offline query (ETL,SAGA,Interactive) on offline instance
  617. role: offline
  618. rules:
  619. - host all +dbrole_offline 10.0.0.0/8 md5
  620. - host all +dbrole_offline 172.16.0.0/12 md5
  621. - host all +dbrole_offline 192.168.0.0/16 md5
  622. pgbouncer_hba_rules: # pgbouncer host-based authentication rules
  623. - title: local password access
  624. role: common
  625. rules:
  626. - local all all md5
  627. - host all all 127.0.0.1/32 md5
  628. - title: intranet password access
  629. role: common
  630. rules:
  631. - host all all 10.0.0.0/8 md5
  632. - host all all 172.16.0.0/12 md5
  633. - host all all 192.168.0.0/16 md5
  634. #-----------------------------------------------------------------
  635. # PG_EXPORTER
  636. #-----------------------------------------------------------------
  637. pg_exporter_enabled: true # setup pg_exporter on instance
  638. pg_exporter_config: pg_exporter.yml # use fast cache exporter for demo
  639. pg_exporter_port: 9630 # pg_exporter listen port
  640. pg_exporter_params: 'sslmode=disable' # url query parameters for pg_exporter
  641. pg_exporter_url: '' # optional, overwrite auto-generate postgres connstr
  642. pg_exporter_auto_discovery: true # optional, discovery available database on target instance ?
  643. pg_exporter_exclude_database: 'template0,template1,postgres,matrixmgr' # optional, comma separated list of database that WILL NOT be monitored when auto-discovery enabled
  644. pg_exporter_include_database: '' # optional, comma separated list of database that WILL BE monitored when auto-discovery enabled, empty string will disable include mode
  645. pg_exporter_options: '--log.level=info --log.format="logger:syslog?appname=pg_exporter&local=7"'
  646. pgbouncer_exporter_enabled: false # setup pgbouncer_exporter on instance (if you don't have pgbouncer, disable it)
  647. pgbouncer_exporter_port: 9631 # pgbouncer_exporter listen port
  648. pgbouncer_exporter_url: '' # optional, overwrite auto-generate pgbouncer connstr
  649. pgbouncer_exporter_options: '--log.level=info --log.format="logger:syslog?appname=pgbouncer_exporter&local=7"'
  650. #-----------------------------------------------------------------
  651. # PG_SERVICE
  652. #-----------------------------------------------------------------
  653. pg_services: # how to expose postgres service in cluster?
  654. - name: primary # service name {{ pg_cluster }}-primary
  655. src_ip: "*"
  656. src_port: 5433
  657. dst_port: pgbouncer # 5433 route to pgbouncer
  658. check_url: /primary # primary health check, success when instance is primary
  659. selector: "[]" # select all instance as primary service candidate
  660. - name: replica # service name {{ pg_cluster }}-replica
  661. src_ip: "*"
  662. src_port: 5434
  663. dst_port: pgbouncer
  664. check_url: /read-only # read-only health check. (including primary)
  665. selector: "[]" # select all instance as replica service candidate
  666. selector_backup: "[? pg_role == `primary` || pg_role == `offline` ]"
  667. - name: default # service's actual name is {{ pg_cluster }}-default
  668. src_ip: "*" # service bind ip address, * for all, vip for cluster virtual ip address
  669. src_port: 5436 # bind port, mandatory
  670. dst_port: postgres # target port: postgres|pgbouncer|port_number , pgbouncer(6432) by default
  671. check_method: http # health check method: only http is available for now
  672. check_port: patroni # health check port: patroni|pg_exporter|port_number , patroni by default
  673. check_url: /primary # health check url path, / as default
  674. check_code: 200 # health check http code, 200 as default
  675. selector: "[]" # instance selector
  676. haproxy: # haproxy specific fields
  677. maxconn: 3000 # default front-end connection
  678. balance: roundrobin # load balance algorithm (roundrobin by default)
  679. default_server_options: 'inter 3s fastinter 1s downinter 5s rise 3 fall 3 on-marked-down shutdown-sessions slowstart 30s maxconn 3000 maxqueue 128 weight 100'
  680. - name: offline # service name {{ pg_cluster }}-offline
  681. src_ip: "*"
  682. src_port: 5438
  683. dst_port: postgres
  684. check_url: /replica # offline MUST be a replica
  685. selector: "[? pg_role == `offline` || pg_offline_query ]" # instances with pg_role == 'offline' or instance marked with 'pg_offline_query == true'
  686. selector_backup: "[? pg_role == `replica` && !pg_offline_query]" # replica are used as backup server in offline service
  687. haproxy_enabled: true # enable haproxy on this node?
  688. haproxy_reload: true # reload haproxy after config?
  689. haproxy_auth_enabled: false # enable authentication for haproxy admin?
  690. haproxy_admin_username: admin # default haproxy admin username
  691. haproxy_admin_password: pigsty # default haproxy admin password
  692. haproxy_exporter_port: 9101 # default admin/exporter port
  693. haproxy_client_timeout: 24h # client side connection timeout
  694. haproxy_server_timeout: 24h # server side connection timeout
  695. vip_mode: none # none | l2 | l4 , l4 not implemented yet
  696. vip_reload: true # reload vip after config?
  697. # vip_address: 127.0.0.1 # virtual ip address ip (l2 or l4)
  698. # vip_cidrmask: 24 # virtual ip address cidr mask (l2 only)
  699. # vip_interface: eth0 # virtual ip network interface (l2 only)
  700. # dns_mode: vip # vip|all|selector: how to resolve cluster DNS?
  701. # dns_selector: '[]' # if dns_mode == vip, filter instances been resolved
  702. ...

最后修改 2022-06-18: v1.5.1 (8de4142)