两台HP Server rp5470小型机,7110磁盘阵列
软件环境:
HP-UX B.11.11、MirrorDisk/UX B.11.11、MC / Service Guard A.11.14、Oracle 9i for HP-UX。
3.1准备系统
3.1.1编辑安全文件:
[/@machine01]vi .rhosts文件
machine1 root
machine2 root
3.1.2创建根逻辑卷的镜像
[/@machine01]#pvcreate -B /dev/rdsk/c2t2d0
[/@machine01]#vgextend /dev/vg00 /dev/dsk/c2t2d0
[/@machine01]#mkboot -l /dev/rdsk/c2t2d0
[/@machine01]#lvextend -m 1 /dev/vg00/lvol1 /dev/dsk/c2t2d0
[/@machine01]#lvextend -m 1 /dev/vg00/lvol2 /dev/dsk/c2t2d0
[/@machine01]#lvextend -m 1 /dev/vg00/lvol3 /dev/dsk/c2t2d0
[/@machine01]#lvextend -m 1 /dev/vg00/secswap /dev/dsk/c2t2d0
[/@machine01]#lvextend -m 1 /dev/vg00/lvol4 /dev/dsk/c2t2d0
[/@machine01]#lvextend -m 1 /dev/vg00/lvol5 /dev/dsk/c2t2d0
[/@machine01]#lvextend -m 1 /dev/vg00/lvol6 /dev/dsk/c2t2d0
[/@machine01]#lvextend -m 1 /dev/vg00/lvol7 /dev/dsk/c2t2d0
[/@machine01]#lvextend -m 1 /dev/vg00/lvol8 /dev/dsk/c2t2d0
[/@machine01]#/usr/sbin/lvlnboot -b /dev/vg00/lvol1
[/@machine01]#/usr/sbin/lvlnboot -s /dev/vg00/lvol2
[/@machine01]#/usr/sbin/lvlnboot -r /dev/vg00/lvol3
验证镜像是否已正确创建:
[/@machine01]#lvlnboot -v
显示下列信息说明镜像已正确创建
Boot Definitions for Volume Group /dev/vg00:
Physical Volumes belonging in Root Volume Group:
/dev/dsk/c1t2d0 (0/0/1/1.2.0) -- Boot Disk
/dev/dsk/c2t2d0 (0/0/2/0.2.0) -- Boot Disk
Boot: lvol1 on: /dev/dsk/c1t2d0
/dev/dsk/c2t2d0
Root: lvol3 on: /dev/dsk/c1t2d0
/dev/dsk/c2t2d0
Swap: lvol2 on: /dev/dsk/c1t2d0
/dev/dsk/c2t2d0
Dump: lvol2 on: /dev/dsk/c1t2d0, 0
在machine02机上重复以上步骤
3.1.3创建群集锁卷组和物理卷:
[/@machine01]#pvcreate -f /dev/rdsk/c4t0d0
[/@machine01]#mkdir /dev/vglock
[/@machine01]#mknod /dev/vglock/group C 64 0x020000
[/@machine01]#vgcreate /dev/vglock /dev/dsk/c4t0d0
[/@machine01]#vgexport -p -s -m /tmp/vglock.map /dev/vglock
[/@machine01]#rcp /tmp/vglock.map machine02:/tmp/.
[/@machine02]#mkdir /dev/vglock
[/@machine02]#mknod /dev/vglock/group c 64 0x020000
[/@machine02]#vgimport -s -m /tmp/vglock.map /dev/vglock
3.2用LVM创建存储基本结构:
3.2.1创建卷组:
#c4t0d1盘来自磁盘阵列,vg01用于存放oracle库ora9的数据
[/@machine01]#pvcreate -f dev/rdsk/c4t0d1
[/@machine01]#mkdir /dev/vg01
[/@machine01]#mknod /dev/vg01/group c 64 0x010000
[/@machine01]#vgcreate /dev/vg01 /dev/dsk/c4t0d1
[/@machine01]#lvcreate -L 10000 /dev/vg01
[/@machine01]#newfs -F vxfs /dev/vg01/data
[/@machine01]#mkdir /data
[/@machine01]#mount /dev/vg01/data /data
[/@machine01]#vgdisplay -v /dev/vg01 #验证卷组是否已正确创建
3.2.2将卷组分发到二号机:
[/@machine01]#umount /data
[/@machine01]#vgchange -a n /dev/vg01
[/@machine01]#vgexport -p -s -m /tmp/vg01.map /dev/vg01
[/@machine01]#rcp /tmp/vg01.map machine02:/tmp/.
[/@machine02]#mkdir /dev/vg01
[/@machine02]#mknod /dev/vg01/group c 64 0x010000
[/@machine02]#vgimport -s -m /tmp/vg01.map /dev/vg01
[/@machine02]#vgchange -a y /dev/vg01
[/@machine02]#mkdir /data
[/@machine02]#mount /dev/vg01/data /data
[/@machine02]#vgdisplay -v /dev/vg01] #验证配置
[/@machine02]#umount /data
[/@machine02]#vgchange -a n /dev/vg01
3.3建库:
3.3.1建库:
假设Oracle99i数据库软件已经安装在系统中,oracle用户及其环境变量等均已设置好:
ORACLE_BASE=/home/oracle/app
ORACLE_HOME=$ORACLE_BASE/product/9.2.0
ORACLE_SID=ora9
ORACLE_TERM=xterm
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:$ORACLE_HOME/rdbms/lib
PATH=/bin:/usr/bin:/usr/sbin:/etc:/opt/bin:/usr/ccs/bin:/usr/local/bin:$ORACLE_H
OME/bin
按如下步骤执行:
[/@machine01]#vgchange -a y vg01
[/@machine01]#mount /dev/vg01/data /data
启动XWindows,打开一个terminal窗口,在terminal窗口中执行下列命令
[/@machine01]#su - oracle
$vi .profile
DISPLAY=x.x.x.x:0.0 #改DISPLAY变量,x.x.x.x为你当前运行xwindows终端的电脑的ip地址
$exit
[/@machine01]#su - oracle
$dbca
在GUI中选Create a database——New Database——全局数据库名:ora9.world,SID:ora9——Dedicated ServerMode——Initialization Parameters,根据实际需要填参数——改变DataBase Storage画面中Controlfile、datafile、Redo Log文件位置均为/data/——Create a database并生成创建代码——最后改sys及system用户的口令——完成
3.3.2将必要的文件拷贝至二号机:
[/home/oracle/app/admin/@machine02]rcp –r machine01:/home/oracle/app/admin/ora9 .
[/home/oracle/app/admin@machine02]#chown -R oracle:dba ora9
[/home/oracle/app/product/9.2.0/@machine02]rcp-r machine01:/home/oracle/app/product/9.2.0/dbs .
[/home/oracle/app/product/9.2.0/@machine02]chown -R oracle:dba dbs
3.4配置群集:
3.4.1生成摸板并修改
[/@machine01]#cmquerycl -v -c /etc/cmcluster/clconfig.ascii -n machine01 -n machine02
[/@machine01]#vi /etc/cmcluster/clconfig.ascii
CLUSTER_NAME oracledb
FIRST_CLUSTER_LOCK_VG /dev/vglock
NODE_NAME machine01
NETWORK_INTERFACE lan2
HEARTBEAT_IP 192.168.100.80
NETWORK_INTERFACE lan0
HEARTBEAT_IP 192.1.1.1
FIRST_CLUSTER_LOCK_PV /dev/dsk/c4t0d0
NODE_NAME machine02
NETWORK_INTERFACE lan0
HEARTBEAT_IP 192.1.1.2
NETWORK_INTERFACE lan2
HEARTBEAT_IP 192.168.100.81
FIRST_CLUSTER_LOCK_PV /dev/dsk/c4t0d0
HEARTBEAT_INTERVAL 2000000
NODE_TIMEOUT 6000000
AUTO_START_TIMEOUT 600000000
NETWORK_POLLING_INTERVAL 2000000
MAX_CONFIGURED_PACKAGES 4 #最大包个数,根据实际情况确定,小于等于60
VOLUME_GROUP /dev/vg01
VOLUME_GROUP /dev/vglock
3.4.2验证群集配置:
[/@machine01]#cmcheckconf -k -v -C /etc/clconfig.ascii
3.4.3分发二进制文件:
[/@machine01]#vgchange -a y vglock #必须仅在发出cmapplyconf命令的节点上激活vglock,这样才可初始化锁磁盘
[/@machine01]#cmapplyconf -k -v -C /etc/cmcluster/clconfig.ascii
[/@machine01]#vgchange -a n vglock
3.4.4启动群集并检查群集:
[/@machine01]#cmruncl -v
[/@machine01]#cmviewcl -v
还可通过断开某节点网络、停下某节点等观察群集是否能正常切换。
3.4.5存储卷组和群集锁配置数据:
[/@machine01]#vgcfgbackup vg01
[/@machine01]#vgcfgbackup vglock
3.5配置高可用性oracle包:
3.5.1建立包目录
[/@machine01]#mkdir /etc/cmcluster/pkg_ora
3.5.2创建包配置文件并进行修改
[/@machine01]#cmmakepkg -p /etc/cmcluster/pkg_ora/pkg_ora.conf
[/@machine01]#vi /etc/cmcluster/pkg_ora/pkg_ora.conf
PACKAGE_NAME pkg_ora
PACKAGE_TYPE FAILOVER
FAILOVER_POLICY CONFIGURED_NODE
FAILBACK_POLICY MANUAL
NODE_NAME machine01
NODE_NAME machine02
AUTO_RUN YES
LOCAL_LAN_FAILOVER_ALLOWED YES
NODE_FAIL_FAST_ENABLED NO
RUN_SCRIPT /etc/cmcluster/pkg_ora/pkg_ora.cntl
RUN_SCRIPT_TIMEOUT NO_TIMEOUT
HALT_SCRIPT /etc/cmcluster/pkg_ora/pkg_ora.cntl
HALT_SCRIPT_TIMEOUT NO_TIMEOUT
SERVICE_NAME oracle_service
SERVICE_FAIL_FAST_ENABLED NO
SERVICE_HALT_TIMEOUT 300
SUBNET 192.168.100.0
3.5.3创建包控制文件并进行修改
[/@machine01]#cmmakepkg -v -s /etc/cmcluster/pkg_ora/pkg_ora.cntl
[/@machine01]#vi /etc/cmcluster/pkg_ora/pkg_ora.cntl
VG[0]="/dev/vg01"
LV[0]="/dev/vg01/data"; FS[0]="/data"; FS_MOUNT_OPT[0]="-o rw"
IP[0]="192.168.100.82"
SUBNET[0]="192.168.100.0"
SERVICE_NAME[0]="oracle_service"
SERVICE_CMD[0]="/etc/cmcluster/pkg_ora/oracle9i.sh monitor"
SERVICE_RESTART[0]=""
function customer_defined_run_cmds
{
# ADD customer defined run commands.
: # do nothing instruction, because a function must contain some command.
/etc/cmcluster/pkg_ora/oracle9i.sh start
test_return 51
}
function customer_defined_halt_cmds
{
# ADD customer defined halt commands.
: # do nothing instruction, because a function must contain some command.
/etc/cmcluster/pkg_ora/oracle9i.sh halt
test_return 52
}
3.5.4修改oracle9i脚本
[/@machine01]#vi /etc/cmcluster/pkg_ora/oracle9i.sh
SID_NAME=ora9
ORACLE_HOME=/home/oracle/app/product/9.2.0
LISTENER_NAME=LISTENER
LISTENER_PASS=
MONITOR_INTERVAL=30
PACKAGE_NAME=pkg_ora
其余部分保持原状
3.5.5验证包配置文件
[/etc/cmcluster/pkg_ora@machine01]#cmcheckconf –v –C /etc/cmcluster/clconfig.ascii -P pkg_ora.conf
3.5.6分发包二进制文件
[/etc/cmcluster/pkg_ora@machine01]#cmapplyconf -v –C /etc/cmcluster/clconfig.ascii -P pkg_ora.conf
3.5.7修改listener.ora文件
[/home/oracle/app/product/9.2.0/@machine01]#vi listener.ora
将下列条目:
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.80)(PORT = 1521))
192.168.100.80改为包地址192.168.100.82,其余部分不变。
3.5.8将包目录和listener.ora文件拷贝至二号机
[/etc/cmcluster@machine02]#rcp -r machine01:/etc/cmcluster/pkg_ora .
[/home/oracle/app/product/9.2.0/network/@machine02]rcp machine01:/oracle/app/product/9.2.0/network/listener.ora .
[/home/oracle/app/product/9.2.0/network/@machine02]chown oracle:dba listener.ora
3.5.9启动包并观察包是否运行正常
[/@machine01]#cmmodpkg -v -e pkg_ora #启动包
[/@machine01]#cmviewcl -v #观察包及群集是否运行正常
还可通过sqlplus及OEM等oracle实用程序验证oracle包是否运行正常。