【PostgreSQL】数据库复制
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了【PostgreSQL】数据库复制,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4199字,纯文字阅读大概需要6分钟。
内容图文
![【PostgreSQL】数据库复制](/upload/InfoBanner/zyjiaocheng/914/a76d01ffd1e348e0b90cdc109ed13ff0.jpg)
[postgres@king01 ~]$ cd /var/lib/pgsql/9.6/data [postgres@king01 data]$ vi pg_hba.conf host replication postgres 192.168.1.0/24 md5 [postgres@king01 data]$ vi postgresql.conf listen_addresses = '0.0.0.0' max_wal_senders = 5 wal_level = hot_standby [postgres@king01 data]$ pg_ctl restart waiting for server to shut down.... done server stopped server starting [root@king02 ~]# wget https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-centos96-9.6-3.noarch.rpm --no-check-certificate [root@king02 ~]# rpm -ivh pgdg-centos96-9.6-3.noarch.rpm [root@king02 ~]# useradd postgres [root@king02 ~]# id postgres uid=500(postgres) gid=500(postgres) groups=500(postgres) [root@king02 ~]# rpm -e postgresql postgresql-devel [root@king02 ~]# yum install -y postgresql96-server.x86_64 postgresql96-contrib.x86_64 [root@king02 ~]# vi /etc/profile PATH=$PATH:/usr/pgsql-9.6/bin export PGDATA=/var/lib/pgsql/9.6/data [root@king02 ~]# su - postgres [postgres@king02 ~]$ pg_basebackup -h 192.168.1.201 -U postgres -F p -P -x -R -D /var/lib/pgsql/9.6/data Password: 2161085/2161085 kB (100%), 1/1 tablespace [postgres@king02 ~]$ cd /var/lib/pgsql/9.6/data [postgres@king02 data]$ ls -l total 124 -rw------- 1 postgres postgres 208 Apr 14 18:26 backup_label drwx------ 6 postgres postgres 4096 Apr 14 18:28 base drwx------ 2 postgres postgres 4096 Apr 14 18:28 global drwx------ 2 postgres postgres 4096 Apr 14 18:26 pg_clog drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_commit_ts drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_dynshmem -rw------- 1 postgres postgres 4290 Apr 14 18:28 pg_hba.conf -rw------- 1 postgres postgres 1636 Apr 14 18:28 pg_ident.conf drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_log drwx------ 4 postgres postgres 4096 Apr 14 18:28 pg_logical drwx------ 4 postgres postgres 4096 Apr 14 18:28 pg_multixact drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_notify drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_replslot drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_serial drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_snapshots drwx------ 2 postgres postgres 4096 Apr 14 18:26 pg_stat drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_stat_tmp drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_subtrans drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_tblspc drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_twophase -rw------- 1 postgres postgres 4 Apr 14 18:28 PG_VERSION drwx------ 3 postgres postgres 4096 Apr 14 18:28 pg_xlog -rw------- 1 postgres postgres 88 Apr 14 18:26 postgresql.auto.conf -rw------- 1 postgres postgres 22369 Apr 14 18:28 postgresql.conf -rw-rw-r-- 1 postgres postgres 154 Apr 14 18:28 recovery.conf [postgres@king02 data]$ cat recovery.conf standby_mode = 'on' primary_conninfo = 'user=postgres password=postgres host=192.168.1.201 port=5432 sslmode=disable sslcompression=1 krbsrvname=postgres' [postgres@king02 data]$ vi postgresql.conf hot_standby = on [postgres@king02 ~]$ pg_ctl start server starting [postgres@king01 ~]$ psql psql (9.6.12) Type "help" for help. postgres=# select pid,state,client_addr,sync_priority,sync_state from pg_stat_replication; pid | state | client_addr | sync_priority | sync_state ------+-----------+---------------+---------------+------------ 2055 | streaming | 192.168.1.202 | 0 | async (1 row) postgres=# select pg_xlog_location_diff(pg_current_xlog_location(),replay_location) from pg_stat_replication; pg_xlog_location_diff ----------------------- 0 (1 row) postgres=# select pg_is_in_recovery(); pg_is_in_recovery ------------------- f (1 row) [postgres@king02 ~]$ psql psql (9.6.12) Type "help" for help. postgres=# select pg_is_in_recovery(); pg_is_in_recovery ------------------- t (1 row) postgres=# select pg_last_xlog_receive_location(),pg_last_xlog_replay_location(),pg_last_xact_replay_timestamp(); pg_last_xlog_receive_location | pg_last_xlog_replay_location | pg_last_xact_replay_timestamp -------------------------------+------------------------------+------------------------------- 0/4A001800 | 0/4A001800 | (1 row)
内容总结
以上是互联网集市为您收集整理的【PostgreSQL】数据库复制全部内容,希望文章能够帮你解决【PostgreSQL】数据库复制所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。