概述
公司有一套业务系统需要在实体服务器上迁移至虚拟化上面,本次是对迁移过程进行记录。
环境
原环境:ORACLE LINUX + ORACLE 11GR2
新环境:CENTOS7 + ORACLE 11GR2
老业务系统数据库备份
1. 查看数据库版本(新环境数据库需要与老环境数据库版本一致)
1 |
1 2 3 4 5 6 7 8 9 |
SQL> select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production PL/SQL Release 11.2.0.4.0 - Production CORE 11.2.0.4.0 Production TNS for Linux: Version 11.2.0.4.0 - Production NLSRTL Version 11.2.0.4.0 - Production |
2. 查看字符集(非常重要,需要将新的ORACLE服务器环境与老环境字符集保持一致,否则会出现乱码等错误)
1 |
1 2 3 4 5 |
SQL> select userenv('language') from dual; USERENV('LANGUAGE') ---------------------------------------------------- AMERICAN_AMERICA.ZHS16GBK |
3. 查看用户表空间(将在新环境里面创建相同的表空间)
1 |
1 |
select default_tablespace from dba_users where username='USER'; |
4. 查看表空间下有哪些用户(将在新环境里面创建相同的用户名)
1 |
1 |
select distinct s.owner from dba_segments s where s.tablespace_name ='USER_DATA'; |
5. 创建备份目录
1 |
create directory expdp as '/u01/expdp'; |
7. 备份目录授权
1 |
Grant read,write on directory expdp to USER; |
6. 备份原数据库(此处使用exp工具进行导出)
1 2 3 4 |
导出数据库(全库导出) expdp USER/PASSWORD@ORCL directory=backup full=y dumpfile=BACKUP.dmp logfile=BACKUP.log; 导出数据库(按用户导出) expdp USER/PASSWORD@ORCL schemas=USER directory=backup dumpfile=BACKUP.dmp logfile=BACKUP.log; |
新系统环境配置
1. 安装JDK
1 |
1 |
rpm -ivh jdk-8u241-linux-x64.rpm |
2. 安装ORACLE(注意安装时的字符集设置)
详见:oracle 11gR2 for Linux 静默安装
3. 安装TOMCAT
略。
4. 创建临时表空间
1 |
1 |
create temporary tablespace USER_TEMP tempfile '/Project/DB/USER_TEMP.DBF' size 200m autoextend on next 100m maxsize 20480m extent management local; |
5. 创建表空间
1 |
1 |
create tablespace USER DATAFILE '/Project/DB/USER.DBF' size 200m autoextend on next 100m maxsize 20480m extent management local; |
6. 创建用户并指定表空间
1 |
1 |
create user USER identified by PASSWORD default tablespace USER temporary tablespace USER_TEMP; |
7. 用户授权
1 |
1 |
grant connect,resource,dba to USER; |
8. 创建备份目录
1 |
create directory expdp as '/u01/expdp'; |
9. 备份目录授权
1 |
Grant read,write on directory expdp to USER; |
10. 数据库还原
1 2 3 4 |
导入数据库(全库导入) impdp USER/PASSWORD dumpfile=BACKUP.dmp full=y logfile=BACKUP.log directory=back 导入数据库(按用户导入) impdp USER/PASSWORD schemas=USER directory=back dumpfile=BACKUP.dmp |