Oracle 11G database migration [expdp / impdp]

Transfer from: http: //www.th7.cn/db/Oracle/201802/263773.shtml

0x01 environment 

A machine, operating system CentOS7.3, Oracle version: 11G, IP address: 192.168.1.11B machines, operating systems CentOS7.3, Oracle version: 11G, IP address: 192.168.1.12

 

A machine to migrate the database from machine A to machine B Oracle listener SID: orcl, account: the CINRAD, password: *, tablespace name: CINRAD_DATA, tablespace file size: a total of 10 files, each initial size 1OG, automatic growth, growth 100M, the maximum size of 30G, the data table space is about 120G

 

B Machine Oracle listener SID: orcl


0x02 migration 
1. Log A machine dba Oracle database 
sqlplus / as sysdba2. Create a database export directory 

Contents can be customized. If the system is empty, the directory is created manually, and give 777


SQL> create directory dumpdir as '/ data / oracle / dump';. 3 gives Oracle users read and write access to the exported directory 
SQL> grant write, read on directory dumpdir to CINRAD;. 4 using data derived expdp 

Enter the Linux command line, Oracle login account, use the Export tool to export all the data expdp CINRAD under the [user can use parallel multi-parameter file export paraller] while single file export:


expdp CINRAD/cinrad@orcl directory=dumpdir dumpfile=cinrad.dump

Parallel multi-file export:


the CINRAD the expdp / CINRAD @ = ORCL Directory DUMPDIR the dumpfile = filesize cinrad_20180204_% U.dump paraller = 500M = 5
// = filesize 500M largest single file 500M
// 5 = the number of parallel paraller 5

Here, I export a single file below to export a single file, for example, continues.


5. Export file transfer 

A machine of the leads to the dump file to the machine B / data / oracle / dump directory


scp /data/oracle/dump/cinrad.dump [email protected]:/data/oracle/dump/cinrad.dump
scp /data/oracle/dump/export.log [email protected]:/data/oracle/dump/export.log

It can also be transmitted together after two export file compression


6. Log B dba machine Oracle database 
sqlplus / as sysdba 7. A machine created in the same data table space 
Create TABLESPACE CINRAD_DATA datafile '/share/database/oracle/cinrad01.dbf' ON AUTOEXTEND size 1OG Next 100Mmaxsize 30G;
ALTER CINRAD_DATA the Add datafile TABLESPACE '/share/database/oracle/cinrad02.dbf' Next size 1OG AUTOEXTEND ON MAXSIZE 100M 30G;
ALTER TABLESPACE CINRAD_DATA the Add datafile '/share/database/oracle/cinrad03.dbf' Next size 1OG AUTOEXTEND ON MAXSIZE 100M 30G ;
ALTER TABLESPACE CINRAD_DATA the Add datafile '/share/database/oracle/cinrad04.dbf' Next size 1OG AUTOEXTEND ON MAXSIZE 100M 30G;
ALTER TABLESPACE CINRAD_DATA the Add datafile '/share/database/oracle/cinrad05.dbf' ON Next 100M size 1OG AUTOEXTEND maxsize 30G;
alter tablespace CINRAD_DATA add datafile '/share/database/oracle/cinrad06.dbf' size 10G autoextend on next 100M maxsize 30G;
alter tablespace CINRAD_DATA add datafile '/share/database/oracle/cinrad07.dbf' size 10G autoextend on next 100M maxsize 30G;
alter tablespace CINRAD_DATA add datafile '/share/database/oracle/cinrad08.dbf' size 10G autoextend on next 100M maxsize 30G;
alter tablespace CINRAD_DATA add datafile '/share/database/oracle/cinrad09.dbf' size 10G autoextend on next 100M maxsize 30G;
alter tablespace CINRAD_DATA add datafile '/share/database/oracle/cinrad10.dbf' size 10G autoextend on next 100M maxsize 30G;

Create a data table space, and add data files to the tablespace


8. Create users and specify the default table space 

Create A user of the machine is the same, the table assigned to the table space user CINRAD_DATA


SQL> CINRAD the CREATE the USER IDENTIFIED BY cinrad the DEFAULT TABLESPACE CINRAD_DATA
// IDENTIFIED BY cinrad this cinrad for the password, you can replace
// DEFAULT TABLESPACE CINRAD_DATACINRAD_DATA specified default table space 9. Authorization 

Oracle user B after the corresponding machine is created, to the corresponding database operations required permissions for the user, or the same as A with all rights conferred directly


SQL> Grant privileges to CINRAD All
// username CINRAD 10. Creating an import directory 

Create the import directory on the B machine, and grant permission to the 777 directory, create the directory in Oracle


SQL> create directory dumpdir as '/ data / oracle / dump';. 11 granted introduced Oracle user directory readable and writable 
SQL> grant write, read on directory dumpdir to CINRAD;. 12 to import data using impdp 

Enter the Linux command line, Oracle login account, using an export tool to import data impdp


impdp system/oracle@orcl directory=dumpdir dumpfile=cinrad.dump parallel=10

The export from the beginning 22:00 pm, the end of the next day 01:13:58, takes too long, need to be optimized. The main index for the efficiency of import, import log annex. Import Options:

table_exists_action: skip if the table already exists, skip and the next object; append data to increase table; truncate table is cut off, and give it to add new data; replace the existing table is deleted, re-built table and append data 13. check the migrated data 
0x03 error 

If not encountered an error, you can ignore, optimization of 0x04


1. being given expdp / impdp tool 
1. Oracle software and database mismatch error: 

Problem Description:


ORA-31626: job does not exist 
ORA-31637: cannot create job SYS_EXPORT_SCHEMA_01 for user SYSTEM 
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95 
ORA-00942:table or view does not exist

solution:

DBA users log on using the Oracle database 
? Execute the following code SQL> @ / the RDBMS / ADMIN / catalog.sql
? SQL> @ / the RDBMS / ADMIN / catproc.sql 
[problems follow this library: EXP-00056: ORACLE error 932 encountered], You can continue to execute SQL> @? / the RDBMS / ADMIN / catmetx.sql 
SQL> @? / the RDBMS / ADMIN / utlrp.sql2. restart Oracle database error 
1. the database is not closed properly and locked memory problems 

Problem Description: Perform the database shutdown immediate closure of the database, incorrect report:


ORA-27102: out of memory
Linux Error: 12: Cannot allocate memory

View Linux virtual memory / dev / shm of occupancy [command: df -hT], found that more than 90% occupied, the memory has been locked can not be released

 

solution:

In Linux execute ps -ef | grep oracle, oracle view pid conducted 
using kill -9 {pid} way Oracle will kill the process 
using the Oracle DBA to log 
database 3. Data import process error startup launched 
1. DB_LINK creation fails, Insufficient permissions 

Problem Description: import, import DB_LINK tips, insufficient privileges solution: give the user DBA privileges or permissions to all


2. DB_LINKE creation failed, missing keywords 

Problem Description:


Failure to sql:
the CREATE DATABASE LINK "ASOM" the CONNECT the TO "ASOM" IDENTIFIED BY VALUES '05535CD93437C21A745CE9EB530617B269'AUTHENTICATED BY "ASOM" IDENTIFIED BY VALUES' 0506C0E222927A938BF9F44DCB31C2038D'USING '10 .36.6.55: 1521 / orcl '
ORA-00905: missing keyword

Solution: to be resolved, manually create the temporary import is complete.


3. The user does not exist 

Problem Description:


Processing the object type SCHEMA_EXPORT / TABLE / GRANT / OWNER_GRANT / OBJECT_GRANT
ORA-39083: Object type OBJECT_GRANT creation failed with error:
ORA-01917: User or role 'CINRAD_META' does not exist
failed sql is:
. GRANT the SELECT ON "CINRAD" " STA_RADAR "the tO" CINRAD_META "
ORA-39083: Object type OBJECT_GRANT creation failed with error:
ORA-01 917: user or role 'CINRAD_META' does not exist
failed sql is:
GRANT the SELECT ON". "" CINRAD TEST_STA_RADAR "the tO" CINRAD_META "

Solution: If the data in the user data there that you want to import, and then create the user re-import, if there is no data you want to import, then you can ignore.


4. The view of the presence of compiler warnings 

Problem Description:


ORA-39082: object type VIEW:. "CINRAD" "V_AWS_OBSERVE_DATA " has been created, but with a compiler warning
ORA-39082: object type VIEW:. "CINRAD" "V_SONDE_OBSERVE_DATA " has been created, but with a compiler warning
ORA-39082: Object type VIEW:. "CINRAD" "V_FLASHLIGHT_OBSERV_DATA_HIS " has been created, but with a compiler warning
ORA-39082: object type VIEW:. "CINRAD" "V_STA_AWS_REG " has been created, but with a compiler warning
ORA-39082: Object type VIEW: . "CINRAD" "V_AWS_OBSERVE_REG" has been created, but with a compiler warning
ORA-39082: object type VIEW:. "CINRAD" "V_EVA_THUNDER_EFF " has been created, but with a compiler warning
ORA-39082: Object type VIEW: "CINRAD". "V_EVA_THUNDER_OUTSIDE" has been created, but with a compiler warning
ORA-39082: object type VIEW:. "CINRAD" "V_EVA_THUNDER_UTILIZATION " has been created, but with a compiler warning
ORA-39082: object type VIEW:. "CINRAD" "V_EVA_THUNDER_PARTAKE " has create,But with a compiler warning
ORA-39082: Object Type VIEW: "CINRAD" "V_EVA_THUNDER_LOCATEMODE" has been created, but with a compiler warnings.
ORA-39082: object type PACKAGE_BODY:. "CINRAD" "GP_DISPATCHER" has been created, but with a compiler warnings

Solution: Use PLSQL connect to the database, right-click the view, edit, enter, can be solved.


0x04 optimization 
1. Oracle memory optimization 

Assuming the server memory 32G


1. Check for Oracle virtual memory [/ dev / shm] size, execute the command df -hT 

tmpfs tmpfs 16G 2.1G 14G 14% / dev / shm This physical memory is typically a server memory 50% to 80%, if the reader account for almost proportion was about 50% [16G], if a larger proportion of the write it is appropriate to increase the size of virtual memory


2. Use the DBA login database, memory size on the setting in the View the Oracle 
SQL> Show the Parameter MEM;

See memory_max_target and memory_target value, which must be less than equal to the size of the server virtual memory settings [16G] and greater than SGA + PGA memory size. If memory_max_target and memory_targety set too small, you need to adjust.


3. Modify the Oracle memory size] [memory_max_target and memory_targety DBA login to the Oracle database 
executes the statement: SQL> shutdown immediate closure of the database 
to execute a statement: SQL> create pfile from spfile; 
Editing pfile file: Linux under execution, vim $ ORACLE_HOME / dbs / initorcl.ora adjustment memory_max_target memory_target, two values are the same adjustment value of the adjustment .pga_aggregate_target .sga_target adjustment principle: / dev / shm virtual memory> = [memory_max_target / memory_target]> = sga_target + pga_aggregate_target

If there is no adjustment in accordance with this principle, it will report the following error:


ORA-00838: Specified value of MEMORY_TARGET  is too small, needs to be at least 4016M ORA-00845: MEMORY_TARGET not supported on this system
executes the statement: SQL> startup, start the database archiving mode 2. Close View archive mode is enabled, execute the statement : SQL> select name, log_mode from v $ database; if the return is NOARCHIVELOG, the archive mode is turned off. 
Alter database noarchivelog; if not take effect, restart the database can see the effects 3. Change the maximum number of connections: If the archive mode is turned on, the statement is executed 

The maximum number of connections is adjusted to 2000

See processes and sessions parameter SQL> show parameter processesSQL> show parameter  sessions
modified processesSQL> alter system set processes = 2000  scope = spfile;
modified sessionsSQL> alter system set sessions = 2000 scope = spfile; 4. Close in the monitoring log 

Modify the file $ ORACLE_HOME / network / admin / listener.ora added at the top of the file: LOGGING_LISTENER = OFF save and exit

 

Restart lsnrctl: Run


lsnrctl stop 
lsnrctl start

Reproduced in: https: //www.cnblogs.com/sharpest/p/11052140.html

Guess you like

Origin blog.csdn.net/weixin_34275734/article/details/93191536