oracle 数据库迁移

 

########################################################################################

查看源数据库字符集

 select * from nls_database_parameters;

 会查到例如下面的内容

 NLS_CHARACTERSET

 ZHS16GBK 

########################################################################################


在源库中导出数据(备份)

根据上面查到的字符集,进行对数据库按用户进行全量备份:

在备份前需要设点字符集

export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

echo $NLS_LANG

对数据库进行备份:

exp OMS_lvnain01/OMS_lvnain01 owner=OMS_lvnain01 file=/home/oracle/gaotest/OMS_lvnain01.dmp

exp OMS_lvnain02/OMS_lvnain02 owner=OMS_lvnain02 file=/home/oracle/gaotest/OMS_lvnain02.dmp

exp OMS_lvnain03/OMS_lvnain03 owner=OMS_lvnain03 file=/home/oracle/gaotest/OMS_lvnain03.dmp


exp PORTAL_lvnain01/PORTAL_lvnain01 owner=PORTAL_lvnain01 file=/home/oracle/gaotest/PORTAL_lvnain01.dmp

exp PORTAL_lvnain02/PORTAL_lvnain02 owner=PORTAL_lvnain02 file=/home/oracle/gaotest/PORTAL_lvnain02.dmp

exp PORTAL_lvnain03/PORTAL_lvnain03 owner=PORTAL_lvnain03 file=/home/oracle/gaotest/PORTAL_lvnain03.dmp


########################################################################################

备份完源库的数据后,需要用下面命令查看源库的表空间。之后再到新服务器上面创建对于的表空间!

select name,status from v$datafile;

########################################################################################

把导出的备份数据传送到迁移的新服务器上

cd /home/oracle/gaotest/

scp -P 6022 ./*  [email protected]:/data/oracle/gaotest/oms  


cd cd /home/oracle/gaotest/

scp -P 6022 ./*  [email protected]:/data/oracle/gaotest/portal 


########################################################################################

########################################################################################


在新的服务器上创建数据库表空间,用户的等

1.OMS_lvnain01(数据文件大小2G)

create tablespace OMS_lvnain01 logging  datafile '/data/oracle/app/oracle/OMS_lvnain01.dbf' size 2000m autoextend on next 2000m maxsize unlimited;                                          ##这个表结构的OMS_lvnain01.dbf被我删除,但是内存不变

create user OMS_lvnain01 identified by OMS_lvnain01 default tablespace OMS_lvnain01;

grant connect,resource,dba to OMS_lvnain01;

==========

#drop tablespace OMS_lvnain01;


2. OMS_lvnain02(数据文件大小5G)

create tablespace OMS_lvnain02 logging  datafile '/data/oracle/app/oradata/OMS_lvnain02.dbf' size 5000m autoextend on next 5000m maxsize unlimited;

create user OMS_lvnain02 identified by OMS_lvnain02 default tablespace OMS_lvnain02;

grant connect,resource,dba to OMS_lvnain02;

==========

3.OMS_lvnain03(数据文件大小6G)

create tablespace OMS_lvnain03 logging  datafile '/data/oracle/app/oradata/OMS_lvnain03.dbf' size 6000m autoextend on next 6000m maxsize unlimited;

create user OMS_lvnain03 identified by OMS_lvnain03 default tablespace OMS_lvnain03;

grant connect,resource,dba to OMS_lvnain03;

#drop tablespace OMS_lvnain03;

==========

4.PORTAL_lvnain01(数据文件大小4G)

create tablespace PORTAL_lvnain01 logging  datafile '/data/oracle/app/oradata/PORTAL_lvnain01.dbf' size 4000m autoextend on next 4000m maxsize unlimited;

create user PORTAL_lvnain01 identified by PORTAL_lvnain01 default tablespace PORTAL_lvnain01;

grant connect,resource,dba to PORTAL_lvnain01;

==========

5.PORTAL_lvnain02(数据文件大小2G)

create tablespace PORTAL_lvnain02 logging  datafile '/data/oracle/app/oradata/PORTAL_lvnain02.dbf' size 5000m autoextend on next 5000m maxsize unlimited;

create user PORTAL_lvnain02 identified by PORTAL_lvnain02 default tablespace PORTAL_lvnain02;

grant connect,resource,dba to PORTAL_lvnain02;

==========

6.PORTAL_lvnain03(数据文件大小2G)

create tablespace PORTAL_lvnain03 logging  datafile '/data/oracle/app/oradata/PORTAL_lvnain03.dbf' size 5000m autoextend on next 5000m maxsize unlimited;

create user PORTAL_lvnain03 identified by PORTAL_lvnain03 default tablespace PORTAL_lvnain03;

grant connect,resource,dba to PORTAL_lvnain03;

########################################################################################

########################################################################################


往新服务器中导入数据

在导入数据之前,同样要设点字符集,字符集肯定要和备份时候设定的字符集一样:

export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

echo $NLS_LANG

开始导入数据

imp OMS_lvnain01/OMS_lvnain01 fromuser=OMS_lvnain01 touser=OMS_lvnain01 buffer=150009081 commit=y file=/data/oracle/gaotest/oms/OMS_lvnain01.dmp ignore=y

imp OMS_lvnain02/OMS_lvnain02 fromuser=OMS_lvnain02 touser=OMS_lvnain02 buffer=150009081 commit=y file=/data/oracle/gaotest/oms/OMS_lvnain02.dmp ignore=y

imp OMS_lvnain03/OMS_lvnain03 fromuser=OMS_lvnain03 touser=OMS_lvnain03 buffer=150009081 commit=y file=/data/oracle/gaotest/oms/OMS_lvnain03.dmp ignore=y

==============================

imp PORTAL_lvnain01/PORTAL_lvnain01 fromuser=PORTAL_lvnain01 touser=PORTAL_lvnain01 buffer=150009081 commit=y file=/data/oracle/gaotest/portal/PORTAL_lvnain01.dmp ignore=y

imp PORTAL_lvnain02/PORTAL_lvnain02 fromuser=PORTAL_lvnain02 touser=PORTAL_lvnain02  buffer=150009081 commit=y file=/data/oracle/gaotest/portal/PORTAL_lvnain02.dbf ignore=y

imp PORTAL_lvnain03/PORTAL_lvnain03 fromuser=PORTAL_lvnain03 touser=PORTAL_lvnain03  buffer=150009081 commit=y file=/data/oracle/gaotest/portal/PORTAL_lvnain03.dmp  ignore=y

########################################################################################

上面命令中,只有 select 命令是在登录oracle数据库,进行的操作,其他的都是在linux的oracle用户下的shell环境中进行的

########################################################################################


你可能感兴趣的:(oracle)