成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

PostgreSQL安裝及Streaming Replication配置詳解

數(shù)據(jù)庫(kù) 其他數(shù)據(jù)庫(kù) PostgreSQL
本文我們主要介紹了PostgreSQL安裝及Streaming Replication配置方法,希望本次的介紹能夠?qū)δ兴鶐椭?/div>

PostgreSQL安裝及Streaming Replication配置是本文我們主要要介紹的內(nèi)容,因?yàn)轫?xiàng)目需要搭建postgres環(huán)境,并要求具有一定的可靠性。所以筆者在搭建這個(gè)環(huán)境的同時(shí)把步驟及命令記錄下來(lái)的。筆者是DB2 DBA.但現(xiàn)在項(xiàng)目準(zhǔn)備從DB2遷移到postgresql. postgresql筆者也是剛剛接觸.筆者以后會(huì)把學(xué)到的關(guān)于postgresql的知識(shí),以及DB2遷移postgresql過(guò)程中遇到的問(wèn)題及經(jīng)驗(yàn)總結(jié)出來(lái),陸續(xù)整理成文檔.,然后和有同樣需求的朋友進(jìn)行交流,希望能夠?qū)δ兴鶐椭?/p>

  1. -------------------------------------------------------  
  2. >>>>>>>>>INSTALL<<<<<<<<<<<<< 
  3. --primary 10.4.5.94  
  4. --standby 10.4.5.93  
  5. --standby 10.4.5.91  
  6.  
  7. psql (PostgreSQL) 9.0.4  
  8. -------------------------------------------------------  
  9. cd /root/postgresql-9.0.4  
  10. ./configure --with-wal-segsize=32 --with-wal-blocksize=16 
  11. gmake  
  12. gmake install  
  13. adduser postgres  
  14. mkdir -p /usr/local/pgsql/data  
  15. mkdir -p /usr/local/pgsql/etc  
  16. chown postgres /usr/local/pgsql/data  
  17. chown postgres /usr/local/pgsql/etc  
  18. chown postgres /pg_data_logs  
  19. cd /pg_data_logs/  
  20. mkdir pg_xlog  
  21. chown postgres pg_xlog/  
  22. su - postgres  
  23. /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data --xlogdir=/pg_data_logs/pg_xlog  
  24. mv /usr/local/pgsql/data/*.conf /usr/local/pgsql/etc  
  25. exit (su - root)  
  26. cp /root/postgresql-9.0.4/contrib/start-scripts/linux /etc/init.d/postgresd  
  27. vi /etc/init.d/postgresd  修改如下部分,用-c config_file指定postgresql.conf的位置: 
  28. ===============================================================  
  29.   start)  
  30.         echo -n "Starting PostgreSQL: "  
  31.         test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj  
  32.         su - $PGUSER -c "$DAEMON -D '$PGDATA' -c config_file=/usr/local/pgsql/etc/postgresql.conf &" >>$PGLOG 2>&1  
  33.         echo "ok"  
  34.         ;;  
  35.   restart)  
  36.         echo -n "Restarting PostgreSQL: "  
  37.         su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"  
  38.         test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj  
  39.         su - $PGUSER -c "$DAEMON -D '$PGDATA' -c config_file=/usr/local/pgsql/etc/postgresql.conf &" >>$PGLOG 2>&1  
  40.         echo "ok"  
  41.         ;;  
  42. ===============================================================  
  43.  
  44. vi /usr/local/pgsql/etc/postgresql.conf  修改如下部分: 
  45. ===============================================================  
  46. #------------------------------------------------------------------------------  
  47. # FILE LOCATIONS  
  48. #------------------------------------------------------------------------------  
  49.  
  50. # The default values of these variables are driven from the -D command-line  
  51. # option or PGDATA environment variable, represented here as ConfigDir.  
  52.  
  53. #data_directory = 'ConfigDir'           # use data in another directory  
  54.                                         # (change requires restart)  
  55. hba_file = '/usr/local/pgsql/etc/pg_hba.conf'     # host-based authentication file  
  56.                                         # (change requires restart)  
  57. ident_file = '/usr/local/pgsql/etc/pg_ident.conf' # ident configuration file  
  58.                                         # (change requires restart)  
  59.  
  60. # If external_pid_file is not explicitly set, no extra PID file is written.  
  61. #external_pid_file = '(none)'           # write an extra PID file  
  62.                                         # (change requires restart)  
  63. ===============================================================  
  64.  
  65. /etc/init.d/postgresd start  
  66.  
  67. ------------------------------------------------------- 
  1. >>>>>>>>>Streaming Replication<<<<<<<<<<<<< 
  2. ------------------------------------------------------- 
  3. --IN ALL SERVER:  
  4. 修改訪問(wèn)控制  
  5. vi /usr/local/pgsql/etc/pg_hba.conf  
  6. ***加一行  
  7. host all all 10.4.5.0/24 password  
  8. host all all 10.4.2.0/24 password  
  9. 修改監(jiān)聽(tīng)范圍  
  10. vi /usr/local/pgsql/etc/postgresql.conf  
  11. 修改listen_addresses = ‘localhost’為listen_addresses = ‘*’,如果前面有#號(hào)則需要?jiǎng)h除#號(hào)  
  12. 重啟  
  13. /etc/init.d/postgresd restart  
  14. --IN PRIMARY SERVER:  
  15. 設(shè)置同步賬號(hào)  
  16. psql  
  17. create user repl superuser login password 'meiyoumima';  
  18. 修改訪問(wèn)控制  
  19. vi /usr/local/pgsql/etc/pg_hba.conf  
  20. ***添加以下內(nèi)容  
  21. host replication repl 10.4.5.93/32 password  
  22. host replication repl 10.4.5.91/32 password 

 

修改postgresql服務(wù)配置文件

 

  1. vi /usr/local/pgsql/etc/postgresql.conf  
  2. ####Add by paolo for replications  
  3. wal_level = hot_standby 
  4. archive_mode = on 
  5. archive_command = 'cp -i %p /pg_data_logs/archivedir/%f </dev/null' 
  6. #archive_timeout = 600 
  7. archive_timeout = 86400 
  8. max_wal_senders = 5 
  9. wal_keep_segments = 32 

 

建立歸檔目錄

mkdir -p /pg_data_logs/archivedir

重啟

/etc/init.d/postgresd restart

--IN STANDBY SERVER:

修改postgresql服務(wù)配置文件

  1. vi /usr/local/pgsql/etc/postgresql.conf  
  2. #Add by paolo for replications  
  3. wal_level = hot_standby 
  4. hot_standby = on 
  5.  
  6. vi /usr/local/pgsql/etc/recovery.conf  
  7. #Add by paolo for replications  
  8. restore_command = 'cp /pg_data_logs/archivedir/%f %p'   
  9. archive_cleanup_command = 'pg_archivecleanup /pg_data_logs/archivedir %r' 
  10. standby_mode = 'on' 
  11. primary_conninfo = 'host=10.4.5.94 port=5432 user=repl password=meiyoumima' 
  12. trigger_file = '/home/postgres/trigger_activestb' 

 

建立歸檔目錄

mkdir -p /pg_data_logs/archivedir

停止postgres

/etc/init.d/postgresd stop

刪除原數(shù)據(jù)目錄下數(shù)據(jù)文件

  1. exit (su - root)  
  2. cd /usr/local/pgsql/  
  3. rm -rf data/  
  4. mkdir data  
  5. chown postgres data  
  6. chmod -R 700 data/ 
  1. >>>>>>>>>>>>>>傳送數(shù)據(jù)文件到StandBy并啟動(dòng)集群<<<<<<<<<<<<<<<<< 
  2. --IN PRIMARY  
  3. su - postgres  
  4. psql -c "SELECT pg_start_backup('label',true);"  
  5. cd /usr/local/pgsql/  
  6. scp -r data/ postgres@10.4.5.93:/usr/local/pgsql/  
  7. scp -r data/ postgres@10.4.5.91:/usr/local/pgsql/  
  8.  
  9. --IN STANDBY  
  10. su - postgres  
  11. cd /usr/local/pgsql/data  
  12. rm postmaster.pid  
  13. ln -s /usr/local/pgsql/etc/recovery.conf recovery.conf  
  14. cd pg_xlog  
  15. mv * /pg_data_logs/archivedir/  
  16. /etc/init.d/postgresd start  
  17.  
  18. --IN PRIMARY  
  19. su - postgres  
  20. psql -c "SELECT * from pg_stop_backup();" 

 

重啟

  1. /etc/init.d/postgresd restart  
  2. -------------------------------------------------------  
  3. >>>>>>>>>pg_archivecleanup inatall<<<<<<<<<<<<< 
  4. ------------------------------------------------------- 
  5. su - root  
  6. cd postgresql-9.0.4/contrib/pg_archivecleanup/  
  7. make  
  8. make install 

 

關(guān)于PostgreSQL安裝及Streaming Replication配置就介紹到這里了,希望本次的介紹能夠?qū)δ兴斋@!

【編輯推薦】

  1. PostgreSQL數(shù)據(jù)庫(kù)中pg_hba.conf文件的使用詳解
  2. MongoDB數(shù)據(jù)庫(kù)中Update參數(shù)使用的相關(guān)知識(shí)簡(jiǎn)介
  3. SQL Server使用UNION代替OR提升查詢性能的實(shí)例
  4. Berkeley DB使用SecondKey給數(shù)據(jù)排序的實(shí)現(xiàn)方法
  5. SQL Server數(shù)據(jù)庫(kù)中FOR XML AUTO的使用詳解續(xù)
責(zé)任編輯:趙鵬 來(lái)源: ChinaUnix博客
相關(guān)推薦

2018-09-13 08:47:09

Tomcat負(fù)載均衡服務(wù)器

2017-06-06 08:31:10

Spark Strea計(jì)算模型監(jiān)控

2018-04-09 12:25:11

2010-06-13 17:07:10

Cacti使用手冊(cè)

2022-01-10 07:59:14

PostgreSQl 主從流復(fù)制歸檔配置

2024-07-08 10:48:51

2009-06-11 10:00:50

Glassfish安裝GlassFish配置

2019-10-21 13:28:38

UbuntuPostgreSQL命令

2010-06-03 13:21:46

Sendmail 配置

2009-06-19 18:19:01

2013-12-26 13:19:26

PostgreSQL優(yōu)化

2012-02-23 09:51:58

虛擬化SRM桌面虛擬化

2010-06-01 16:46:38

Rsync 命令

2009-07-17 17:34:15

JRuby On Ra

2010-09-10 20:19:34

tftp server

2009-07-09 15:58:40

Ubuntu JDK安

2023-05-18 07:58:27

2010-06-21 14:57:32

Linux apt

2010-05-31 14:47:28

Cacti配置

2023-03-17 23:08:36

PostgreSQL數(shù)據(jù)庫(kù)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)

主站蜘蛛池模板: 亚洲成人中文字幕 | 亚洲激情在线观看 | 亚洲第一天堂无码专区 | 久久精品一区二区三区四区 | 91久久久久久久久 | 性色综合 | 激情五月综合网 | 99久久免费精品 | 久久中文视频 | 日韩视频高清 | 操操日| 欧美成视频 | 国产精品久久久久久 | 国产乱码精品一区二区三区中文 | 亚洲v日韩v综合v精品v | 黄色国产 | 亚洲精品久久久久中文字幕二区 | 黄网站色大毛片 | 九九热精品在线视频 | 精品精品视频 | 在线免费观看欧美 | 天堂视频一区 | 久久久精品高清 | 国产一级片 | 黄色一级电影免费观看 | 日韩视频在线一区 | 91视频免费视频 | 欧美看片 | 日韩视频精品在线 | 欧美亚洲综合久久 | 日韩一区二区福利视频 | 免费观看一级特黄欧美大片 | 嫩草视频网 | 国产精品自拍一区 | 99精品免费| 成年人在线视频 | 国产区第一页 | 一区二区三区四区在线视频 | 九九久久在线看 | 91欧美精品成人综合在线观看 | 久久综合久色欧美综合狠狠 |