環境遷移之Oracle資料庫遷移

2021-08-29 04:02:09 字數 1781 閱讀 2492

因環境公升級變更,現需要將舊的開發測試環境中的資料遷移到新的開發環境中。以下是本次資料遷移工作的過程記錄。

第一步:連線登入舊的資料庫環境,檢視業務使用者的預設表空間是哪些。

select username, default_tablespace from dba_users where username in ('opn_sys', 'opn_rpt', 'opn_int');
第二步:查詢資料檔案占用大小和使用大小。

select 

b.file_id 檔案id號,

b.tablespace_name 表空間名,

b.bytes/1024/1024||'m'位元組數,

(b.bytes-sum(nvl(a.bytes,0)))/1024/1024||'m' 已使用,

sum(nvl(a.bytes,0))/1024/1024||'m' 剩餘空間,

100 - sum(nvl(a.bytes,0))/(b.bytes)*100 占用百分比

from dba_free_space a,dba_data_files b

where a.file_id=b.file_id and b.tablespace_name = 'data_opn'

group by b.tablespace_name,b.file_id,b.bytes

order by b.file_id;

第三步:連線登入新環境,檢視資料檔案路徑。

select tablespace_name, file_id,file_name, 

round(bytes/(1024*1024),0) total_space from dba_data_files

where tablespace_name = 'data_opn'

order by tablespace_name;

第四步:在新環境建立表空間。

第五步:逐個建立業務使用者

--建立使用者名為opn_sys密碼為!qaz2wsx,預設表空間為data_opn的資料庫業務使用者

create user opn_sys identified by "!qaz2wsx" default tablespace data_opn;

第六步:給業務使用者授權

grant resource, connect, create session, create view, create sequence, create synonym to opn_sys;
第七步:匯出資料

//匯出遠端伺服器的資料

[oracle@dxh-redhat6 crsdump]$ exp opn_sys/\[email protected]:1521/opendb file=/home/oracle/crsdump/opn_sys_20181016.dmp

第八步:匯入資料

//在本機上匯入資料

[oracle@dxh-redhat6 crsdump]$ imp opn_sys/\!qaz2wsx@orcl file=/home/oracle/crsdump/opn_sys_20181016.dmp full=y

備註:資料匯入過程可能需要dba許可權,此時可以通過以下命令給普通使用者授予dba許可權

grant dba, connect, resource to opn_sys;

Oracle資料庫遷移之物理遷移

oracle資料庫遷移有多種,今天先從物理遷移實驗做起。物理遷移比較簡單,但是要求兩個庫的版本必須一樣,且必須事先記錄要遷移的庫的sid 歸檔模式 資料檔案 日誌檔案 控制檔案 引數檔案和密碼檔案。遷移過程大致分為以下四步 1 用遷移的引數檔案啟庫到nomount狀態。資料庫預設情況下是用 orac...

Oracle資料庫的備份 遷庫

oracle資料庫有三種常用的備份方法,分別是匯出 匯入 exp imp 或者使用資料幫浦方法 impdp expdp 熱備份和冷備份。匯出 匯入備份是一種邏輯備份,相對於匯出 匯入來說,熱備份 冷備份是一種物理備份 一 exp 我們知道採用direct path可以提高匯出速度。所以,在使用exp...

怎麼遷mysql資料庫 MySQL資料庫遷移

mysql資料庫遷移 資料檔案直接遷移 在遷移之前有三種方案 1.資料庫直接匯出,拷貝檔案到新伺服器,在新伺服器上匯入。2.使用 mysql gui tools 中的 mysqlmigrationtool。3.資料檔案和庫表結構檔案直接拷貝到新伺服器,掛載到同樣配置的mysql服務下。我在我的電腦上...