ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Legato Networker备份Oracle

Legato Networker备份Oracle

原创 Linux操作系统 作者:it_newbalance 时间:2013-06-25 11:42:46 0 删除 编辑
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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-03-28

  • 博文量
    143
  • 访问量
    702575