AIX 6.1 + HACMP 6.1 + Oracle 11g雙機實施 (4) --- Oracle手工建庫&Oracle Net配置及Oracle雙機切換測試




# 本文爲該系列第四部分,描述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 now, on system restart or both                now                                                                                                                                                                                
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?




二.      Oracle手工建庫


#     此部分A機操作即可



1.      創建PFILE

$ cd $ORACLE_HOME/dbs
$ cat $ORACLE_HOME/dbs/inithadb.ora
db_name=hadb
control_files='/oradata/hadb/control01.ctl'
undo_management=auto

$



2.      目錄賦權


# chown oracle:oinstall /oradata



3.      創建相關目錄


$ cd /oradata

$ mkdir hadb



4.      創建建庫腳本

$ cat database.sql
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啓動實例


$ sqlplus / as sysdba

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.

SQL> create spfile from pfile;

File created.

SQL>
startup nomount
ORACLE instance started.

Total System Global Area  250560512 bytes
Fixed Size                  2220392 bytes
Variable Size             192941720 bytes
Database Buffers           50331648 bytes
Redo Buffers                5066752 bytes

SQL>



6.      執行建庫腳本


SQL> @/oradata/database.sql

Database created.

SQL>



7.      創建數據字典,動態性能視圖和PL/SQL包


SQL> @$ORACLE_HOME/rdbms/admin/catproc.sql

SQL> @$ORACLE_HOME/sqlplus/admin/pupbld.sql




三.      Oracle Net配置


1.      A機配置監聽


$ cat listener.ora
# 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機監聽


$ hostname
hacmp2
$ sqlplus system/[email protected]: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機相關目錄下


$ scp listener.ora 192.168.128.100:/u01/app/oracle/product/11.2.0/dbhome_1/network/admin
[email protected]'s password:
listener.ora                                                                                                                                                                                               100%  464     0.5KB/s   00:00  

$




四.      Oracle雙機配置


1.      把A機SPFILE發送到B機相關目錄下


$ cd $ORACLE_HOME/dbs
$ scp spfilehadb.ora 192.168.128.100:/u01/app/oracle/product/11.2.0/dbhome_1/dbs
[email protected]'s password:
spfilehadb.ora                                                                                                                                                                                             100% 1536     1.5KB/s   00:00  

$



2.      配置應用服務器啓停腳本

#     A機和B機都要操作
# cat start.sh
su - oracle -c "lsnrctl start;echo 'startup' | sqlplus / as sysdba"
#
cat stop.sh
su - oracle -c "lsnrctl stop;echo 'shutdown immediate' | sqlplus / as sysdba"

#




五.      Oracle雙機切換測試


1.      關閉A機集羣

smit clstop

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機狀態


$hostname
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機監聽


$ hostname
hacmp1
$
sqlplus system/[email protected]: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機運行正常



4.     開啓A機集羣

smit clstart


Start now, on system restart or both                now                                                                                                                                                                                
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機集羣


smit clstop

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



6.      查看A機狀態

$ hostname
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機監聽


$ hostname
hacmp2
$ sqlplus system/[email protected]: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機運行正常



8.      啓動B機集羣

smit clstart


Start now, on system restart or both                now                                                                                                                                                                                
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?



#     自此AIX 6.1 + HACMP 6.1 + Oracle 11g雙機實施完成



THE END




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章