Home Database Mysql Tutorial Oracle单实例数据库迁移到OracleRAC环境之--数据导出导入

Oracle单实例数据库迁移到OracleRAC环境之--数据导出导入

Jun 07, 2016 pm 02:52 PM
oracle Example database

Oracle单实例数据库迁移到Oracle RAC环境之--数据导出导入 系统环境: 操作系统:RedHat EL55 Oracle : Oracle 11.2.0.1.0 集群软件:Oracle GI 11.2.0.1.0 本案例采用的是通过数据的导入导出(EXPDP/IMPDP)的迁移方式 650) this.width=650;" src="http://w

Oracle单实例数据库迁移到Oracle RAC环境之--数据导出导入

系统环境:

操作系统:RedHat EL55

Oracle : Oracle 11.2.0.1.0

集群软件:Oracle GI 11.2.0.1.0

本案例采用的是通过数据的导入导出(EXPDP/IMPDP)的迁移方式

wKioL1N9ovKhMVJ1AAGFVMkanCc961.jpg


   从单实例的库迁移数据到RAC环境,可以有多种方式,通过数据的导出和导入也可以,但前提是数据库采用相同的字符集。

1、数据库环境

单实例

17:35:59 SYS@ test1>SELECT * FROM V$VERSION;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
Elapsed: 00:00:00.02
Copy after login


17:35:36 SYS@ test1>select userenv('LANGUAGE') FROM DUAL;

USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.ZHS16GBK
Copy after login
Copy after login

RAC 环境:

17:46:03 SYS@ prod1>SELECT * FROM V$VERSION;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
Elapsed: 00:00:00.16
Copy after login

17:46:29 SYS@ prod1>select instance_name,status from gv$instance;

INSTANCE_NAME    STATUS
---------------- ------------
prod1            OPEN
prod2            OPEN
Copy after login

17:45:40 SYS@ prod1>select userenv('LANGUAGE') FROM DUAL;

USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.ZHS16GBK
Copy after login
Copy after login

2、建立测试环境

单实例:

17:38:26 SYS@ test1>create tablespace test01

17:41:40 2 datafile '/dsk1/oradata/test1/test01.dbf' size 100m;

Tablespace created.

17:43:49 SYS@ test1>create user test1 identified by test1

17:44:00 2 default tablespace test01

17:44:00 3 temporary tablespace tmpgp1

17:44:00 4 quota unlimited on test01

17:44:00 5 account unlock;

17:44:00 SYS@ test1>grant connect ,resource to test1;

Grant succeeded.

17:50:34 SYS@ test1>conn test1/test1

Connected.

17:50:41 TEST1@ test1>create table testtb1 tablespace test01 as select * from scott.emp;

Table created.

Elapsed: 00:00:00.25

17:50:52 TEST1@ test1>create index test_empno_ind on testtb1(empno) tablespace indx;

Index created.

Elapsed: 00:00:00.05

如果做表空间传输,需要对表空间做自包含检测:


17:51:15 SYS@ test1>EXECUTE DBMS_TTS.TRANSPORT_SET_CHECK('test01', TRUE);

PL/SQL procedure successfully completed.

Elapsed: 00:01:04.07

17:52:25 SYS@ test1>SELECT * FROM TRANSPORT_SET_VIOLATIONS;

no rows selected

Elapsed: 00:00:00.05

创建导出传输目录:

17:52:43 SYS@ test1>create directory exp_dir as '/home/oracle/exp';

Directory created.

Elapsed: 00:00:00.07

17:53:24 SYS@ test1>grant read,write on directory exp_dir to test1;

Grant succeeded.

Elapsed: 00:00:00.06

17:53:39 SYS@ test1>!mkdir ~/exp


导出schema:

[oracle@rh6 exp]$ expdp test1/test1 directory=exp_dir dumpfile=test.dmp logfile=test.log schemas=test1

Export: Release 11.2.0.1.0 - Production on Thu Jul 10 17:59:05 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "TEST1"."SYS_EXPORT_SCHEMA_02":  test1/******** directory=exp_dir dumpfile=test.dmp logfile=test.log schemas=test1 
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 256 KB
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
. . exported "TEST1"."SYS_EXPORT_SCHEMA_01"              139.4 KB    1073 rows
. . exported "TEST1"."TESTTB1"                           8.570 KB      14 rows
Master table "TEST1"."SYS_EXPORT_SCHEMA_02" successfully loaded/unloaded
******************************************************************************
Dump file set for TEST1.SYS_EXPORT_SCHEMA_02 is:
  /home/oracle/exp/test.dmp
Job "TEST1"."SYS_EXPORT_SCHEMA_02" successfully completed at 17:59:28
Copy after login
Copy after login


3、在RAC环境下导入数据:

从单实例传输dump文件到RAC环境下


[oracle@rh6 exp]$ scp *.dmp 192.168.8.21:/u01/exp

The authenticity of host '192.168.8.21 (192.168.8.21)' can't be established.
RSA key fingerprint is 39:04:88:3b:54:34:3c:34:d2:df:74:37:fe:5f:92:2d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.8.21' (RSA) to the list of known hosts.
oracle@192.168.8.21's password: 
test.dmp                                                                                 100%  428KB 428.0KB/s   00:00
Copy after login

在RAC下建立表空间和Schema:

18:16:28 SYS@ prod1>create tablespace test01;
Tablespace created.
Elapsed: 00:00:06.27
18:19:19 SYS@ prod1>create tablespace indx;
Tablespace created.
Elapsed: 00:00:05.81
18:19:36 SYS@ prod1>select file_name,file_id,tablespace_name,bytes/1024/1024 from dba_data_files;
FILE_NAME                                             FILE_ID TABLESPACE_NAME                BYTES/1024/1024
-------------------------------------------------- ---------- ---------------------------
+DG1/prod/datafile/users.259.852387481                      4 USERS                                        5
+DG1/prod/datafile/undotbs1.258.852292707                   3 UNDOTBS1                                   105
+DG1/prod/datafile/sysaux.257.852292707                     2 SYSAUX                                     630
+DG1/prod/datafile/system.256.852292703                     1 SYSTEM                                     690
+DG1/prod/datafile/example.264.852292891                    5 EXAMPLE                                103.125
+DG1/prod/datafile/undotbs2.265.852293259                   6 UNDOTBS2                                    50
+DG1/prod/datafile/tbs1.269.852376681                       7 TBS1                                       100
+DG1/prod/datafile/test01.273.852574753                     8 TEST01                                     100
+DG1/prod/datafile/indx.274.852574771                       9 INDX                                       100
9 rows selected.
Copy after login
18:14:34 SYS@ prod1>create user test1 identified by test1
18:14:49   2      default tablespace users
18:14:49   3      temporary tablespace temp
18:14:49   4     quota unlimited on  users
18:14:49   5    account unlock;
User created.
Elapsed: 00:00:00.15
18:14:50 SYS@ prod1>
18:14:50 SYS@ prod1>grant connect,resource to test1;
Grant succeeded.
Copy after login

建立数据导入目录

18:15:31 SYS@ prod1>create directory imp_dir as '/u01/exp';
Directory created.
18:16:08 SYS@ prod1>grant read,write on directory imp_dir to test1;
Grant succeeded.
Elapsed: 00:00:00.16
[root@node1 ~]# mkdir -p /u01/exp
[root@node1 ~]# chown -R oracle:dba /u01/exp
Copy after login

导入数据:


[root@node1 ~]# su - oracle

[oracle@node1 ~]$ cd /u01/exp

[oracle@node1 exp]$ ls

test.dmp

[oracle@node1 exp]$ impdp test1/test1 directory=imp_dir dumpfile=test.dmp logfile=test.log schemas=test1

Import: Release 11.2.0.1.0 - Production on Thu Jul 10 18:21:05 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Master table "TEST1"."SYS_IMPORT_SCHEMA_01" successfully loaded/unloaded
Starting "TEST1"."SYS_IMPORT_SCHEMA_01":  test1/******** directory=imp_dir dumpfile=test.dmp logfile=test.log schemas=test1 
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "TEST1"."SYS_EXPORT_SCHEMA_01"              139.4 KB    1073 rows
. . imported "TEST1"."TESTTB1"                           8.570 KB      14 rows
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Job "TEST1"."SYS_IMPORT_SCHEMA_01" successfully completed at 18:21:42
Copy after login

数据导入成功!


4、验证:

18:19:45 SYS@ prod1>conn test1/test1
Connected.
18:22:20 TEST1@ prod1>select * from tab;
TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
SYS_EXPORT_SCHEMA_01           TABLE
TESTTB1                        TABLE
Elapsed: 00:00:00.08
18:22:24 TEST1@ prod1>select * from testtb1;
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7369 SMITH      CLERK           7902 17-DEC-80        800                    20
      7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
      7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
      7566 JONES      MANAGER         7839 02-APR-81       2975                    20
      7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
      7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
      7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
      7788 SCOTT      ANALYST         7566 19-APR-87       3000                    40
      7839 KING       PRESIDENT            17-NOV-81       5000                    10
      7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
      7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
      7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
14 rows selected.
Elapsed: 00:00:00.02
18:22:34 TEST1@ prod1>
17:47:08 SYS@ prod2>conn test1/test1
Connected.
18:22:54 TEST1@ prod2>select * from testtb1;
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7369 SMITH      CLERK           7902 17-DEC-80        800                    20
      7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
      7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
      7566 JONES      MANAGER         7839 02-APR-81       2975                    20
      7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
      7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
      7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
      7788 SCOTT      ANALYST         7566 19-APR-87       3000                    40
      7839 KING       PRESIDENT            17-NOV-81       5000                    10
      7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
      7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
      7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
14 rows selected.
Elapsed: 00:00:00.31
Copy after login

数据导入错误案例:

错误(1):

[oracle@rh6 ~]$ expdp test1/test1 directory=exp_dir dumpfile=~/exp/test.dmp logfile=~/exp/test.log schemas=test1

Export: Release 11.2.0.1.0 - Production on Thu Jul 10 17:55:21 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORA-39002: invalid operation

ORA-39070: Unable to open the log file.

ORA-39088: file name cannot contain a path specification

在dumpfile和logfile指定的参数不能指定路径!

错误(2):

[oracle@rh6 ~]$ cd exp

[oracle@rh6 exp]$ expdp test1/test1 directory=exp_dir dumpfile=test.dmp logfile=test.log schemas=test1

Export: Release 11.2.0.1.0 - Production on Thu Jul 10 17:56:19 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Starting "TEST1"."SYS_EXPORT_SCHEMA_01": test1/******** directory=exp_dir dumpfile=test.dmp logfile=test.log schemas=test1

Estimate in progress using BLOCKS method...

Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 64 KB

Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA

Processing object type SCHEMA_EXPORT/TABLE/TABLE

Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX

Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT

Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

Processing object type SCHEMA_EXPORT/TABLE/COMMENT

UDE-04031: operation generated ORACLE error 4031

ORA-04031: unable to allocate 32 bytes of shared memory ("shared pool","SELECT job_id FROM v$datapum...","SQLA","tmp")

ORA-06512: at "SYS.KUPV$FT_INT", line 2904

ORA-06512: at "SYS.KUPC$QUE_INT", line 572

ORA-25254: time-out in LISTEN while waiting for a message

ORA-06512: at "SYS.DBMS_DATAPUMP", line 3263

ORA-06512: at "SYS.DBMS_DATAPUMP", line 4488

ORA-06512: at line 1

出现了ORA-04031错误,应该和share pool 有关系!


查看系统共享池

17:57:59 SYS@ test1>show parameter shared

NAME                                 TYPE                             VALUE
------------------------------------ -------------------------------- -------------------
hi_shared_memory_address             integer                          0
max_shared_servers                   integer
shared_memory_address                integer                          0
shared_pool_reserved_size            big integer                      12M
shared_pool_size                     big integer                      112M
shared_server_sessions               integer
shared_servers                       integer                          0
Copy after login

调整share pool的size:

17:58:01 SYS@ test1>alter system set shared_pool_size=200m ;

System altered.

Elapsed: 00:00:00.65

调整后重新导出成功:

[oracle@rh6 exp]$ expdp test1/test1 directory=exp_dir dumpfile=test.dmp logfile=test.log schemas=test1

Export: Release 11.2.0.1.0 - Production on Thu Jul 10 17:59:05 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "TEST1"."SYS_EXPORT_SCHEMA_02":  test1/******** directory=exp_dir dumpfile=test.dmp logfile=test.log schemas=test1 
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 256 KB
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
. . exported "TEST1"."SYS_EXPORT_SCHEMA_01"              139.4 KB    1073 rows
. . exported "TEST1"."TESTTB1"                           8.570 KB      14 rows
Master table "TEST1"."SYS_EXPORT_SCHEMA_02" successfully loaded/unloaded
******************************************************************************
Dump file set for TEST1.SYS_EXPORT_SCHEMA_02 is:
  /home/oracle/exp/test.dmp
Job "TEST1"."SYS_EXPORT_SCHEMA_02" successfully completed at 17:59:28
Copy after login
Copy after login


@至此,数据迁移完成!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1662
14
PHP Tutorial
1261
29
C# Tutorial
1234
24
MySQL: An Introduction to the World's Most Popular Database MySQL: An Introduction to the World's Most Popular Database Apr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

Why Use MySQL? Benefits and Advantages Why Use MySQL? Benefits and Advantages Apr 12, 2025 am 12:17 AM

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

How to create cursors in oracle loop How to create cursors in oracle loop Apr 12, 2025 am 06:18 AM

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

What to do if the oracle log is full What to do if the oracle log is full Apr 12, 2025 am 06:09 AM

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.

What steps are required to configure CentOS in HDFS What steps are required to configure CentOS in HDFS Apr 14, 2025 pm 06:42 PM

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

Oracle's Role in the Business World Oracle's Role in the Business World Apr 23, 2025 am 12:01 AM

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

MySQL vs. Other Databases: Comparing the Options MySQL vs. Other Databases: Comparing the Options Apr 15, 2025 am 12:08 AM

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.

How to stop oracle database How to stop oracle database Apr 12, 2025 am 06:12 AM

To stop an Oracle database, perform the following steps: 1. Connect to the database; 2. Shutdown immediately; 3. Shutdown abort completely.

See all articles