rac安装手册

松小松 贡献于2017-02-13

作者 wei.ye  创建于2010-10-09 02:35:00   修改者tornados  修改于2010-10-09 02:35:00字数46151

文档摘要:
关键词:

数据库系统安装实施文档 一、系统配置信息 1、主机系统 2台IBM System x3650 2CPU、16G内存、 2.5GHZ主频、2块146GB SAS硬盘、2块集成1000/100/10自适应网卡、1块PCI-e网卡、2块4GB HBA卡。 操作系统:红旗DC Server 5.0 sp2 数据库系统:Oracle 10g (10.2.0.1.0) Database_linux_x86_64 Red Flag Linux OS系统分区情况: /boot 102M / 10G /home 10G /var 10G /usr 10G /swap 12GB /backup 25G /opt 剩余容量 网络地址 #public network-(eth1) 10.170.64.194 postdb1 10.170.64.195 postdb2 #private interconnect-(eth0) 1.1.1.1 postdb1-priv 1.1.1.2 postdb2-priv 255.255.255.252 #public virtual ip(vip)address-(eth1) 10.170.64.196 postdb1-vip 10.170.64.197 postdb2-vip 2、存储系统: IBM DS4700磁盘阵列2台、14x146GB/15000KPS SAS 硬盘、双冗余控制器 业务系统数据库生产系统磁盘阵列 型号:DS4700-72A 划分如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Hotspare RAID5 RAID5 RAID5 RAID5 RAID5 RAID5 RAID5 RAID5 RAID5 RAID5 RAID5 MIRROR 华为 专用 MIRROR 华为 专用 空 空 1号盘为热备盘,2-12号硬盘做了RAID5,以200G为单位进行划分,划完为止,最后不足200G的也划出来。同时将每个分区都分别映射给两台数据库服务器。 业务系统数据库备份磁盘阵列 型号:DS4700-70A 划分如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Hotspare Hotspare RAID5 … … … … …. …. … …. …. …. RAID5 空 空 1、2号盘为热备盘,3-14号盘做了RAID5。在RAID5的array中划分了一块大的逻辑分区,其容量约为850G,分别映射给了两台数据库服务器postdb1、postdb2,此分区挂载在了postdb1的/database_backup目录下,作为数据库日常备份使用。 备份盘阵剩余未划容量约为:600G,留作以后系统扩展使用。 3、数据库系统 初始化参数: SID (postdb) SGA(6G) 16G内存 PGA(2G) 16G内存 SGA(8G) 32G内存 PGA(4G) 32G内存 PROCESS (500) JOB (20) 初始表空间 SYSAUX (1024M) SYSTEM (1024M) TEMP (8192M) UNDOTBS1 (4096M) UNDOTBS2 (4096M) USERS (500M) 重做日志组 128M,128M,128M,128M 4、密码信息: 操作系统用户: root:postdb oracle:oracle Asm数据库用户: sys/system:sysasm 数据库用户: sys/system:postdb 二、安装前准备 1、配置网络――需要在两个节点上都配置(以root用户执行) 做网卡绑定。 1、配置两个节点的主机名、公有网络的地址、私有网络的地址 节点1: hostname=postdb1 Gatway = 10.214.22.254 eth1 10.214.22.133 255.255.255.128 postdb1 eth0 192.168.8.103 255.255.255.0 postdb1-priv 节点2: hostname=postdb2 gatway=10.214.22.254 eth1 10.214.22.135 255.255.255.128 postdb2 eth0 192.168.8.104 255.255.255.0 postdb2-priv Note:postdb1、postdb2必须对应的相同的网卡名字如上eth1,postdb1-priv、postdb2-priv必须对应相同的网卡名字如上eth0 2、配置两个节点的/etc/hosts,编辑添加如下内容: #public network-(eth1) 10.214.22.133 postdb1 10.214.22.135 postdb2 #private interconnect-(eth0) 192.168.8.103 postdb1-priv 192.168.8.104 postdb2-priv #public virtual ip(vip)address-(eth1) 10.214.22.134 postdb1-vip 10.214.22.136 postdb2-vip Note:postdb1-vip、postdb2-vip只需要在/etc/hosts文件中定义,不需要配置在网卡上,RAC在安装的过程中,会根据指定的公用网络网卡自动绑定。 3、确保 RAC 节点名没有出现在回送地址(127.0.0.1)中 确认在/etc/hosts文件中,所有的节点名都没有被包含在loopback地址中(127.0.0.1)。如果节点名列在了loopback地址中如下: 127.0.0.1 localhost.localdomain localhost 4、确认并关闭UDP ICMP过滤,即确认关闭防火墙 1> 检查是否关闭了防火墙 # /etc/rc.d/init.d/iptables status 2> 如果防火墙正在运行,首先手动停止 # /etc/rc.d/init.d/iptables stop 3> 然后关闭防火墙,使其在下次重启以后不再启用 # chkconfig iptables off Note:或者使用ntsysv查看防火墙是否默认是关闭的。 5、确认已关闭SELINUX # /usr/bin/system-config-securitylevel 查看SELINUX是否关闭 如果SELINUX是在运行的,关闭SELINUX 重新启动服务器 2、建oracle用户,组及相关目录――需要在两个节点上都配置(以root用户执行) groupadd -g 115 dba groupadd -g 116 oinstall useradd -u 175 -g oinstall -G dba oracle passwd oracle 密码:oracle mkdir –p /opt/app/oracle #oracle_home目录 cd /opt/app/oracle mkdir backup_scripts #备份脚本存放的地方 mkdir oinstall #数据库安装文件存放地方 chown –R oracle:oinstall /opt chmod –R 775 /opt 验证nobody用户存在 id nobody 如果不存在nobody,执行如下: useradd nobody 3、配置oracle用户登录脚本即环境变量――需要在两个节点上都配置(以oracle用户配置) 编辑oracle用户下的.bash_profile文件添加如下行,如果是在节点2,那么对应的export ORACLE_SID=postdb1应为export ORACLE_SID=postdb2: export ORACLE_BASE=/opt/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db1 export ORA_CRS_HOME=$ORACLE_BASE/crs/10.2.0 export PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:$PATH export LD_LIBRARY_PATH=/usr/lib64:/lib:/usr/lib:$ORACLE_HOME/lib:$ORACLE_HOME/lib32:$ORACLE_HOME/oracm/lib:$ORA_CRS_HOME/lib:$ORA_CRS_HOME/lib32:/usr/local/lib export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib export TNS_ADMIN=$ORACLE_HOME/network/admin export NLS_LANG=american_america.zhs16GBk export ORACLE_SID=postdb1 umask 022 4、配置hangcheck-timer模块――两个节点上都执行(以root用户执行) 检查hangcheck-timer模块是否已经安装 # find /lib/modules -name "hangcheck-timer.ko" 配置hangcheck-timer模块参数 # su - # echo "options hangcheck-timer hangcheck_tick=30 hangcheck_margin=180" >> /etc/modprobe.conf 设置模块在系统启动是装载 # echo "/sbin/modprobe hangcheck-timer" >> /etc/rc.local 手动装载,测试参数设置的有效性 # su - # modprobe hangcheck-timer # grep Hangcheck /var/log/messages | tail -2 可以看到hangcheck_tick设置为30, hangcheck_margin设置为180。 5、配置用户等效性(以oracle用户执行,配置过程在节点1和2上有交叉,依照下面说明操作即可) 在两节点上查看ssh是否安装并且正在运行: # pgrep sshd 配置ssh的用户等效性: 第一步是生成 SSH 的公共密钥 在两个节点上分别生成公用密钥执行以下命令: [oracle@postdb1 ~]$cd /home/oracle [oracle@postdb1 ~]$ssh-keygen -t dsa 上面的命令中都一路回车,接收默认值 第二步,将公共密钥文件拷贝到其他节点 在第一个节点: [oracle@postdb1 ~]$cd /home/oracle/.ssh [oracle@postdb1 ~]$cat id_dsa.pub > authorized_keys [oracle@postdb1 ~]$scp authorized_keys postdb2:/home/oracle/.ssh 在第二个节点: [oracle@postdb1 ~]$cat id_dsa.pub >>authorized_keys [oracle@postdb1 ~]$scp authorized_keys postdb1:/home/oracle/.ssh 分别在两个节点上测试用户等效性: [oracle@postdb1 ~]$ssh postdb2 hostname [oracle@postdb1 ~]$ssh postdb1 hostname 上面命令没有出现提示输入密码或者其他提示为用户等效性配置好了。 6、查看网络,cpu,内存信息――需要在两个节点上都配置(以root用户执行) 查看cpu信息:cat /proc/cpuinfo 查看内存信息:cat /proc/meminfo 查看交换分区信息:cat /proc/meminfo|grep swapinfo 查看文件系统空间:df -k 7、检查并安装oracle需要的系统包――在两个节点上都配置(以root用户执行) $rpm -q gcc make binutils openmotif setarch compat-db compat-gcc compat-gcc-c++ compat-libstdc++ gcc-4.1.1-52.el5 make-3.81-1.1 binutils-2.17.50.0.6-2.el5 openmotif-2.3.0-0.3.el5 setarch-2.0-1.1 compat-db-4.2.52-5.1 package compat-gcc is not installed package compat-gcc-c++ is not installed package compat-libstdc++ is not installed rpm -q gcc make binutils openmotif setarch compat-db compat-gcc compat-gcc-c++ compat-libstdc++ 如果有没有安装的包使用命令:rpm –ivh package_name安装即可 8、在/etc/sysctl.conf文件中添加安装oracle需要的参数――两个节点都需要配置(root用户) 检查内核参数的值: # /sbin/sysctl -a | grep sem # /sbin/sysctl -a | grep shm # /sbin/sysctl -a | grep file-max # /sbin/sysctl -a | grep ip_local_port_range # /sbin/sysctl -a | grep net.core 检查/etc/sysctl.conf文件中的参数是否包含以下内容,将以下参数编辑成以下值: kernel.shmall = 2097152 kernel.shmmax = 8589934592 #物理内存的一半,以字节为单位,当前为16G kernel.shmmni = 4096 kernel.sem = 250 32000 100 142 fs.file-max = 327680 net.ipv4.ip_local_port_range = 1024 65000 net.core.rmem_default = 262144 net.core.wmem_default = 262144 net.core.rmem_max = 262144 net.core.wmem_max = 262144 然后执行:sysctl –p将修改参数生效 9、设置oracle的shell限制:――两个节点上都需要配置(root用户身份) 以 root 用户身份运行以下命令: cat >> /etc/security/limits.conf <> /etc/pam.d/login < authorized_keys scp authorized_keys postdb2:/root/.ssh/ 3、将节点二的id_dsa.pub追加到authorized_keys中,并将authorized_keys传回到节点1 cd /root/.ssh cat id_dsa.pub >> authorized_keys scp authorized_keys postdb1:/root/.ssh/ 4、测试连通性 在root用户下:ssh postdb1 date Ssh postdb2 date 安装数据库软件: 用终端连接服务器网络: xhost + export DISPLAY=10.214.22.240:0.0 ; unset ORA_CRS_HOME unset ORACLE_HOME cd /opt/app/oracle/oinstall/database ./runinstaller –ignoreSysPrereqs 5.Oracle打补丁 注意home路径 1.首先需要下载补丁 10204 for linux下的补丁 补丁号为 6810189 文件名为 p6810189_10204_Linux-x86.zip  (包括clusterware和software) 2. 因为是新安装的clusterware,database software 没有创建数据库 所以打补丁步骤就简单点 2.1 打clusterware 补丁 首先要停掉 crs服务 两个节点都要 /u01/crs/oracle/product/10.2.0/crs/bin/crsctl stop crs 2.2  安装clusterware补丁 选择crs_home 目录 选择所有节点 一直往下安装 到最后按提示来做  rac1节点 /u01/crs/oracle/product/10.2.0/crs/bin/crsctl stop crs /u01/crs/oracle/product/10.2.0/crs/install 目录下运行 root102.sh rac2 节点 /u01/crs/oracle/product/10.2.0/crs/bin/crsctl stop crs /u01/crs/oracle/product/10.2.0/crs/install 目录下运行 root102.sh 2.3  安装 oracle 软件包 选择ORACLE_HOME目录 选择所有节点 一直往下安装 分别用root用户执行 /u01/app/oracle/product/10.2.0/ 目录下 root.sh 即可 6. 配置监听程序 配置监听程序(在一个节点上执行就好了) 在ORACLE用户下: Netca [oracle@postdb1 ~]$ srvctl status nodeapps -n postdb1 VIP 正在运行的节点: postdb1 GSD 正在运行的节点: postdb1 监听程序正在节点上运行: postdb1 ONS 守护程序正在节点上运行:postdb1 [oracle@postdb1 ~]$ srvctl status nodeapps -n postdb2 VIP 正在运行的节点: postdb2 GSD 正在运行的节点: postdb2 监听程序正在节点上运行: postdb2 ONS 守护程序正在节点上运行:postdb2 7. 建立asm 在一个节点的oracle用户下执行dbca,选择配置自动存储管理: 8.创建数据库 用cvu确认数据库安装的前准备工作符合要求: 安装软件解压出来是clusterware目录,进入其下的cluvfy目录如下: /opt/app/oracle/oinstall/clusterware/cluvfy [oracle@postdb1 cluvfy]$ ./runcluvfy.sh stage -pre dbcfg -n postdb1,postdb2 -d /opt/app/oracle/product/10.2.0/db1 -verbose 执行 数据库配置 的预检查 正在检查节点的可访问性... 检查: 节点 "postdb1" 的节点可访问性 目标节点 是否可访问? ------------------------------------ ------------------------ postdb1 是 postdb2 是 结果:节点 "postdb1" 的节点可访问性检查已通过。 正在检查等同用户... 检查: 用户 "oracle" 的等同用户 节点名 注释 ------------------------------------ ------------------------ postdb2 通过 postdb1 通过 结果:用户 "oracle" 的等同用户检查已通过。 正在检查管理权限... 检查: 用户 "oracle" 的存在性 节点名 用户存在 注释 ------------ ------------------------ ------------------------ postdb2 是 通过 postdb1 是 通过 结果:"oracle" 的用户存在性检查已通过。 检查: 组 "oinstall" 的存在性 节点名 状态 组 ID ------------ ------------------------ ------------------------ postdb2 存在 116 postdb1 存在 116 结果:"oinstall" 的组存在性检查已通过。 检查: 组 "oinstall" 中用户 "oracle" 的成员资格 [作为 主] 节点名 用户存在 组存在 组中的用户 主 注释 ---------------- ------------ ------------ ------------ ------------ ------------ postdb2 是 是 是 是 通过 postdb1 是 是 是 是 通过 结果:组 "oinstall" 中用户 "oracle" 的成员资格检查 [作为 主] 已通过。 检查: 组 "dba" 的存在性 节点名 状态 组 ID ------------ ------------------------ ------------------------ postdb2 存在 115 postdb1 存在 115 结果:"dba" 的组存在性检查已通过。 检查: 组 "dba" 中用户 "oracle" 的成员资格 节点名 用户存在 组存在 组中的用户 主 注释 ---------------- ------------ ------------ ------------ ------------ ------------ postdb2 是 是 是 否 通过 postdb1 是 是 是 否 通过 结果:组 "dba" 中用户 "oracle" 的成员资格检查已通过。 管理权限检查已通过。 正在检查节点的连接性... 节点 "postdb2" 的接口信息 接口名 IP 地址 子网 ------------------------------ ------------------------------ ---------------- eth0 192.168.8.104 192.168.8.0 eth1 10.214.22.135 10.214.22.128 eth1 10.214.22.136 10.214.22.0 节点 "postdb1" 的接口信息 接口名 IP 地址 子网 ------------------------------ ------------------------------ ---------------- eth0 192.168.8.103 192.168.8.0 eth1 10.214.22.133 10.214.22.128 eth1 10.214.22.134 10.214.22.0 检查: 子网 "192.168.8.0" 的节点连接性 源 目标 是否已连接? ------------------------------ ------------------------------ ---------------- postdb2:eth0 postdb1:eth0 是 结果:含有节点 postdb2,postdb1 的子网 "192.168.8.0" 的节点连接性检查已通过。 检查: 子网 "10.214.22.128" 的节点连接性 源 目标 是否已连接? ------------------------------ ------------------------------ ---------------- postdb2:eth1 postdb1:eth1 是 结果:含有节点 postdb2,postdb1 的子网 "10.214.22.128" 的节点连接性检查已通过。 检查: 子网 "10.214.22.0" 的节点连接性 源 目标 是否已连接? ------------------------------ ------------------------------ ---------------- postdb2:eth1 postdb1:eth1 是 结果:含有节点 postdb2,postdb1 的子网 "10.214.22.0" 的节点连接性检查已通过。 子网 "192.168.8.0" 上用于专用互联的合适接口: postdb2 eth0:192.168.8.104 postdb1 eth0:192.168.8.103 子网 "10.214.22.128" 上用于专用互联的合适接口: postdb2 eth1:10.214.22.135 postdb1 eth1:10.214.22.133 子网 "10.214.22.0" 上用于专用互联的合适接口: postdb2 eth1:10.214.22.136 postdb1 eth1:10.214.22.134 ERROR: 找不到用于 VIP 的合适接口集。 结果:节点的连接性检查失败。 正在检查 CRS 完整性... 正在检查守护程序的活动性... 检查: "CRS daemon" 的活动性 节点名 运行 ------------------------------------ ------------------------ postdb2 是 postdb1 是 结果:"CRS daemon" 的活动性检查已通过。 正在检查守护程序的活动性... 检查: "CSS daemon" 的活动性 节点名 运行 ------------------------------------ ------------------------ postdb2 是 postdb1 是 结果:"CSS daemon" 的活动性检查已通过。 正在检查守护程序的活动性... 检查: "EVM daemon" 的活动性 节点名 运行 ------------------------------------ ------------------------ postdb2 是 postdb1 是 结果:"EVM daemon" 的活动性检查已通过。 所有守护程序的活动性 节点名 CRS daemon CSS daemon EVM daemon ------------ ------------------------ ------------------------ ---------- postdb2 是 是 是 postdb1 是 是 是 正在检查 CRS 健康状况... 检查: CRS 的健康状况 节点名 CRS OK? ------------------------------------ ------------------------ postdb2 是 postdb1 是 结果:CRS 健康状况检查已通过。 CRS 完整性检查已通过。 在所有节点上预检查 数据库配置 失败。 数据库软件安装完毕后,在oracle用户下执行dbca命令创建数据库。 在一台服务器上,以oracle用户执行dbca命令创建数据库,过程和在window上建库一样,区别在数据库数据文件是建立共享磁盘阵列上。 xhost + export DISPLAY=10.214.22.240:0.0 ; $dbca 此处不再添加db服务名 9. 修改bug 现象:ORA-12545因目标主机或对象不存在,连接失败 1、用oracle用户登陆rac节点postdb1,修改tnsnames.ora vi tnsnames.ora(把HOST对应的vip改成公用IP地址) POSTDB1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.118.5.15)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = postdb) (INSTANCE_NAME = postdb1) ) ) 2、用oracle用户登陆rac节点postdb2,修改tnsnames.ora vi tnsnames.ora(把HOST对应的vip改成公用IP地址) POSTDB2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.118.5.17)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = postdb) (INSTANCE_NAME = postdb2) ) ) 3、修改节点1的参数文件中的 local_listener(sqlplus / as sysdba) alter system set local_listener='postdb1' scope=spfile sid='postdb1'; 重启节点 srvctl stop instance -d postdb -i postdb1 srvctl stop nodeapps -n postdb1 srvctl start instance -d postdb -i postdb1 srvctl start nodeapps -n postdb1 4、修改节点2的参数文件中的 local_listener(sqlplus / as sysdba) alter system set local_listener='postdb2' scope=spfile sid='postdb2'; 重启节点 srvctl stop instance -d postdb -i postdb2 srvctl stop nodeapps -n postdb2 srvctl start instance -d postdb -i postdb2 srvctl start nodeapps -n postdb2 10. 查看数据文件信息: 登录数据库: SQL> select name from v$controlfile; NAME -------------------------------------------------------------------------------- +DATA1/postdb/controlfile/current.256.664225135 +FLASH_RECAVORY/postdb/controlfile/current.256.664225135 SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- +DATA1/postdb/datafile/system.259.664225145 +DATA1/postdb/datafile/undotbs1.260.664225155 +DATA1/postdb/datafile/sysaux.261.664225183 +DATA1/postdb/datafile/undotbs2.263.664225193 +DATA1/postdb/datafile/users.264.664225221 SQL> select name from v$tempfile; NAME -------------------------------------------------------------------------------- +DATA1/postdb/tempfile/temp.262.664225189 SQL> select member from v$logfile; MEMBER -------------------------------------------------------------------------------- +DATA1/postdb/onlinelog/group_1.257.664225135 +FLASH_RECAVORY/postdb/onlinelog/group_1.257.664225135 +DATA1/postdb/onlinelog/group_2.258.664225137 +FLASH_RECAVORY/postdb/onlinelog/group_2.258.664225137 +DATA1/postdb/onlinelog/group_3.265.664226121 +FLASH_RECAVORY/postdb/onlinelog/group_3.259.664226121 +DATA1/postdb/onlinelog/group_4.266.664226123 +FLASH_RECAVORY/postdb/onlinelog/group_4.260.664226123 SQL> select name from v$archived_log; NAME -------------------------------------------------------------------------------- +DATA1/postdb/1_12_664225125.dbf 五.测试集群 1.测试RAC数据库的状态(以oracle用户执行) $ ls -l /etc/init.d/init.* init.crs init.crsd init.cssd init.evmd crs_stat -t -v ----查看crs的所有resources的状态 crs_stop resource_name -f ―――关闭状态为unknown的resources crs_start resource_name ――――启动刚才关闭的unknown 状态的resource srvctl status database -d postdb ――― 查看数据库的状态 实例 postdb1 正在节点 postdb1 上运行 实例 postdb2 正在节点 postdb2 上运行 测试结果:正常 srvctl status asm -n postdb1 -----查看节点1asm实例的状态 srvctl status asm -n postdb2 -----查看节点2asm实例的状态 srvctl status nodeapps -n postdb1 ――― 查看数据库节点1的服务状态 VIP 正在运行的节点: postdb1 GSD 正在运行的节点: postdb1 监听程序正在节点上运行: postdb1 ONS 守护程序正在节点上运行:postdb1 测试结果:正常 srvctl status nodeapps -n postdb2 ――― 查看数据库节点2的服务状态 VIP 正在运行的节点: postdb2 GSD 正在运行的节点: postdb2 监听程序正在节点上运行: postdb2 ONS 守护程序正在节点上运行:postdb2 测试结果:正常 srvctl config database -d postdb ――― 查看数据库的配置情况 postdb1 postdb1 /opt/app/oracle/ product/10.2.0/db1 postdb2 postdb2 /opt/app/oracle/ product/10.2.0/db1 测试结果:正常 srvctl config nodeapps -n postdb1 -a -g -s -l 显示节点应用程序的配置 VIP 已存在。: /postdb1-vip/10.214.22.134/255.255.255.0/eth1 GSD 已存在。 ONS 守护程序已存在。 监听程序已存在。 测试结果:正常 srvctl config service -d postdb ―――显示指定集群数据库的所有服务 db PREF: postdb2 postdb1 AVAIL: 测试结果:正常 lsnrctl status ―――查看监听器的状态(postdb1) LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 05-JUL-2008 12:11:00 Copyright (c) 1991, 2005, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER_POSTDB1 Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production Start Date 04-JUL-2008 17:25:30 Uptime 0 days 18 hr. 45 min. 29 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /opt/app/oracle/ product/10.2.0/db1/network/admin/listener.ora Listener Log File /opt/app/oracle/ product/10.2.0/db1/network/log/listener_postdb1.log Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.118.5.15)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.118.5.14)(PORT=1521))) Services Summary... Service "PLSExtProc" has 1 instance(s). Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service... Service "db" has 2 instance(s). Instance "postdb1", status READY, has 2 handler(s) for this service... Instance "postdb2", status READY, has 1 handler(s) for this service... Service "postdb" has 2 instance(s). Instance "postdb1", status READY, has 2 handler(s) for this service... Instance "postdb2", status READY, has 1 handler(s) for this service... Service "postdbXDB" has 2 instance(s). Instance "postdb1", status READY, has 1 handler(s) for this service... Instance "postdb2", status READY, has 1 handler(s) for this service... Service "postdb_XPT" has 2 instance(s). Instance "postdb1", status READY, has 2 handler(s) for this service... Instance "postdb2", status READY, has 1 handler(s) for this service... The command completed successfully 测试结果:正常 lsnrctl status ―――查看监听器的状态(postdb2) LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 05-JUL-2008 12:12:12 Copyright (c) 1991, 2005, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER_POSTDB2 Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production Start Date 04-JUL-2008 17:25:30 Uptime 0 days 18 hr. 46 min. 42 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /opt/app/oracle/ product/10.2.0/db1/network/admin/listener.ora Listener Log File /opt/app/oracle/ product/10.2.0/db1/network/log/listener_postdb2.log Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.118.5.17)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.118.5.16)(PORT=1521))) Services Summary... Service "PLSExtProc" has 1 instance(s). Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service... Service "db" has 2 instance(s). Instance "postdb1", status READY, has 1 handler(s) for this service... Instance "postdb2", status READY, has 2 handler(s) for this service... Service "postdb" has 2 instance(s). Instance "postdb1", status READY, has 1 handler(s) for this service... Instance "postdb2", status READY, has 2 handler(s) for this service... Service "postdbXDB" has 2 instance(s). Instance "postdb1", status READY, has 1 handler(s) for this service... Instance "postdb2", status READY, has 1 handler(s) for this service... Service "postdb_XPT" has 2 instance(s). Instance "postdb1", status READY, has 1 handler(s) for this service... Instance "postdb2", status READY, has 2 handler(s) for this service... The command completed successfully 测试结果:正常 srvctl status instance -d postdb -i postdb1 ――――单个实例1的状态 实例 postdb1 正在节点 postdb1 上运行 测试结果:正常 srvctl status instance -d postdb -i postdb2 ――――单个实例2的状态 实例 postdb2 正在节点 postdb2 上运行 测试结果:正常 srvctl status service -d postdb -s db ――――数据库全局命名服务db的状态 服务 db 正在实例 postdb2, postdb1 上运行 测试结果:正常 起停两个节点监听: srvctl start listener -n postdb1 srvctl stop listener –n postdb1 srvctl start listener -n postdb2 srvctl stop listener –n postdb2 2.测试起停rac集群数据库 停止 Oracle RAC 10g 集群 emctl stop dbconsole srvctl stop instance -d postdb -i postdb1 srvctl stop asm -n postdb1 srvctl stop nodeapps -n postdb1 srvctl stop instance -d postdb -i postdb2 srvctl stop asm -n postdb2 srvctl stop nodeapps -n postdb2 测试结果:正常 启动 Oracle RAC 10g 集群 srvctl start nodeapps -n postdb1 srvctl start nodeapps -n postdb2 srvctl start asm -n postdb2 srvctl start instance -d postdb -i postdb2 srvctl start asm -n postdb1 srvctl start instance -d postdb -i postdb1 emctl start dbconsole                 测试结果:正常 3.查看集群中所有正在运行的实例 sqlplus system/postdb@postdb SELECT inst_id, instance_number inst_no, instance_name inst_name, parallel, status, database_status ,database_status, host_name host FROM gv$instance ORDER BY inst_id; INST_ID INST_NO INST_NAME PAR STATUS DATABASE_STATUS ---------- ---------- ---------------- --- ------------ ----------------- DATABASE_STATUS ----------------- HOST ---------------------------------------------------------------- 1 1 postdb1 YES OPEN ACTIVE ACTIVE postdb1 2 2 postdb2 YES OPEN ACTIVE ACTIVE postdb2 测试结果:正常 4.检查rac数据库的高可用性 停掉Rac数据库其中一个节点的实例,数据库可以对外提供服务 1、登陆数据库 Sqlplus system/postdb@postdb 2、查看其登陆的节点 Select host_name from v$instance; HOST_NAME ---------------------------------------------------------------- postdb1 3、停止其登陆的节点的实例 srvctl stop instance -d postdb -i postdb1 4、重新连接 Sqlplus system/postdb@postdb Select host_name from v$instance; HOST_NAME ---------------------------------------------------------------- Postdb2 测试结果:正常 5.测试高可用性 srvctl status database -d postdb 实例 postdb1 正在节点 postdb1 上运行 实例 postdb2 正在节点 postdb2 上运行 srvctl stop instance -d postdb -i postdb2 srvctl status database -d postdb 实例 postdb1 正在节点 postdb1 上运行 实例 postdb2 没有在 postdb2 节点上运行 srvctl stop nodeapps -n postdb2 srvctl status nodeapps -n postdb2 VIP 没有运行的节点: postdb2 GSD 没有运行的节点: postdb2 监听程序未在节点上运行: postdb2 ONS 守护程序未在节点上运行:postdb2 [root@postdb2 ~]# init 0 通过客户端连接数据库 C:\Documents and Settings\wei.ye>sqlplus system/postdb@postdb SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 7月 5 15:19:52 2008 Copyright (c) 1982, 2005, Oracle. All rights reserved. 连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production With the Partitioning, Real Application Clusters, OLAP and Data Mining options SQL> select host_name from v$instance; HOST_NAME ---------------------------------------------------------------- postdb1 6.测试rac数据库的负载均衡功能 连续通过客户端登陆rac数据库,可以看到会话连接到rac数据库中的不同实例 sqlplus system/postdb@postdb SQL> SELECT inst_id, username, sid, serial# FROM gv$session WHERE username is not null; ―――查看会话在实例上的分布情况 INST_ID USERNAME SID SERIAL# ---------- ------------------------------ ---------- ---------- 2 DBSNMP 505 1690 2 SYSTEM 508 6139 2 SYSMAN 509 864 2 POST_KF 510 512 2 SYSMAN 512 4464 2 SYSTEM 514 12034 2 DBSNMP 517 10665 2 SYSTEM 520 2451 2 SYS 522 19 2 SYS 523 6 2 SYS 524 3 INST_ID USERNAME SID SERIAL# ---------- ------------------------------ ---------- ---------- 2 SYS 525 6 2 SYSMAN 526 251 2 SYSMAN 530 42 1 POST_KF 498 1625 1 DBSNMP 499 624 1 DBSNMP 500 3926 1 SYSTEM 501 1367 1 POST_KF 502 1302 1 DBSNMP 503 1444 1 DBSNMP 504 3272 1 POST_KF 506 339 INST_ID USERNAME SID SERIAL# ---------- ------------------------------ ---------- ---------- 1 POST_KF 507 7148 1 POST_KF 508 1357 1 POST_KF 509 4001 1 POST_KF 510 7922 1 POST_KF 513 433 1 SYSMAN 514 39 1 POST_KF 515 3022 1 POST_KF 517 2415 1 DBSNMP 518 1782 1 SYS 525 19 1 SYS 526 3 INST_ID USERNAME SID SERIAL# ---------- ------------------------------ ---------- ---------- 1 SYS 527 8 1 POST_KF 531 1222 1 SYS 534 14 7.连接em管理控制台 登陆http://10.118.5.15:1158/em 正常登陆 测试结果:正常 六、定时自动备份的实施 1.备份任务的实施 备份任务在节点postdb1上执行: 6.1、从存储划分磁盘映射到节点postdb1,建议根据业务量的增长情况划分一个大的磁盘空间便于备份管理,该盘阵主要用来备份数据库的数据。 [root@postdb1 ~]# fdisk -l Disk /dev/sda: 146.6 GB, 146685296640 bytes 255 heads, 63 sectors/track, 17833 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1288 10241437+ 83 Linux /dev/sda3 1289 2818 12289725 82 Linux swap /dev/sda4 2819 17833 120607987+ 5 Extended /dev/sda5 2819 4093 10241406 83 Linux /dev/sda6 4094 5368 10241406 83 Linux /dev/sda7 5369 6643 10241406 83 Linux /dev/sda8 6644 9830 25599546 83 Linux /dev/sda9 9831 17833 64284066 83 Linux Disk /dev/sdb: 214.7 GB, 214748364800 bytes 255 heads, 63 sectors/track, 26108 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System Disk /dev/sdc: 215.8 GB, 215822106624 bytes 255 heads, 63 sectors/track, 26238 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdc1 1 26238 210756703+ 83 Linux Disk /dev/sdd: 216.8 GB, 216895848448 bytes 255 heads, 63 sectors/track, 26369 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdd1 1 26369 211808961 83 Linux Disk /dev/sde: 217.9 GB, 217969590272 bytes 255 heads, 63 sectors/track, 26499 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sde1 1 26499 212853186 83 Linux Disk /dev/sdf: 858.9 GB, 858993459200 bytes 255 heads, 63 sectors/track, 104433 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sdf doesn't contain a valid partition table Disk /dev/sdg: 219.0 GB, 219043332096 bytes 255 heads, 63 sectors/track, 26630 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdg1 1 37 297171 83 Linux /dev/sdg2 38 26630 213608272+ 5 Extended /dev/sdg5 38 74 297171 83 Linux /dev/sdg6 75 111 297171 83 Linux /dev/sdg7 112 148 297171 83 Linux /dev/sdg8 149 185 297171 83 Linux /dev/sdg9 186 2676 20008926 83 Linux Disk /dev/sdh: 220.1 GB, 220117073920 bytes 255 heads, 63 sectors/track, 26761 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdh1 1 26761 214957701 83 Linux Disk /dev/sdi: 158.1 GB, 158177689600 bytes 255 heads, 63 sectors/track, 19230 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sdi doesn't contain a valid partition table 如上:/dev/sdf为备份磁盘,约858G 6.2、fdisk /dev/sdi # sdn需根据盘阵映射到服务器上的实际的值替代 6.3、建立挂载点目录,并修改权限及属主、属组。 mkdir /database_backup 6.4、建立文件系统,并挂载。 mkfs -t ext3 /dev/sdf1 # sdnn需根据分区以后的实际的值替代 mount /dev/sdf1 /database_backup # sdnn需根据分区以后的实际的值替代 chown -R oracle.dba /database_backup chmod 775 /database_backup 6.5、编辑/etc/fstab给新建的文件系统增加一行,让文件系统每次重启以后自动挂载。 vi /etc/fastab(添加如下行) /dev/sdf1 /database_backup ext3 defaults 0 0 # sdnn需根据分区以后的实际的值替代 6.6、crontab每周周六晚上2点0分执行一次全备份(包括参数文件、控制文件、数据文件、归档日志),每天晚上1点0分执行一次增量备份(包括控制文件、数据文件增量备份、归档日志),备份保留21天,自动删除21天以前的备份数据。 备份脚本存放在/opt/app/oracle/backup_scripts/下,分别为postdb_full_backup.sh,postdb_incre_backup.sh,full_backup.sh,incre_backup.sh备份过程的log在/opt/app/oracle/backup_scripts/下的postdb_full_backup.log,postdb_incre_backup.log 6.6.1 在oracle用户下执行crontab –e编辑crontab列表添加如下行: 0 2 * * 6 /opt/app/oracle/backup_scripts/full_backup.sh >>/opt/app/oracle/backup_scripts/postdb_full_backup.log 2>&1 0 1 * * * /opt/app/oracle/backup_scripts/incre_backup.sh >>/opt/app/oracle/backup_scripts/postdb_incre_backup.log 2>&1 6.6.2 生成入口shell文件,文件名:full_backup.sh incre_backup.sh Su – oracle Vi full_backup.sh Cd /opt/app/oracle/backup_scripts #full_backup.sh export ORACLE_BASE=/opt/app/oracle export ORACLE_HOME=/opt/app/oracle/product/10.2.0/db1 export ORACLE_SID=postdb1 export LANG=zh_CN.GB18030 /opt/app/oracle/product/10.2.0/db1/bin/rman cmdfile= /opt/app/oracle/backup_scripts/postdb_full_backup.sh Su – oracle Cd /opt/app/oracle/backup_scripts Vi incre_backup.sh #incre_backup.sh export ORACLE_BASE=/opt/app/oracle export ORACLE_HOME=/opt/app/oracle/product/10.2.0/db1 export ORACLE_SID=postdb1 export LANG=zh_CN.GB18030 /opt/app/oracle/product/10.2.0/db1/bin/rman cmdfile= /opt/app/oracle/backup_scripts/postdb_incre_backup.sh 6.6.3 rman脚本 Su – oracle Cd /opt/app/oracle/backup_scripts Vi postdb_full_backup.sh #postdb_full_backup.sh connect target / run{ configure retention policy to recovery window of 21 days; allocate channel c1 type disk; allocate channel c2 type disk; allocate channel c3 type disk; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/database_backup/%F.bck'; CONFIGURE CONTROLFILE AUTOBACKUP ON; BACKUP SPFILE format '/database_backup/sp_%s_%p_%t'; backup incremental level 0 cumulative tag '%TAG' database format '/database_backup/db_%s_%p_%t'; sql 'alter system archive log current'; backup tag '%TAG' archivelog all not backed up delete all input format '/database_backup/arc_%s_%p_%t'; backup current controlfile format '/database_backup/cf_%s_%p_%t'; delete noprompt obsolete; release channel c1; release channel c2; release channel c3; } Su – oracle Cd /opt/app/oracle/backup_scripts Vi postdb_incre_backup.sh #postdb_incre_backup.sh connect target / run { allocate channel c1 type disk; backup incremental level 1 cumulative as BACKUPSET tag '%TAG' database format '/database_backup/db_%s_%p_%t' include current controlfile; sql 'alter system archive log current'; backup as BACKUPSET tag '%TAG' archivelog all not backed up delete all input format '/database_backup/arc_%s_%p_%t'; delete noprompt obsolete; release channel c1; } Cd /opt/app/oracle/backup_scripts Chown oracle:dba * Chmod 775 * 2.备份系统测试 1执行如下的全备份脚本: /opt/app/oracle/backup_scripts/full_backup.sh 查看屏幕输出是否有报错。 输出如下: [oracle@postdb1 backup_scripts]$ /opt/app/oracle/backup_scripts/full_backup.sh Recovery Manager: Release 10.2.0.1.0 - Production on Sun Aug 31 20:36:13 2008 Copyright (c) 1982, 2005, Oracle. All rights reserved. RMAN> connect target * 2> run{ 3> configure retention policy to recovery window of 21 days; 4> allocate channel c1 type disk; 5> allocate channel c2 type disk; 6> allocate channel c3 type disk; 7> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/database_backup/%F.bck'; 8> CONFIGURE CONTROLFILE AUTOBACKUP ON; 9> BACKUP SPFILE format '/database_backup/sp_%s_%p_%t'; 10> backup incremental level 0 cumulative tag '%TAG' database format '/database_backup/db_%s_%p_%t'; 11> sql 'alter system archive log current'; 12> backup tag '%TAG' archivelog all not backed up delete all input format '/database_backup/arc_%s_%p_%t'; 13> backup current controlfile format '/database_backup/cf_%s_%p_%t'; 14> delete noprompt obsolete; 15> release channel c1; 16> release channel c2; 17> release channel c3; 18> } 19> connected to target database: POSTDB (DBID=3896756965) using target database control file instead of recovery catalog new RMAN configuration parameters: CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 21 DAYS; new RMAN configuration parameters are successfully stored allocated channel: c1 channel c1: sid=536 instance=postdb1 devtype=DISK allocated channel: c2 channel c2: sid=511 instance=postdb1 devtype=DISK allocated channel: c3 channel c3: sid=510 instance=postdb1 devtype=DISK new RMAN configuration parameters: CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/database_backup/%F.bck'; new RMAN configuration parameters are successfully stored new RMAN configuration parameters: CONFIGURE CONTROLFILE AUTOBACKUP ON; new RMAN configuration parameters are successfully stored Starting backup at 31-AUG-08 channel c1: starting full datafile backupset channel c1: specifying datafile(s) in backupset including current SPFILE in backupset channel c1: starting piece 1 at 31-AUG-08 channel c1: finished piece 1 at 31-AUG-08 piece handle=/database_backup/sp_1_1_664230976 tag=TAG20080831T203616 comment=NONE channel c1: backup set complete, elapsed time: 00:00:02 Finished backup at 31-AUG-08 Starting backup at 31-AUG-08 channel c1: starting incremental level 0 datafile backupset channel c1: specifying datafile(s) in backupset input datafile fno=00002 name=+DATA1/postdb/datafile/undotbs1.260.664225155 input datafile fno=00005 name=+DATA1/postdb/datafile/users.264.664225221 channel c1: starting piece 1 at 31-AUG-08 channel c2: starting incremental level 0 datafile backupset channel c2: specifying datafile(s) in backupset input datafile fno=00004 name=+DATA1/postdb/datafile/undotbs2.263.664225193 channel c2: starting piece 1 at 31-AUG-08 channel c3: starting incremental level 0 datafile backupset channel c3: specifying datafile(s) in backupset input datafile fno=00001 name=+DATA1/postdb/datafile/system.259.664225145 input datafile fno=00003 name=+DATA1/postdb/datafile/sysaux.261.664225183 channel c3: starting piece 1 at 31-AUG-08 channel c2: finished piece 1 at 31-AUG-08 piece handle=/database_backup/db_3_1_664230979 tag=%TAG comment=NONE channel c2: backup set complete, elapsed time: 00:00:25 channel c3: finished piece 1 at 31-AUG-08 piece handle=/database_backup/db_4_1_664230979 tag=%TAG comment=NONE channel c3: backup set complete, elapsed time: 00:00:25 channel c1: finished piece 1 at 31-AUG-08 piece handle=/database_backup/db_2_1_664230978 tag=%TAG comment=NONE channel c1: backup set complete, elapsed time: 00:00:29 Finished backup at 31-AUG-08 Starting Control File and SPFILE Autobackup at 31-AUG-08 piece handle=/database_backup/c-3896756965-20080831-00.bck comment=NONE Finished Control File and SPFILE Autobackup at 31-AUG-08 sql statement: alter system archive log current Starting backup at 31-AUG-08 current log archived channel c1: starting archive log backupset channel c1: specifying archive log(s) in backup set input archive log thread=1 sequence=12 recid=1 stamp=664226296 channel c1: starting piece 1 at 31-AUG-08 channel c2: starting archive log backupset channel c2: specifying archive log(s) in backup set input archive log thread=1 sequence=13 recid=2 stamp=664231012 input archive log thread=1 sequence=14 recid=5 stamp=664231018 channel c2: starting piece 1 at 31-AUG-08 channel c3: starting archive log backupset channel c3: specifying archive log(s) in backup set input archive log thread=2 sequence=1 recid=3 stamp=664231068 input archive log thread=2 sequence=2 recid=4 stamp=664231071 channel c3: starting piece 1 at 31-AUG-08 channel c1: finished piece 1 at 31-AUG-08 piece handle=/database_backup/arc_6_1_664231018 tag=%TAG comment=NONE channel c1: backup set complete, elapsed time: 00:00:02 channel c1: deleting archive log(s) archive log filename=+DATA1/postdb/1_12_664225125.dbf recid=1 stamp=664226296 channel c3: finished piece 1 at 31-AUG-08 piece handle=/database_backup/arc_8_1_664231018 tag=%TAG comment=NONE channel c3: backup set complete, elapsed time: 00:00:02 channel c3: deleting archive log(s) archive log filename=+DATA1/postdb/2_1_664225125.dbf recid=3 stamp=664231068 archive log filename=+DATA1/postdb/2_2_664225125.dbf recid=4 stamp=664231071 channel c2: finished piece 1 at 31-AUG-08 piece handle=/database_backup/arc_7_1_664231018 tag=%TAG comment=NONE channel c2: backup set complete, elapsed time: 00:00:06 channel c2: deleting archive log(s) archive log filename=+DATA1/postdb/1_13_664225125.dbf recid=2 stamp=664231012 archive log filename=+DATA1/postdb/1_14_664225125.dbf recid=5 stamp=664231018 Finished backup at 31-AUG-08 Starting backup at 31-AUG-08 channel c1: starting full datafile backupset channel c1: specifying datafile(s) in backupset including current control file in backupset channel c1: starting piece 1 at 31-AUG-08 channel c1: finished piece 1 at 31-AUG-08 piece handle=/database_backup/cf_9_1_664231025 tag=TAG20080831T203705 comment=NONE channel c1: backup set complete, elapsed time: 00:00:01 Finished backup at 31-AUG-08 Starting Control File and SPFILE Autobackup at 31-AUG-08 piece handle=/database_backup/c-3896756965-20080831-01.bck comment=NONE Finished Control File and SPFILE Autobackup at 31-AUG-08 RMAN retention policy will be applied to the command RMAN retention policy is set to recovery window of 21 days no obsolete backups found released channel: c1 released channel: c2 released channel: c3 Recovery Manager complete. [oracle@postdb1 backup_scripts]$ 2、执行如下的增量备份脚本: /opt/app/oracle/backup_scripts/incre_backup.sh 查看屏幕输出是否有报错。 屏幕输出如下: [oracle@postdb1 backup_scripts]$ /opt/app/oracle/backup_scripts/incre_backup.sh Recovery Manager: Release 10.2.0.1.0 - Production on Sun Aug 31 20:38:37 2008 Copyright (c) 1982, 2005, Oracle. All rights reserved. RMAN> connect target * 2> run { 3> allocate channel c1 type disk; 4> backup incremental level 1 cumulative as BACKUPSET tag '%TAG' database format '/database_backup/db_%s_%p_%t' include current controlfile; 5> sql 'alter system archive log current'; 6> backup as BACKUPSET tag '%TAG' archivelog all not backed up delete all input format '/database_backup/arc_%s_%p_%t'; 7> delete noprompt obsolete; 8> release channel c1; 9> } 10> connected to target database: POSTDB (DBID=3896756965) using target database control file instead of recovery catalog allocated channel: c1 channel c1: sid=510 instance=postdb1 devtype=DISK Starting backup at 31-AUG-08 channel c1: starting incremental level 1 datafile backupset channel c1: specifying datafile(s) in backupset input datafile fno=00002 name=+DATA1/postdb/datafile/undotbs1.260.664225155 input datafile fno=00004 name=+DATA1/postdb/datafile/undotbs2.263.664225193 input datafile fno=00001 name=+DATA1/postdb/datafile/system.259.664225145 input datafile fno=00003 name=+DATA1/postdb/datafile/sysaux.261.664225183 input datafile fno=00005 name=+DATA1/postdb/datafile/users.264.664225221 channel c1: starting piece 1 at 31-AUG-08 channel c1: finished piece 1 at 31-AUG-08 piece handle=/database_backup/db_11_1_664231119 tag=%TAG comment=NONE channel c1: backup set complete, elapsed time: 00:00:35 channel c1: starting incremental level 1 datafile backupset channel c1: specifying datafile(s) in backupset including current control file in backupset channel c1: starting piece 1 at 31-AUG-08 channel c1: finished piece 1 at 31-AUG-08 piece handle=/database_backup/db_12_1_664231154 tag=%TAG comment=NONE channel c1: backup set complete, elapsed time: 00:00:01 Finished backup at 31-AUG-08 Starting Control File and SPFILE Autobackup at 31-AUG-08 piece handle=/database_backup/c-3896756965-20080831-02.bck comment=NONE Finished Control File and SPFILE Autobackup at 31-AUG-08 sql statement: alter system archive log current Starting backup at 31-AUG-08 current log archived channel c1: starting archive log backupset channel c1: specifying archive log(s) in backup set input archive log thread=1 sequence=15 recid=6 stamp=664231158 input archive log thread=1 sequence=16 recid=8 stamp=664231162 input archive log thread=2 sequence=3 recid=7 stamp=664231215 input archive log thread=2 sequence=4 recid=9 stamp=664231221 channel c1: starting piece 1 at 31-AUG-08 channel c1: finished piece 1 at 31-AUG-08 piece handle=/database_backup/arc_14_1_664231167 tag=%TAG comment=NONE channel c1: backup set complete, elapsed time: 00:00:02 channel c1: deleting archive log(s) archive log filename=+DATA1/postdb/1_15_664225125.dbf recid=6 stamp=664231158 archive log filename=+DATA1/postdb/1_16_664225125.dbf recid=8 stamp=664231162 archive log filename=+DATA1/postdb/2_3_664225125.dbf recid=7 stamp=664231215 archive log filename=+DATA1/postdb/2_4_664225125.dbf recid=9 stamp=664231221 Finished backup at 31-AUG-08 Starting Control File and SPFILE Autobackup at 31-AUG-08 piece handle=/database_backup/c-3896756965-20080831-03.bck comment=NONE Finished Control File and SPFILE Autobackup at 31-AUG-08 RMAN retention policy will be applied to the command RMAN retention policy is set to recovery window of 21 days no obsolete backups found released channel: c1 Recovery Manager complete. 3、cd /database_backup Ls -ls 查看备份是否在此目录下生成 [oracle@postdb1 backup_scripts]$ cd /database_backup [oracle@postdb1 database_backup]$ ls -la 总用量 1216376 drwxrwxr-x 3 oracle dba 4096 8月 31 20:39 . drwxr-xr-x 30 root root 4096 8月 31 20:21 .. -rw-r----- 1 oracle oinstall 393728 8月 31 20:39 arc_14_1_664231167 -rw-r----- 1 oracle oinstall 127066624 8月 31 20:37 arc_6_1_664231018 -rw-r----- 1 oracle oinstall 17121792 8月 31 20:37 arc_7_1_664231018 -rw-r----- 1 oracle oinstall 12087296 8月 31 20:37 arc_8_1_664231018 -rw-r----- 1 oracle oinstall 15368192 8月 31 20:36 c-3896756965-20080831-00.bck -rw-r----- 1 oracle oinstall 15368192 8月 31 20:37 c-3896756965-20080831-01.bck -rw-r----- 1 oracle oinstall 15368192 8月 31 20:39 c-3896756965-20080831-02.bck -rw-r----- 1 oracle oinstall 15368192 8月 31 20:39 c-3896756965-20080831-03.bck -rw-r----- 1 oracle oinstall 15335424 8月 31 20:37 cf_9_1_664231025 -rw-r----- 1 oracle oinstall 614400 8月 31 20:39 db_11_1_664231119 -rw-r----- 1 oracle oinstall 15335424 8月 31 20:39 db_12_1_664231154 -rw-r----- 1 oracle oinstall 458252288 8月 31 20:36 db_2_1_664230978 -rw-r----- 1 oracle oinstall 3899392 8月 31 20:36 db_3_1_664230979 -rw-r----- 1 oracle oinstall 532561920 8月 31 20:36 db_4_1_664230979 drwx------ 2 oracle dba 16384 8月 31 19:06 lost+found -rw-r----- 1 oracle oinstall 98304 8月 31 20:36 sp_1_1_664230976 [oracle@postdb1 database_backup]$ 3.恢复测试 1、利用crontab脚本,执行rac数据库的rman全备份及增量备份 2、在一台服务器上执行,停止数据库两个节点的实例,并停止em控制台 emctl stop dbconsole srvctl stop instance -d postdb -i postdb1 srvctl stop instance -d postdb -i postdb2 3、删除参数文件,模拟数据丢失 登录到第一个节点的服务器, su - oracle Export ORACLE_SID=+ASM1 Asmcmd Cd data1/postdb Rm spfilepostdb.ora 5、恢复参数文件(从单台实例进行恢复) Oracle用户下: Su - oracle rman target / startup --发现报错,起不来 set dbid 3896756965 ――此DBID从/backup_data目录下控制文件备份得到。 restore spfile from '/database_backup/c-3896756965-20080901-11.bck'; ――是/database_backup下时间最新的控制文件的备份。 shutdown immediate; startup nomount; 6、set dbid 3896756965 restore controlfile from '/database_backup/c-3896756965-20080901-11.bck'; ――是/backup_data下时间最新的控制文件的备份。 alter database mount; 7、restore database; 8、recover database; 9、alter database open resetlogs;

下载文档到电脑,查找使用更方便

文档的实际排版效果,会与网站的显示效果略有不同!!

需要 10 金币 [ 分享文档获得金币 ] 1 人已下载

下载文档