postgresql資料移轉

來源:互聯網
上載者:User

標籤:

postgresql從庫故障準備新庫

1,建立使用者
[[email protected] home]# userdel postgres
[[email protected] home]# groupdel postgres

mkdir /home/mydb
chown -R postgres:postgres /home/mydb
2,解壓安裝包
[[email protected] home]## tar -xvf postgres/postgresql-8.1.4.tar

cd postgres/postgresql-8.1.4
編譯安裝: ./configure --prefix=/usr/local/pgsql -localstatedir=/home/mydb

$ ./configure --prefix=/usr/local/pgsql --with-pgconfigdir=/usr/local/pgsql/bin/ --with-pgbindir=/usr/local/pgsql/bin/ --with-pgincludedir=/usr/local/pgsql
/include/ --with-pgincludeserverdir=/usr/local/pgsql/include/server/ --with-pglibdir=/usr/local/pgsql/lib/ --with-pgpkglibdir=/usr/local/pgsql/lib/ --with-pgsharedir=/usr/local/pgsql/share/
make

All of PostgreSQL successfully made. Ready to install


su - postgres

vi .bash_profile

PATH=$PATH:$HOME/bin:/usr/local/pgsql/bin

 

/usr/local/pgsql/bin/initdb /home/mydb


/usr/local/pgsql/bin/pg_ctl -D /home/mydb star

 

3.slony安裝

tar -xvf slony1-1.2.6.tar

su - root

./configure --with-pgsourcetree=/usr/local/pgsql/bin

$ ./configure --prefix=/usr/local/pgsql --with-pgconfigdir=/usr/local/pgsql/bin/ --with-pgbindir=/usr/local/pgsql/bin/ --with-pgincludedir=/usr/local/pgsql
/include/ --with-pgincludeserverdir=/usr/local/pgsql/include/server/ --with-pglibdir=/usr/local/pgsql/lib/ --with-pgpkglibdir=/usr/local/pgsql/lib/ --with-pgsharedir=/usr/local/pgsql/share/

 

3.主庫資料備份

 /usr/local/pgsql/bin/pg_dumpall > /home/mydb/backup/`date ‘+%Y%m%d‘`_dumpall.sql

4.新庫恢複

psql -f /home/mydb/backup/`date ‘+%Y%m%d‘`_dumpall.sql

 

發現報錯:

psql:20150611_dumpall.sql:406: ERROR: could not access file "$libdir/dblink": No such file or directory
psql:20150611_dumpall.sql:409: ERROR: function public.dblink(text, text) does not exist
psql:20150611_dumpall.sql:417: ERROR: could not access file "$libdir/dblink": No such file or directory
psql:20150611_dumpall.sql:420: ERROR: function public.dblink(text, text, boolean) does not exist
psql:20150611_dumpall.sql:428: ERROR: could not access file "$libdir/dblink": No such file or directory
psql:20150611_dumpall.sql:431: ERROR: function public.dblink(text) does not exist
psql:20150611_dumpall.sql:439: ERROR: could not access file "$libdir/dblink": No such file or directory
psql:20150611_dumpall.sql:442: ERROR: function public.dblink(text, boolean) does not exist
psql:20150611_dumpall.sql:450: ERROR: could not access file "$libdir/dblink": No such file or directory
psql:20150611_dumpall.sql:453: ERROR: function public.dblink_build_sql_delete(text, int2vector, integer, text[]) does not exist
psql:20150611_dumpall.sql:461: ERROR: could not access file "$libdir/dblink": No such file or directory
psql:20150611_dumpall.sql:464: ERROR: function public.dblink_build_sql_insert(text, int2vector, integer, text[], text[]) does not exist
psql:20150611_dumpall.sql:472: ERROR: could not access file "$libdir/dblink": No such file or directory
psql:20150611_dumpall.sql:475: ERROR: function public.dblink_build_sql_update(text, int2vector, integer, text[], text[]) does not exist
psql:20150611_dumpall.sql:483: ERROR: could not access file "$libdir/dblink": No such file or directory
psql:20150611_dumpall.sql:486: ERROR: function public.dblink_close(text) does not exist

報錯原因是資料庫中用到預存程序,預存程序用到dblink

配置安裝dblink(擴充)

cd /home/postgres/postgresql-8.1.4/contrib
make

make install

再恢複沒問題了。

5.舊從庫上的指令碼以及slon指令檔都移到新庫上來,修改IP為從庫IP

postgresql資料移轉

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.