# 本文为该系列第四部分,描述Oracle手工建库&Oracle Net配置及Oracle双机切换测试
# 第一部分: AIX 6.1配置HACMP 6.1
# 第二部分: AIX 6.1安装Oracle 11gR2
# 第三部分: AIX 6.1 Cloning an Oracle Home
一. A机和B机启动集群
smit clstart
Start Cluster Services on these nodes [hacmp1,hacmp2]
Manage Resource Groups Automatically
BROADCAST message at startup? false
Startup Cluster Information Daemon? false
Ignore verification errors? false
Automatically correct errors found during Interactively
cluster start?
# 此部分A机操作即可
db_name=hadb
control_files='/oradata/hadb/control01.ctl'
undo_management=auto
$
2. 目录赋权
# chown oracle:oinstall /oradata
3. 创建相关目录
$ mkdir hadb
CREATE DATABASE hadb
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
CONTROLFILE REUSE
MAXDATAFILES 10
MAXINSTANCES 2
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
LOGFILE
GROUP 1 ('/oradata/hadb/redo01.log', '/oradata/hadb/redo02.log') SIZE 30M,
GROUP 2 ('/oradata/hadb/redo03.log', '/oradata/hadb/redo04.log') SIZE 30M,
GROUP 3 ('/oradata/hadb/redo05.log', '/oradata/hadb/redo06.log') SIZE 30M
MAXLOGFILES 5
MAXLOGHISTORY 100
NOARCHIVELOG
FORCE LOGGING
EXTENT MANAGEMENT LOCAL
DATAFILE '/oradata/hadb/system01.dbf' SIZE 300M AUTOEXTEND ON
SYSAUX DATAFILE '/oradata/hadb/sysaux01.dbf' SIZE 300M AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TABLESPACE users DATAFILE '/oradata/hadb/users.dbf' SIZE 300M AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE temp TEMPFILE '/oradata/hadb/temp.dbf' SIZE 500M
UNDO TABLESPACE undo DATAFILE '/oradata/hadb/undo.dbf' SIZE 1G;
$
5. 创建SPFILE启动实例
SQL*Plus: Release 11.2.0.3.0 Production on Sun Jun 23 11:50:35 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
File created.
SQL> startup nomount
Total System Global Area 250560512 bytes
Fixed Size 2220392 bytes
Variable Size 192941720 bytes
Database Buffers 50331648 bytes
Redo Buffers 5066752 bytes
SQL>
6. 执行建库脚本
Database created.
SQL>
7. 创建数据字典,动态性能视图和PL/SQL包
SQL> @$ORACLE_HOME/sqlplus/admin/pupbld.sql
1. A机配置监听
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = hadb)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = hadb)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hacmp_svc)(PORT = 1521))
)
ADR_BASE_LISTENER = /u01/app/oracle
$
2. B机测试A机监听
hacmp2
$ sqlplus system/oracle@192.168.128.103:1521/hadb
SQL*Plus: Release 11.2.0.3.0 Production on Sun Jun 23 12:44:14 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SQL>
3. 把A机监听配置文件发送到B机相关目录下
oracle@192.168.128.100's password:
listener.ora 100% 464 0.5KB/s 00:00
$
1. 把A机SPFILE发送到B机相关目录下
oracle@192.168.128.100's password:
spfilehadb.ora 100% 1536 1.5KB/s 00:00
$
su - oracle -c "lsnrctl start;echo 'startup' | sqlplus / as sysdba"
# cat stop.sh
su - oracle -c "lsnrctl stop;echo 'shutdown immediate' | sqlplus / as sysdba"
#
Stop now, on system restart or both now
Stop Cluster Services on these nodes [hacmp1]
BROADCAST cluster shutdown? true
Select an Action on Resource Groups Move Resource Groups
2. 查看B机状态
hacmp2
$lsnrctl status
LSNRCTL for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production on 23-JUN-2013 12:53:19
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hacmp_svc)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
Start Date 23-JUN-2013 12:52:49
Uptime 0 days 0 hr. 0 min. 31 sec
Trace Level off
Security ON: Local OS Authentication
SNMP ON
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/hacmp2/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.128.103)(PORT=1521)))
Services Summary...
Service "hadb" has 1 instance(s).
Instance "hadb", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
$ ps -ef | grep ora_
oracle 4915348 1 0 12:53:13 - 0:00 ora_reco_hadb
oracle 5505200 1 0 12:53:12 - 0:00 ora_ckpt_hadb
oracle 5570666 1 0 12:53:12 - 0:00 ora_vktm_hadb
oracle 6029458 1 0 12:53:10 - 0:00 ora_psp0_hadb
oracle 6094930 1 0 12:53:13 - 0:00 ora_mmon_hadb
oracle 6291486 1 1 12:53:12 - 0:00 ora_dia0_hadb
oracle 6488282 11534576 0 12:53:28 pts/1 0:00 grep ora_
oracle 6553742 1 0 12:53:12 - 0:00 ora_diag_hadb
oracle 7405658 1 0 12:53:12 - 0:00 ora_dbw0_hadb
oracle 8388718 1 0 12:53:12 - 0:00 ora_dbrm_hadb
oracle 8454184 1 0 12:53:13 - 0:00 ora_mmnl_hadb
oracle 9634026 1 0 12:53:12 - 0:00 ora_lgwr_hadb
oracle 9699506 1 0 12:53:12 - 0:00 ora_mman_hadb
oracle 10420306 1 0 12:53:12 - 0:00 ora_smon_hadb
oracle 11010284 1 0 12:53:10 - 0:00 ora_pmon_hadb
oracle 11665490 1 0 12:53:12 - 0:00 ora_gen0_hadb
oracle 11927746 1 0 12:53:19 - 0:00 ora_qmnc_hadb
$
# B机监听正常启动,Oracle进程正常启动
3. A机测试B机监听
hacmp1
$ sqlplus system/oracle@192.168.128.103:1521/hadb
SQL*Plus: Release 11.2.0.3.0 Production on Sun Jun 23 12:56:27 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SQL>
# Oracle在B机运行正常
smit clstart
Start Cluster Services on these nodes [hacmp1]
Manage Resource Groups Automatically
BROADCAST message at startup? false
Startup Cluster Information Daemon? false
Ignore verification errors? false
Automatically correct errors found during Interactively
cluster start?
5. 关闭B机集群
Stop now, on system restart or both now
Stop Cluster Services on these nodes [hacmp2]
BROADCAST cluster shutdown? true
Select an Action on Resource Groups Move Resource Groups
hacmp1
$ lsnrctl status
LSNRCTL for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production on 23-JUN-2013 13:00:24
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hacmp_svc)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
Start Date 23-JUN-2013 12:59:28
Uptime 0 days 0 hr. 0 min. 55 sec
Trace Level off
Security ON: Local OS Authentication
SNMP ON
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/hacmp1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.128.103)(PORT=1521)))
Services Summary...
Service "hadb" has 1 instance(s).
Instance "hadb", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
$ ps -ef | grep ora_
oracle 6488124 1 0 12:59:53 - 0:00 ora_q001_hadb
oracle 6750354 1 0 12:59:34 - 0:00 ora_vktm_hadb
oracle 9371846 1 0 12:59:40 - 0:00 ora_p001_hadb
oracle 9699546 1 0 12:59:34 - 0:00 ora_gen0_hadb
oracle 9896064 1 0 12:59:32 - 0:00 ora_pmon_hadb
oracle 10158254 1 0 12:59:34 - 0:00 ora_lgwr_hadb
oracle 11010238 1 0 12:59:35 - 0:00 ora_smon_hadb
oracle 11796574 1 0 12:59:34 - 0:00 ora_ckpt_hadb
oracle 11993342 1 0 12:59:43 - 0:00 ora_qmnc_hadb
oracle 12124166 1 0 12:59:40 - 0:00 ora_p000_hadb
oracle 12255344 1 0 12:59:40 - 0:00 ora_p002_hadb
oracle 12714006 1 0 12:59:34 - 0:00 ora_dbrm_hadb
oracle 12910734 1 0 12:59:35 - 0:00 ora_mmon_hadb
oracle 12976130 1 0 12:59:34 - 0:00 ora_diag_hadb
oracle 14549208 1 0 12:59:34 - 0:00 ora_dbw0_hadb
oracle 15794294 1 0 12:59:35 - 0:00 ora_reco_hadb
oracle 15859820 1 0 12:59:35 - 0:00 ora_mmnl_hadb
oracle 16449682 1 0 12:59:34 - 0:00 ora_mman_hadb
oracle 16515276 1 0 12:59:33 - 0:00 ora_psp0_hadb
oracle 16777252 1 0 12:59:53 - 0:00 ora_q000_hadb
oracle 16974000 1 0 12:59:34 - 0:00 ora_dia0_hadb
oracle 17367112 14483560 0 13:00:30 pts/0 0:00 grep ora_
$
# A机监听正常启动,Oracle进程正常启动
7. B机测试A机监听
hacmp2
$ sqlplus system/oracle@192.168.128.103:1521/hadb
SQL*Plus: Release 11.2.0.3.0 Production on Sun Jun 23 13:00:46 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SQL>
# Oracle在A机运行正常
smit clstart
Start Cluster Services on these nodes [hacmp2]
Manage Resource Groups Automatically
BROADCAST message at startup? false
Startup Cluster Information Daemon? false
Ignore verification errors? false
Automatically correct errors found during Interactively
cluster start?
转载于:https://blog.51cto.com/xin23/1228585