Legato Networker備份Oracle

it_newbalance發表於2013-06-25
Oracle module install and uninstall
1 我們已經在備份伺服器上建立了一個catalog庫,具體的操作過程如下:

1)查詢現在的資料庫
# sqlplus /nolog
SQL*Plus: Release 9.2.0.1.0 - Production on Wed Dec 3 23:41:33 2003
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL>; connect / as sysdba;
Connected.
SQL>; select * from v$tablespace;
TS# NAME INC
---------- ------------------------------ ---
0 SYSTEM YES
1 UNDOTBS1 YES
2 TEMP YES
3 CWMLITE YES
4 INDX YES
5 TOOLS YES
6 USERS YES
7 XDB YES
8 rows selected.
SQL>; sellect name,bytes,status from v$datafile;
NAME-------------------------BYTES STATUS---------- -------
/oracle/product/9.2.0.1/oradata/legato/system01.dbf 5242880 SYSTEM
/oracle/oradata/legato/system01.dbf 262144000 SYSTEM
/oracle/product/9.2.0.1/oradata/legato/undotbs01.dbf 5242880 ONLINE
NAME-------------------------- BYTES STATUS---------- -------
/oracle/oradata/legato/undotbs01.dbf 209715200 ONLINE
/oracle/product/9.2.0.1/oradata/legato/cwmlite01.dbf 5242880 ONLINE
/oracle/oradata/legato/cwmlite01.dbf 20971520 ONLINE
NAME--------------------------------------BYTES STATUS- -------
/oracle/product/9.2.0.1/oradata/legato/indx01.dbf 5242880 ONLINE
/oracle/oradata/legato/indx01.dbf 26214400 ONLINE
/oracle/product/9.2.0.1/oradata/legato/tools01.dbf 5242880 ONLINE
NAME------------------------------- BYTES STATUS------- -------
/oracle/oradata/legato/tools01.dbf 10485760 ONLINE
/oracle/product/9.2.0.1/oradata/legato/users01.dbf 5242880 ONLINE
/oracle/oradata/legato/users01.dbf 26214400 ONLINE
NAME--------------------------------BYTES STATUS---------- -------
/oracle/product/9.2.0.1/oradata/legato/xdb01.dbf 5242880 ONLINE
/oracle/oradata/legato/xdb01.dbf 20971520 ONLINE
14 rows selected.

SQL>; select INSTANCE_NAME,HOST_NAME,VERSION from v$instance;

INSTANCE_NAME----------------HOST_NAME-------------VERSION-----------------
legato
l2000a
9.2.0.1.0

SQL>; select username from dba_users;
USERNAME------------------------------
SYS
SYSTEM
DBSNMP
OUTLN
OLAPSYS
WMSYS
6 rows selected.

2)建立表空間和rman使用者,並授權。
SQL>; create tablespace rman_ts datafile '/oracle/oradata/legato/rman_ts01.dbf' size 200M default storage (initial 100K next 100K pctincrease 0);
Tablespace created.

SQL>; alter tablespace rman_ts online;
Tablespace altered.

SQL>; select * from v$tablespace;
TS# NAME INC
---------- ------------------------------ ---
0 SYSTEM YES
1 UNDOTBS1 YES
2 TEMP YES
3 CWMLITE YES
4 INDX YES
5 TOOLS YES
6 USERS YES
7 XDB YES
8 RMAN_TS YES
9 rows selected.

SQL>; create user rman identified by oracle9i default tablespace rman_ts quota unlimited on rman_ts;
User created.

SQL>; grant recovery_catalog_owner to rman;
Grant succeeded.

SQL>; grant connect ,resource to rman;
Grant succeeded.

SQL>; select username from dba_users;
USERNAME------------------------------
SYS
SYSTEM
RMAN
DBSNMP
OUTLN
OLAPSYS
WMSYS

7 rows selected.

3) 建立recover catalog 。
l2000a:/oracle #rman catalog rman/oracle9i@legato;
Recovery Manager: Release 9.2.0.1.0 - 64bit Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
connected to recovery catalog database
recovery catalog is not installed

RMAN>; create catalog;
recovery catalog created

RMAN>; exit
Recovery Manager complete.
l2000a:/oracle #exit
script. done on Thu Dec 4 00:02:43 2003

2 今天需要做的工作

0) 判斷系統中是否存在nsr程式:
# ps –ef|grep nsr
如果存在,先執行如下命令:
# nsr_shutdown
看是否存在/nsr和/opt/networker資料夾,如果存在,執行如下命令:
# mv /nsr /var/legato
# mv /opt/networker /var/legato
# mv /sbin/init.d/networker /sbin/init.d/networker.old
# mv /sbin/rc2.d/S900networker /sbin/rc2.d/S900networker.old

1) Install Legato Networker client
將相關的檔案ftp上傳到/var/legato資料夾下;
要求/opt要有大於100M的硬碟空間。
1執行swinstall & 選擇安裝legato NetWorker的client 和man。
2 編輯需要安裝軟體的伺服器的 /etc/hosts 檔案,增加如下內容:
136.5.9.63 l2000a
3 在備份伺服器(l2000a)上 vi /etc/hosts ,增加如下內容:
136.5.196.100 xxxx

4 編輯需要安裝軟體的伺服器的 /nsr/res/servers 檔案,增加如下內容:
l2000a
5 編輯伺服器root使用者的profile檔案,在PATH環境變數中增加如下部分:
/opt/networker/bin
6 執行一次 #. ./.profile
7 手工啟動networker的程式:
# /sbin/init.d/networker start
8 檢驗程式是否正常啟動:
# ps –ef|grep nsr
如果有 nsrd和nsrexed則說明正常。
9 在備份伺服器上增加如下客戶端:
xxxx
10 在新安裝軟體的機器上執行如下命令:
# nwbackup &
手工指定 /etc/hosts檔案測試檔案備份是否正常。

2) Install NetWorker Module for oracle
1執行swinstall & 選擇安裝networker module for oracle
2 做資料庫的連結
# su - oracle
$ cd $ORACLE_HOME/lib
$ mv libobk.sl libobk.sl.bak (該目錄下沒有libobk.sl 檔案)
$ ln –s /usr/lib/libnwora.sl libobk.sl


3) Open target database Archivelog 模式(該步驟由oracle工程師來做)
# su – oracle
$ vi /u01/app/oracle/admin/cqyp/pfile/initora8i.ora
然後根據客戶的實際情況修改下面幾行:
log_archive_start = true
log_archive_dest_1 = "location=/redo_log"
log_archive_format = arch_%t_%s.arc
將前面的幾個#註釋掉。

4) Open target database archive log模式(該步驟由oracle工程師來做)
# su – oracle
$ sqlplus /nolog
>;connect / as sysdba;
>;startup mount;
>;archive log start;
>;alter database archivelog;
>;alter database open;
>;archive log list;
>;exit

5) 在target庫上建立一個dbbackup使用者。該使用者具備sysdba許可權。(該步驟由oracle工程師來做。)

 create user dbbackup identified by oracle9i default tablespace tools;
 grant sysdba to dbbackup;
6) 修改資料庫的tnsnames.ora。

在target資料庫的tnsnames.ora上增加如下內容:
LEGATO =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = l2000a)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = legato)
)
)
在備份伺服器catalog資料庫的tnsnames.ora上增加如下內容:
ORA7 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = cq112)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ora7)
)
)
7) 在target伺服器上register catalog database;
$ rman catalog rman/oracle9i@legato target sys/password@ora7;
RMAN>;register database;

8) 修改/opt/networker/bin下的nsrnmo
注意修改以下內容:
ORACLE_HOME= /u01/app/oracle/product/8.1.7
PATH=/usr/local/sbin:/usr/ccs/bin:/usr/sbin:/usr/bin:/usr/dt/bin:/usr/openwin/bin:/bin:/usr/ucb:/usr/local/bin:/oracle/app/oracle8/product/817/bin

NSR_RMAN_ARGUMENTS="catalog msglog '/nsr/applogs/msglog.log' append"

NSR_SB_DEBUG_FILE=/nsr/applogs/nsrnmostart.log

ORACLE_SID=ora8i

9) 測試備份教本。
1 Online_db_full
connect target sys/password@XXXX;
connect catalog rman/oracle9i@legato;
run {
allocate channel t1 type 'SBT_TAPE' parms 'ENV=(NSR_SERVER=l2000a,NSR_DATA_VOLUME_POOL=Default)';

allocate channel t2 type 'SBT_TAPE' parms 'ENV=(NSR_SERVER=l2000a,NSR_DATA_VOLUME_POOL=Default)';

allocate channel t3 type 'SBT_TAPE' parms 'ENV=(NSR_SERVER=l2000a,NSR_DATA_VOLUME_POOL=Default)';

allocate channel t4 type 'SBT_TAPE' parms 'ENV=(NSR_SERVER=l2000a,NSR_DATA_VOLUME_POOL=Default)';

backup full filesperset 4
format 'Default_%s_%p_%u'
(database include current controlfile);


release channel t1;
release channel t2;
release channel t3;
release channel t4;

}

2 online_archivelog
connect target sys/password@XXXX;
connect catalog rman/oracle9i@legato;

run{

allocate channel t1 type 'SBT_TAPE' parms 'ENV=(NSR_SERVER=l2000a,NSR_DATA_VOLUME_POOL=Default)';

allocate channel t2 type 'SBT_TAPE' parms 'ENV=(NSR_SERVER=l2000a,NSR_DATA_VOLUME_POOL=Default)';

sql 'alter system switch logfile';

backup filesperset 4
format 'archive_%s_%p_%u'
(archivelog until time 'SYSDATE' delete input);

release channel t1;
release channel t2;

}

以下是本人在華能集團06年儲存備份專案中編寫的"使用Legato NetWorker備份、恢復Oracle 9i_Solaris9"文件.

1. 啟用資料庫的歸檔模式................................................................................................................. 4

1.1. 配置歸檔屬性........................................................................................................................... 4

1.2. 配置歸檔模式........................................................................................................................... 4

2. 準備安裝NMO程式......................................................................................................................... 5

3. 安裝NMO程式................................................................................................................................ 5

4. 配置Oracle資料庫的連結........................................................................................................... 8

4.1. 連結NMO模組的庫檔案和Oracle資料庫..................................................................................... 8

5. 配置客戶端的備份指令碼: nsrnmo................................................................................................. 8

6. 配置RMAN備份指令碼....................................................................................................................... 9

7. 配置NetWorker的備份策略......................................................................................................... 9

7.1. 建立卷標模板........................................................................................................................... 9

7.2. 設定備份策略SCHDULE............................................................................................................ 10

7.3. 建立備份任務組...................................................................................................................... 10

7.4. 建立備份介質池...................................................................................................................... 10

7.5. 建立CLIENT/SAVESET.............................................................................................................. 10

8. 備份Oracle資料庫..................................................................................................................... 11

9. 恢復Oracle資料庫..................................................................................................................... 11

9.1. 建立測試表............................................................................................................................. 11

9.2. 移動測試表空間...................................................................................................................... 12

9.3. 恢復表空間............................................................................................................................. 12

9.4. 驗證表空間............................................................................................................................. 12


1. 啟用資料庫的歸檔模式

注意: 進行啟用歸檔模式前,一定要對生產資料庫進行全備份。

1.1. 配置歸檔屬性

歸檔模式的修改,可使用oracle 9i的新特性,使用spfile,通過alter system set語句來完成。

oracle使用者登陸:SQL> connect /as sysdba

假如需要放入歸檔檔案的路徑為$ORACLE_ARCH_1$ORACLE_ARCH_2,則進行如下設定:

SQL>alter system set log_archive_dest_1=”Location=/$ORACLE_ARCH_1” scope=spfile;

SQL>alter system set log_archive_dest_2=”Location=/$ORACLE_ARCH_2” scope=spfile;

設定歸檔程式:啟動oracle自動歸檔的程式,進行如下設定:

SQL>alter system set log_archive_start=ture scope=spfile;

設定歸檔檔名稱:設定好歸檔檔案的名稱, 進行如下設定:

SQL>alter system set log_archive_format=”SID_T%TS%S.ARC”

如果是Oracle 8i資料庫,那麼在$ORACLE_BASE/admin/$ORACLE_SID/pfile/init$ORACLE_SID.ora中修改上面3個引數即可,再重啟Oracle 8i資料庫。

1.2. 配置歸檔模式

正常關閉資料庫:sql>shutdown immediate;

安裝啟動資料庫:SQL>startup mount

配置歸檔模式

SQL>alter database archivelog;

使歸檔日誌自動歸檔

sql>archive log start;

開啟資料庫

SQL>alter database open;

驗證:檢查歸檔屬性

SQL>archive log list

檢視歸檔目標是否設定正確,歸檔程式是否已經啟動.資料庫是否已經處於歸檔狀態。

2. 準備安裝NMO程式

首先,應該先在備份客戶端伺服器上安裝Legato NetWorker 的客戶端,然後安裝Legato NetWorker Module for Oracle程式。

NetWorker客戶端伺服器的/etc/hosts中增加備份伺服器和客戶端的IP地址。

請將NetWorker NMO安裝光碟插進備份客戶端伺服器的光碟機中,或將NetWorker NMO安裝程式上傳至備份客戶端伺服器中。解開壓縮軟體包,#gunzip nmo42_solaris_64.tar.gz

#tar –xvpf nmo42_solaris_64.tar

3. 安裝NMO程式

安裝NetWorker Module for Oracle程式時,應該以root使用者身份登入執行# pkgadd -d /nmo42_solaris_64

The following packages are available:

1 LGTOnmo NetWorker Module for Oracle

(sparc) 4.2 [LNMs_2004.Build.273]

2 LGTOnmowz Legato NetWorker Wizard for Oracle Module

(sparc) 4.2 [LNMs_2004.Build.273]

Select package(s) you wish to process (or 'all' to process

all packages). (default: all) [?,??,q]:

Processing package instance from

NetWorker Module for Oracle

(sparc) 4.2 [LNMs_2004.Build.273]

Copyright (c) 1990-2005, LEGATO Software, a division of EMC.

## Executing checkinstall script.

Using as the package base directory.

## Processing package information.

## Processing system information.

7 package pathnames are already properly installed.

## Verifying disk space requirements.

## Checking for conflicts with packages already installed.

The following files are already installed on the system and are being

used by another package:

/usr/lib/nsr

Do you want to install these conflicting files [y,n,?,q] y

## Checking for setuid/setgid programs.

This package contains scripts which will be executed with super-user

permission during the process of installing this package.

Do you want to continue with the installation of [y,n,?] y

Installing NetWorker Module for Oracle as

## Executing preinstall script.

## Installing part 1 of 1.

/etc/nsrnmo.sh

… …

/usr/share/man/man5/nmo_eula.5

[ verifying class ]

## Executing postinstall script.

*** Registration of NMO on the client completed successfully. ***

*** Important Information for Completing your NMO Installation ***

---------------------------------------------------------------------

Depending on the Oracle version you are running,

you may have to link the Oracle executable

and/or shutdown and restart Oracle

before you are ready to use NMO.

Please, consult your Installation Guide for complete instructions.

Installation of was successful.

Processing package instance from

Legato NetWorker Wizard for Oracle Module

(sparc) 4.2 [LNMs_2004.Build.273]

Copyright (c) 1990-2005, LEGATO Software, a division of EMC.

## Executing checkinstall script.

Using as the package base directory.

## Processing package information.

## Processing system information.

2 package pathnames are already properly installed.

## Verifying disk space requirements.

## Checking for conflicts with packages already installed.

## Checking for setuid/setgid programs.

This package contains scripts which will be executed with super-user

permission during the process of installing this package.

Do you want to continue with the installation of [y,n,?] y

Installing Legato NetWorker Wizard for Oracle Module as

## Executing preinstall script.

## Installing part 1 of 1.

/usr/lib/nsr/libnmowiz.so

[ verifying class ]

## Executing postinstall script.

*** Registration of NMO on the console completed successfully. ***

*** Important Information for Completing your NMOWZ Installation ***

---------------------------------------------------------------------

Please, consult your Installation Guide for complete instructions.

Installation of was successful.

The following packages are available:

1 LGTOnmo NetWorker Module for Oracle

(sparc) 4.2 [LNMs_2004.Build.273]

2 LGTOnmowz Legato NetWorker Wizard for Oracle Module

(sparc) 4.2 [LNMs_2004.Build.273]

Select package(s) you wish to process (or 'all' to process

all packages). (default: all) [?,??,q]: q

NetWorker可執行路徑新增到root使用者的環境變數檔案中。

4. 配置Oracle資料庫的連結

安裝完NMO軟體之後,我們應該連結NMO模組的庫檔案和Oracle資料庫軟體。對於不同的作業系統和Oracle資料庫的版本,我們使用以下一步或兩步命令去連結庫檔案:移走連結到Oracle的庫檔案的符號連線;Oracle libraries重新配置一個新的庫。

4.1. 連結NMO模組的庫檔案和Oracle資料庫

#su – oracle

關閉所有的Oracle例項(Oracle9i以上除外)

$cd $ORACLE_HOME/lib

$ln –s /usr/lib/libnwora.so libobk.so

啟動所有的Oracle例項(Oracle9i以上除外)

現在我們可以手動操作執行RMAN備份Oracle資料庫。

注意:在編寫RMAN備份指令碼中時,allocate channel後如果跟disk,則是在檔案系統上備份;如果是SBT_TAPE, 就是配置Oracle通過SBT_TAPE對第三方提供介面備份,即在Legato NetWorker中配置的裝置上備份。

如,allocate channel t1 type 'SBT_TAPE'

5. 配置客戶端的備份指令碼: nsrnmo

編輯networker 目錄(/usr/sbin)下的nsrnmo檔案,設定:

ORACLE_HOME:ORACLE系統的目錄

PATH:搜尋路徑應包括NETWORKER程式的目錄和nsrnmo所在目錄 /usr/sbin

NSR_RMAN_ARGUMENTSrman的執行引數,如指定LOGmsglog=/tmp/rmanlog

TNS_ADMINtnsnames.ora檔案所在的目錄

ORACLE_HOME=/oracle/product/9.2.0

PATH=/bin:/usr/sbin:/usr/bin:$ORACLE_HOME/bin

NSR_RMAN_ARGUMENTS=nocatalog msglog '/nsr/applogs/msglog.log' append

6. 配置RMAN備份指令碼

備份SCRIPT指定了RMAN備份時的備份物件(DATABASETABLESPACEDATAFILECONTROL FILEARCHIVELOG)、備份級別(0123)、備份裝置、執行引數等。

備份全庫

connect target sys/root@oracle

run{

allocate channel t1 type 'SBT_TAPE'

parms 'ENV=(NSR_SERVER=356wd,NSR_CLIENT=hn-sun,NSR_DATA_VOLUME_POOL=ora)';

backup full filesperset 4

format 'oracle_%s_%p_%u'

(database include current controlfile);

sql 'alter system switch logfile';

release channel t1;

}

備份歸檔日誌部分

sql 'alter system switch logfile';

backup filesperset 4

format 'archive_%s_%p_%u'

(archivelog until time 'SYSDATE' delete input);

7. 配置NetWorker的備份策略

Devices中建立硬碟裝置或在系統中使用jbconfig配置NAS或磁帶庫裝置。

7.1. 建立卷標模板

NWADMIN選單下,在Manage Label Templates中選 Label Templates,按CREAT 按鈕,設定:

NAMEoracle

FIELDS: oracle,001-999

SPERATOR.

按“確定”按鈕,設定生效。

7.2. 設定備份策略SCHDULE

NWADMIN選單下,在Manage Schdules中選Schdules,按CREAT按鈕,設定備份的策略。先選定備份策略的迴圈週期,如“WEEK”。再設定週期內的每一天,S代表SKIP不執行備份,F代表執行備份任務。

7.3. 建立備份任務組

NWADMIN選單下,在Manage Groups中選Groups,按CREAT按鈕,設定組名oracle,啟動時間,及是否自動啟動。按“確定”按鈕,設定生效。

7.4. 建立備份介質池

NWADMIN選單下,在Manage Poolss中選Pools,按CREAT按鈕,設定:

NAMEoracle

LABEL TEMPLATEoracle

給磁帶加捲標,使其成為該介質池的卷。按“確定”按鈕,設定生效。

7.5. 建立CLIENT/SAVESET

NWADMIN選單下,在Manage Clients中選Clients,按CREAT按鈕,設定:

. NAME:備份客戶機的主機名

SCHEDULE:備份時間表

BROWSE POLICY:備份資料在檔案索引中的儲存期限

RETENTION POLICY:備份資料在磁帶上的儲存期限

GROUP:確定該備份物件屬於備份工作組oracle

SAVE SET:備份指令碼的存放路徑

REMOTE ACCESS:恢復許可權,指定那些使用者可以恢復該資料

BACKUP COMMAND:指定完成備份任務的命令,nsrnmo

注意:BACKUP COMMAND中一定要輸入執行備份任務的命令nsrnmo,否則備份不會成功。

ALIASES:該客戶機的別名,對於多網路卡主機可有多個別名

8. 備份Oracle資料庫

NetWorker伺服器端操作的備份組中,選擇備份組點選右鍵“start”按鈕。

備份任務的執行情況可以在Monitor中的Messages中瀏覽。

而備份執行的細節可以參考在備份組的Details中檢視。

9. 恢復Oracle資料庫

首先在NetWorker客戶端關閉Oracle資料庫sql>shutdown immediate,接著將測試表空間的資料檔案移開$mv test_ts01.dbf ..,安裝啟動資料庫sql>startup mount

最後執行恢復指令碼$rman cmdfile /oracle/rcv_ora_tbs,就可以恢復資料檔案或表空間。

9.1. 建立測試表

建立測試表空間test_ts

SQL> create tablespace test_ts datafile '/oracle/oradata/oracle/test_ts01.dbf' size 100M;

建立測試使用者test

SQL> create user test identified by test default tablespace test_ts quota unlimited on test_ts;

給測試使用者test授權

SQL> grant connect ,resource to test;

以使用者test身份建立測試表test

SQL> create table test(name varchar2(20),age varchar2(50),phone number)tablespace test_ts;

向測試表test插入測試資料

SQL> insert into test values('dengwei','28',356);

SQL> commit;

檢視測試表的內容

SQL> select name,age,phone from test;

NAME AGE PHONE

----------------------------------------

dengwei 28 356

對測試資料庫再做一次全庫備份。

9.2. 移動測試表空間

首先關閉Oracle資料庫

sql>shutdown immediate

移動測試表空間的資料檔案,將測試表空間的資料檔案移走。

$ mv test_ts01.dbf ..

9.3. 恢復表空間

安裝啟動資料庫

sql>startup mount

再從備份中恢復測試表空間

恢復一個表空間的RMAN指令碼

connect target sys/root@oracle

run{

allocate channel t1 type 'SBT_TAPE'

parms 'ENV=(NSR_SERVER=356wd,NSR_CLIENT=hn-sun,NSR_DATA_VOLUME_POOL=ora)';

restore tablespace test_ts;

recover tablespace test_ts;

release channel t1;

}

alter database open;

重啟Oracle資料庫

sql>shutdown immediate

sql>startup

9.4. 驗證表空間

以使用者test身份登入,檢視測試表的內容,如果能顯示測試表的資訊,說明恢復測試成功。

SQL> select name,age,phone from test;

NAME AGE PHONE

----------------------------------------

dengwei 28 356

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24558279/viewspace-764756/,如需轉載,請註明出處,否則將追究法律責任。

相關文章