PostgreSQL 流复制配置方法.docx
《PostgreSQL 流复制配置方法.docx》由会员分享,可在线阅读,更多相关《PostgreSQL 流复制配置方法.docx(12页珍藏版)》请在三一办公上搜索。
1、背景:在两个或多个部署了Postgresql数据库上,进行配置流豆制.或基于原来的流良制架构进行犷展备用节点.出现问题可进行手动切换主库.环境如下:Postgresql版本为11.7master172.16.1.11主库slave172.16.1.12备库建汉:数据库服务器之间配背ntp进行时间定期(加到定期任务crontab-e)同步,否则可能会导致数据异常。一、搭建master服务器主库master1、修改master服务器PgJba.conf,添加如下TYPEDATABASEUSERADDRESSMETHOD表示允许任意网段的用户通过MD5进行认证连接hostallall0.0.0.0/
2、0mdS表示允许该网段172.16.1.0的repl用户进行流豆制hostreplicationrepl172.16.1.0/0trusthostreplicationall:1/128trustlocalallalltrusthostallall127.1/32trusthostallall:1/128trustlocalreplicationalltrusthostreplicationall127.1/32trusthostreplicationall:1/128trusthostallall172.16.l.md51rtO11terddtA/pmtgr.rootmasterpostgr
3、esql#catpghba.confgrep-EvFf2root$lave*修改master服务器postgresqlconf参数配置如下,为注释listen.addresses=*port=5432ma.connections=2000SUPerUSejreSerVed.connections=10wa1.evel=logicalfu1.page.writes=onWa1.log_hints=offarchive.mode=onarchive.Command=bintruemax_Wa1.SenderS-50hot.standby=onIog.destination=,csvlogloggi
4、ng_collector=onlog_directory=log,log_filename=,postgresql-%Y-%m-%d-%H%M%Slog_rOtatior1.age=Idlog,OtatiOn_SiZe=IOMBIog.statement=,modroot0masterpostgresql#catpostgresql.cofgrep-EvF#(change#(change#(change#(changerequiresrequiresrequiresrequiresrestart)restart)restart)restart)listenaddresses=#whatIPad
5、dress(es)tolistenon;#comma-separatedlistofaddr#defaultstoIocalhosf;usemaxconnections=26#(change#(change#(change#(change#(change#(changerequiresrequiresrequiresrequiresrequiresrequiresrestart)restart)restart)restart)restart)restart)sharedbuffers=128b#selects#selects#selects#min128kBthethethesystemdef
6、aultsystemdefaultsystemdefault(changerequiresrestart)dynamicsharedmemorytype=posix(changerequiresrestart)(changerequiresrestart)thedefaultisthefirstoptsupportedbytheoperatingsPoStgreSMASTERpg_ctl-Ddatapostgresqlstartwaitingforservertostart.2020-09-1815:00:21.403CST96091.OG:listeningonIPv4address0.0.
7、0.0,port54322020-09-1815:00:21.403CST96091.OG:listeningonIPv6address,port54322020-09-1815:00:21.405CST96091.OG:listeningonUnixsocketVtmp/.s.PGSQ1.5432-2020-09-1815:00:21.412CST96091.OG:redirectinglogoutputtologgingcollectorprocess2020-09-1815:00:21.412CST9609HINT:Futurelogoutputwillappearindirectory
8、-log.doneserverstarted2rootslave-1rtC,maste11datapostgr-rootmasterpostgresql#servicepostgresqldstatuspgctl:serverisrunning(PID:54426)usrlocalpostgresqlbinpostgresDdatapostgresqlrootmasterpostgresql#postgres=#A1.TERUSERpostgresWITHPASSWORDpSSwOrd;A1.TERRO1.Epostgres=#CREATEUSERreplWITHPASSWORDpsSWord
9、REP1.ICATION;CREATERO1.Epostgres=#du1.fKrlRolenameAttributesMemberofpostgresSuperuser,Createrole,CreateDB,Replication,BypassR1.SreplIReplication创建使用的测试数据库pgpool和表pgpoolpostgres=#CREATEDATABASEpgpool;CREATEDATABASEpostgres=#cpgpoolYouarenowconnectedtodatabasepgpoolasuserpostgres.pgpool=#pgpool=#CREAT
10、ETAB1.Epgpool(idserial,agebigint,insertTimetimestampdefaultnow();CREATETAB1.Epgpool=#insertintopgpool(age)values(1);INSERT01pgpool=#select*frompgpool;idIageinserttime1I1I2020-09-1815:07:03.329849(1row)查看数据库是否为主库f表示为主库postgres=#select*frompg_is_in_recovery();pg_is_in_recovery(1row)至此master服务器主库搭建完毕二、
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- PostgreSQL 流复制配置方法 复制 配置 方法
链接地址:https://www.31ppt.com/p-7185144.html