这里涉及到三个oracle对象,一个是客户的视图,一个是客户提供的中转站服务器上的oracle,一个是我们自己的开发机的oracle,最终我们开发使用自己开发机的oracle的数据来进行开发,开发完成后,将oracle源改为客户的视图源,将产品部署到客户提供的中转站上。并且中转站的oracle也已经不再需要,可以停掉,实际上web产品部署在另外一个节点,这个中转站提供计算处理程序的居住场所。下面介绍我接入开发数据的具体步骤,我是按表的形式进行导入导出,并且用到的是oracle的数据泵。
验证是否能够连接,假设用户密码都是xsc,远端ip是192.168.2.2,实例端口9010,实例名orcltyg
扫描实例端口: nmap 远端ip
sqlplus "xsc"/"xsc"@192.168.2.2:9010/orcltyg
本机静默安装oracle11g(略)
本机创建表空间和oracle用户,假设用户为xsc,数据表空间为xsc,temp表空间xsctemp
create temporary tablespace xsctemp tempfile '/opt/oracle/oradata/orcl/xsctemp.dbf' size 1000m autoextend on next 1000m maxsize unlimited extent management local;
createtablespacexscloggingdatafile'/opt/oracle/oradata/orcl/xsc.dbf'size1000mautoextendonnext1000mmaxsizeunlimitedextentmanagementlocalautoallocate segmentspacemanagementauto;
createuserxscidentifiedbyxscdefaulttablespacexsctemporarytablespacexsctemp;
grantconnect,resource,dbatoxsc;
创建到远端192.168.2.2的dblink
create database link orcltyglink connect to xsc identified by "xsc" using '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.2)(PORT = 9010)) (CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = ORCLTYG)))';
select * from xsjl@orcltyglink;
通过dblink连接远端视图选取数据创建本地的表xsjl
create table xsjl as select * from xsjl@orcltyglink;
选取一行来看
select * from xsjl whererownum<=1;
把它备份出来,并用ftp工具下载
mkdir /backup
chown -R oracle.oinstall /backup/
sqlplus / as sysdba
create or replace directory dir as '/backup/';
grant write,read on directory dir to xsc;
quit
nohup expdp xsc/xsc@orcl tables=xsjl dumpfile=xsjl.dmp logfile=xsjl.log directory=dir job_name=xsjl_job &
通过ftp或者sz下载,然后上传到开发的oracle主机上
还原到开发机的oracle中
sqlplus / as sysdba
create temporary tablespace xsctemp tempfile '/u01/app/oracle/oradata/consume/xsctemp.dbf' size 1000m autoextend on next 1000m maxsize unlimited extent management local;
createtablespacexscloggingdatafile'/u01/app/oracle/oradata/consume/xsc.dbf'sqlplus / as sysdba
create or replace directory dir as '/u01/backup/';
grant write,read on directory dir to xsc;
quit
cd /u01/backup
rz [xsjl.dmp]
nohup impdp xsc/xsc dumpfile=xsjl.dmp logfile=xsjl.log directory=dir tables=xsjl job_name=xsjl_job &
验证
select * from xsjl whererownum<=1;