postgresql数据迁移
postgresql从库故障准备新库
1,创建用户
[root@localhost home]# userdel postgres
[root@localhost home]# groupdel postgres
mkdir /home/mydb
chown -R postgres:postgres /home/mydb
2,解压安装包
[root@localhost 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数据迁移的更多相关文章
- 一次PostgreSql数据迁移,使用nodejs来完成
2014-02-08 XX开放平台不允许使用站外的服务器了,可是我们的app都在站外,数据库也在站外,全都要求迁移到其云主机上(坑爹啊).我们在其云主机上仅有有限的资源,而且也有在运行中的数据库,要做 ...
- PostgreSQL 数据迁移
新主机PostgreSQL需要事先建立和原主机名称相同的用户和数据库. 备份原主机数据库 pg_dump -U <UserName> -p <PortNum> <DBNa ...
- postgresql 不同数据库不同模式下的数据迁移
编写不容易,转载请注明出处谢谢, 数据迁移 因为之前爬虫的时候,一部分数据并没有上传到服务器,在本地.本来用的就是postgresql,也没用多久,数据迁移的时候,也遇到了很多问题,第一次使pg_du ...
- 关于hdfs 和hive的数据迁移
1. 迁移hdfs,使用hadoop 命令 hadoop distcp -pugp hdfs://localhost:9000/ hdfs://localhost:9000/ 此处示例仅作说明用 2 ...
- 阿里云 RDS实例间的数据迁移
使用数据传输DTS可以实现两个RDS实例间的数据迁移.对于支持增量迁移的存储引擎,还可以使用DTS在源RDS实例不停服的情况下,将数据迁移到目标RDS实例.目前对于RDS不同存储引擎,只支持同构迁移( ...
- gitlab数据迁移到docker容器
需求:想把服务器上的gitlab迁移到docker容器里面注意:gitlab的迁移,必须保持gitlab的版本一致,此处使用的是:8.4.3,数据库版本和类型一致,此处使用的是postgresql 9 ...
- Neo4j ETL工具快速上手:简化从关系数据库到图数据库的数据迁移
注:本文系从https://medium.com/neo4j/tap-into-hidden-connections-translating-your-relational-data-to-graph ...
- 项目案例之GitLab的数据迁移
项目案例之GitLab的数据迁移 链接:https://pan.baidu.com/s/1CgaEv12cwfbs5RxcNpxdAg 提取码:fytm 复制这段内容后打开百度网盘手机App,操作更方 ...
- 由数据迁移至MongoDB导致的数据不一致问题及解决方案
故事背景 企业现状 2019年年初,我接到了一个神秘电话,电话那头竟然准确的说出了我的昵称:上海小胖. 我想这事情不简单,就回了句:您好,我是小胖,请问您是? "我就是刚刚加了你微信的 xx ...
随机推荐
- Robotframework框架AndroidLibrary库安装
1.Ruby官网(http://rubyinstaller.org/)下载系统对应安装包进行安装 2.Ruby官网(http://rubyinstaller.org/)下载对应DevKit,运行解压到 ...
- arp命令
地址解析协议ARP用于将IP地址解析成MAC地址.当把数据包从一个计算机发送到另一个计算机的时候,计算机或路由器使用ARP请求来确定下一跳的MAC地址. MAC地址用于按跳发送数据包,直到达到最终目的 ...
- Linux解压和打包jar
linux 中解压jarunzip XXX.jar -d app 打jar 进入到解压目录里面(app)jar cvfm0 MR-XDR-JMR-NEW.jar META-INF/MANIFEST.M ...
- final的使用
final对基本类型,限定常量. final对对象的引用,不可引用其他对象. final的字段,必须在定义时或者构造器内完成初始化.构造内才完成初始化的Blank Final(空白final). cl ...
- ThinkPHP升级指导
升级指导 http://www.kancloud.cn/manual/thinkphp5/163239 从V5.0.1升级到V5.0.2 从V5.0.1升级到V5.0.2需要注意如下事项: 下列模型属 ...
- [jv-convert] Error 1,[all-recursive] Error 1
g++4.6编译是报错: make profiledbootstrap /var/tmp/gcc4/gcc-4.0.1/sparc-sun-solaris2.8/gcc/gcj -B/var/tmp/ ...
- 解决错误 Cannot await in the body of a catch clause
解决错误 Cannot await in the body of a catch clause static async Task f() { ExceptionDispatchInfo ca ...
- REST及RESTful的实现
什么是REST? REST (REpresentation State Transfer) 描述了一个架构样式的网络系统,比如 web 应用程序.它首次出现在 2000 年 Roy Fielding ...
- 初识Android NDK
本文介绍Windows环境下搭建Android NDK开发环境,并创建一个简单的使用Native代码的Android Application. 一.环境搭建 二.JNI函数绑定 三.例子 一.环境搭建 ...
- Using Redis to store php session
Using Redis to store php session 默认情况下,php将会将session信息存储在文件系统上,在单机情况下没有问题,但是当系统负载增大,或者在对系统可用性要求很高的场景 ...