PostgreSQL 8.4 和 9.3
Posted
技术标签:
【中文标题】PostgreSQL 8.4 和 9.3【英文标题】:postgreSQL 8.4 and 9.3 【发布时间】:2018-12-28 22:00:08 【问题描述】:我在将数据库备份 pg8.4 (.dump) 恢复到 pg9.3 时遇到了一些问题
当我将 8.4 恢复到 9.2 时它工作正常,但由于某种原因在 9.3 中不起作用
设置如下:
Centos 6 pg8.4
Centos 7 pg9.2
Centos 7 pg9.3
所有服务器都自带Plesk,pg9.2通过Plesk安装,9.3来自官方site
所有服务器也使用 Postgis(9.2 和 9.3 中的 2.1.8 和 8.4 中的旧版本)
我尝试通过Pgadmin和终端恢复dump文件,9.2和9.3有什么区别,为什么我不能恢复数据?
可能是因为9.2的数据文件夹在/var/lib/pgsql/data
,如果通过官方网站安装在/var/lib/pgsql/9.3/data
?
这些是我遇到的一些错误:
pg_restore: creating SEQUENCE OWNED BY "public.mordersl_ogc_fid_seq"
pg_restore: creating TABLE "public.mordersp"
pg_restore: [archiver (db)] Error from TOC entry 160; 1259 18553 TABLE mordersp postgres
pg_restore: [archiver (db)] could not execute query: ERROR: relation "mordersp" already exists
Command was: CREATE TABLE mordersp (
ogc_fid integer NOT NULL,
wkb_geometry geometry(Geometry,27700),
item_ref numeric(254,0)...
pg_restore: creating SEQUENCE "public.mordersp_ogc_fid_seq"
pg_restore: [archiver (db)] Error from TOC entry 159; 1259 18551 SEQUENCE mordersp_ogc_fid_seq postgres
pg_restore: [archiver (db)] could not execute query: ERROR: relation "mordersp_ogc_fid_seq" already exists
Command was: CREATE SEQUENCE mordersp_ogc_fid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
pg_restore: creating SEQUENCE OWNED BY "public.docstore_ogc_fid_seq"
pg_restore: creating VIEW "public.geography_columns"
pg_restore: [archiver (db)] Error from TOC entry 143; 1259 17626 VIEW geography_columns postgres
pg_restore: [archiver (db)] could not execute query: ERROR: relation "geography_columns" already exists
Command was: CREATE VIEW geography_columns AS
SELECT current_database() AS f_table_catalog, n.nspname AS f_table_schema, c.relname AS f_t...
pg_restore: creating VIEW "public.geometry_columns"
pg_restore: [archiver (db)] Error from TOC entry 144; 1259 17730 VIEW geometry_columns postgres
pg_restore: [archiver (db)] could not execute query: ERROR: relation "geometry_columns" already exists
Command was: CREATE VIEW geometry_columns AS
SELECT (current_database())::character varying(256) AS f_table_catalog, (n.nspname)::charact...
pg_restore: creating TABLE "public.mapscheds"
pg_restore: [archiver (db)] Error from TOC entry 154; 1259 18517 TABLE mapscheds postgres
pg_restore: [archiver (db)] could not execute query: ERROR: relation "mapscheds" already exists
Command was: CREATE TABLE mapscheds (
ogc_fid integer NOT NULL,
wkb_geometry geometry(Geometry,27700),
msid numeric(254,0),
...
pg_restore: creating SEQUENCE "public.mapscheds_ogc_fid_seq"
pg_restore: [archiver (db)] Error from TOC entry 153; 1259 18515 SEQUENCE mapscheds_ogc_fid_seq postgres
pg_restore: [archiver (db)] could not execute query: ERROR: relation "mapscheds_ogc_fid_seq" already exists
Command was: CREATE SEQUENCE mapscheds_ogc_fid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
pg_restore: creating SEQUENCE OWNED BY "public.mapscheds_ogc_fid_seq"
pg_restore: creating TABLE "public.mapschedsback"
pg_restore: [archiver (db)] Error from TOC entry 165; 1259 191782 TABLE mapschedsback postgres
pg_restore: [archiver (db)] could not execute query: ERROR: relation "mapschedsback" already exists
Command was: CREATE TABLE mapschedsback (
ogc_fid integer,
wkb_geometry geometry(Geometry,27700),
msid numeric(254,0),
ms...
pg_restore: creating TABLE "public.minv"
pg_restore: [archiver (db)] Error from TOC entry 156; 1259 18529 TABLE minv postgres
pg_restore: [archiver (db)] could not execute query: ERROR: relation "minv" already exists
Command was: CREATE TABLE minv (
ogc_fid integer NOT NULL,
wkb_geometry geometry(Geometry,27700),
item_ref numeric(254,0),
...
pg_restore: creating SEQUENCE "public.minv_ogc_fid_seq"
pg_restore: [archiver (db)] Error from TOC entry 155; 1259 18527 SEQUENCE minv_ogc_fid_seq postgres
pg_restore: [archiver (db)] could not execute query: ERROR: relation "minv_ogc_fid_seq" already exists
Command was: CREATE SEQUENCE minv_ogc_fid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
我在创建表之前和之后尝试在不创建表的情况下进行还原。
这是脚本的一部分:
-- Table: ordersl
-- DROP TABLE ordersl;
CREATE TABLE ordersl
(
ogc_fid serial NOT NULL,
wkb_geometry geometry(Geometry,27700),
item_ref numeric(254,0),
order_ref character varying(32),
locality character varying(30),
....
pm_id numeric(254,0),
order_id numeric(254,0),
order_doc character varying(254),
ms_grid character varying(20),
CONSTRAINT ordersl_pk PRIMARY KEY (ogc_fid)
)
WITH (
OIDS=FALSE
);
ALTER TABLE ordersl
OWNER TO postgres;
-- Index: ordersl_geom_idx
-- DROP INDEX ordersl_geom_idx;
CREATE INDEX ordersl_geom_idx
ON ordersl
USING gist
(wkb_geometry);
【问题讨论】:
你是如何恢复的,到底是什么问题?有什么具体的错误信息吗? 我已经更新了问题 【参考方案1】:没错,这是意料之中的。
您必须使用 9.3 中的 pg_dump
可执行文件转储 8.4 数据库。
9.3 知道如何转储 8.4 数据库,以便在 9.3 中加载转储。
【讨论】:
在我有 PG8.4 的服务器上我没有 PG9.3,我是说另一个有 PG9.2 的服务器中的 8.4 备份有效,而在 9.3 没有 您的描述有点混乱,如果我弄错了,请见谅。底线是:如果你想用 9.3 恢复,你必须用 9.3 转储。这是支持的方式。如果发生其他任何事情,你很幸运。 好吧..我告诉你,我可以将使用 8.4 创建的 8.4 转储恢复到 9.2,并且 2 个数据库位于 2 个不同的服务器中,其中一个我只有 8.4,另一个只有9.2。pg_dump
是复古兼容的,所以应该可以工作。证明是在 9.2 中有效。问题是 9.3 我不明白为什么不起作用
如果 8.4 转储恢复到 9.2,那么您很幸运。 pg_dump
按您的想法不向后兼容。相信我或在文档中查找。预计 8.4 转储不会恢复到 9.3。
幸运与否,我可以恢复任何我想要的东西,我想我要把 8.4 恢复到 9.2,然后备份 9.2 并将其恢复到 9.3.. .这有点工作,但似乎是唯一的方法以上是关于PostgreSQL 8.4 和 9.3的主要内容,如果未能解决你的问题,请参考以下文章
UISearchController 的 SearchBar 在激活时位于状态栏下方(ios 9.3,ios 8.4)
Postgresql 8.4 和 BitDefender 11
如何屏蔽 json 字段中的选定值 - Postgresql 9.3 和 PDI
PostgreSQL 8.4 将所有表的 DML 权限授予一个角色
没有运算符与给定名称和参数类型匹配。您可能需要添加显式类型转换。 -- Netbeans、Postgresql 8.4 和 Glassfish