AS4 10g 單節點遷移到ASM RAC步驟總結

tw214227發表於2011-05-14

AS4上 遷移單例項節點到RAC

遷移過程大概記錄:


1.準備sharedisk

準備兩塊共享磁碟,一塊用於ocr vdisk,一塊用於ASM

 


2.為ASM 建立vg lv raw

 

NODE 1:

a.建立分割槽(linux 因為LV 的raw 會覆蓋cylinders 0 ,而分割槽預設是從cylinders 1開始,所以要用分割槽):


fdisk ,主節點先分割槽,第二個節點直接fdisk w寫入就行

b.繫結RAW:

 

繫結引數加入配置檔案:

[root@pri ~]# vi /etc/sysc
sysconfig/   sysctl.conf
[root@pri ~]# vi /etc/sysconfig/rawdevices

# This file and interface are deprecated.
# Applications needing raw device access should open regular
# block devices with O_DIRECT.
# raw device bindings
# format: <rawdev> <major> <minor>
#          <rawdev> <blockdev>
# example: /dev/raw/raw1 /dev/sda1
#          /dev/raw/raw2 8 5
/dev/raw/raw1 253 2
/dev/raw/raw2 /dev/sdc1               
/dev/raw/raw3 /dev/sdc3

"/etc/sysconfig/rawdevices" 11L, 347C written   

c.重啟服務生效
[root@pri ~]# service rawdevices restart
Assigning devices:
           /dev/raw/raw1 -->   253 2
/dev/raw/raw1: bound to major 253, minor 2
           /dev/raw/raw2 -->   /dev/sdc1
/dev/raw/raw2: bound to major 8, minor 33
           /dev/raw/raw3 -->   /dev/sdc3
/dev/raw/raw3: bound to major 8, minor 35

d.修改RAW許可權:

 

[root@pri ~]# chown oracle:dba /dev/raw/raw*
[root@pri ~]# ll /dev/raw/raw*
crw-rw---- 1 oracle dba 162, 1 Jul 17 22:16 /dev/raw/raw1
crw-rw---- 1 oracle dba 162, 2 Jul 17 23:42 /dev/raw/raw2
crw-rw---- 1 oracle dba 162, 3 Jul 17 23:42 /dev/raw/raw3

e.用久修改許可權檔案,防止重啟後失效:

[root@pri ~]# vi /etc/udev/permissions.d/50-udev.permissions
找到這一行,修改成:

# raw devices
ram*:oracle:disk:0660
raw/*:oracle:disk:0660

 

NODE 2:
root@standby ~]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "oraclevg" using metadata type lvm2
Found volume group "VolGroup00" using metadata type lvm2
[root@standby ~]# vgdisplay -v oraclevg

啟用scan到的VG
[root@standby ~]# vgchange -a y oraclevg
  

其餘步驟參照NODE 1中的b.---e.
  

3.建立ASM 例項


On the first node, create an init+ASM1A.ora file in $ORACLE_HOME/dbs with the following parameters:


vi init+ASM1A.ora


asm_diskstring='/dev/raw/raw*'
background_dump_dest=/oracle/admin/+ASM/bdump
core_dump_dest=/oracle/admin/+ASM/cdump
user_dump_dest=/oracle/admin/+ASM/udump
instance_type=asm
large_pool_size=16M
remote_login_passwordfile=exclusive
+ASM1A.instance_number=1
+ASM1B.instance_number=2


4.Create ASM password file.
Using the orapwd utility, create an orapw+ASM1A file in $ORACLE_HOME/dbs on the first node.

[oracle@salmon1]$ cd $ORACLE_HOME/dbs
[oracle@salmon1]$ orapwd file=orapw+ASM1A password=sys entries=5


5.Create the first ASM instance.
Create the first ASM instance on the first node. The second ASM instance will be created in Post Installation after the CRS

software is installed on the second node.

[oracle@salmon1]$ export ORACLE_SID=+ASM1A
[oracle@salmon1]$ sqlplus / as sysdba

SQL*Plus: Release 10.1.0.3.0 - Production on Thu May 26 05:51:07 2005

Copyright (c) 1982, 2004, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 104857600 bytes
Fixed Size                777616 bytes
Variable Size             104079964 bytes
Database Buffers          0 bytes
Redo Buffers              0 bytes
ORA-15110: no diskgroups mounted

6. Create the ASM instance spfile.
Create a spfile immediately after the ASM instance starts. With spfile, any newly created disk groups are automatically

added to the spfile.

SQL> create spfile from pfile;

File created.

 

7. Create disk groups.

CREATE DISK GRROUP DATA EXTERNAL REDUNDANCY DISK '/dev/raw/raw1'


8.Migrate data files to ASM.

You must use RMAN to migrate the data files to ASM disk groups. All data files will be migrated to the newly created disk

group, DG1. The redo logs and control files are created in DG1 and DG2. In a production environment, you should store redo

logs on different set of disks and disk controllers from the rest of the Oracle data files.


[oracle@pri dbs]$export ORALCE_SID=test
[oracle@pri dbs]$sqlplus '/as sysdba'

SQL> alter system set db_create_file_dest=’+DG1’;

System altered.

SQL> alter system set control_files='+DG1/cf1.dbf' scope=spfile;

System altered.

SQL> shutdown immediate;


[oracle@pri dbs]$

[oracle@pri ~]$ rman target /


RMAN> startup nomount;

Oracle instance started

Total System Global Area     524288000 bytes

Fixed Size                     1268460 bytes
Variable Size                146801940 bytes
Database Buffers             373293056 bytes
Redo Buffers                   2924544 bytes


RMAN> restore controlfile from '/oracle/oradata/test/control01.ctl'

RMAN> restore controlfile from '/oracle/oradata/test/control01.ctl';

Starting restore at 17-7月 -09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=321 devtype=DISK

 

channel ORA_DISK_1: copied control file copy
output filename=+DATA/control01.ctl
Finished restore at 17-7月 -09

RMAN>
RMAN>
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1


RMAN> backup as copy database format '+DATA';

Starting backup at 17-7月 -09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=321 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=/oracle/oradata/test/system01.dbf
output filename=+DATA/test/datafile/system.257.692491979 tag=TAG20090717T225226 recid=4 stamp=692492102
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:37
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=/oracle/oradata/test/sysaux01.dbf
output filename=+DATA/test/datafile/sysaux.258.692492119 tag=TAG20090717T225226 recid=5 stamp=692492208
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:46
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/oracle/oradata/test/undotbs01.dbf
output filename=+DATA/test/datafile/undotbs1.259.692492223 tag=TAG20090717T225226 recid=6 stamp=692492266
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:06
channel ORA_DISK_1: starting datafile copy
input datafile fno=00009 name=/oracle/oradata/usertmp01.dbf
output filename=+DATA/test/datafile/userstmp.260.692492289 tag=TAG20090717T225226 recid=7 stamp=692492300
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
Finished backup at 17-7月 -09


RMAN> switch database to copy;

datafile 1 switched to datafile copy "+DATA/test/datafile/system.257.692491979"
datafile 2 switched to datafile copy "+DATA/test/datafile/undotbs1.259.692492223"
datafile 3 switched to datafile copy "+DATA/test/datafile/sysaux.258.692492119"
datafile 9 switched to datafile copy "+DATA/test/datafile/userstmp.260.692492289"


RMAN> alter database open;

database opened

RMAN> exit

 

[oracle@pri ~]$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.4.0 - Production on 星期五 7月 17 23:04:28 2009

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Data Mining and Real Application Testing options


SQL>select tablespace_name, file_name from dba_data_files;

TABLESPACE_NAME FILE_NAME
--------------- --------------------------------------------------------------------------------
SYSAUX          +DATA/test/datafile/sysaux.258.692492119
UNDOTBS1        +DATA/test/datafile/undotbs1.259.692492223
SYSTEM          +DATA/test/datafile/system.257.692491979
USERSTMP        +DATA/test/datafile/userstmp.260.692492289


9.Migrate temp tablespace to ASM.

SQL> alter tablespace temp add tempfile size 100M;

Tablespace altered.


SQL> select file_name from dba_temp_files;

FILE_NAME
--------------------------------------------------------------------------------
+DATA/test/tempfile/temp.261.692493003
/oracle/oradata/test/temp01.dbf

10.Migrate redo logs to ASM.

Drop existing redo logs and recreate them in ASM disk groups


SQL> select group#, members,status from v$log;

    GROUP#    MEMBERS STATUS
---------- ---------- ----------------
         1          2 INACTIVE
         2          2 INACTIVE
         3          2 CURRENT

SQL> select group#, members,status from v$log;

    GROUP#    MEMBERS STATUS
---------- ---------- ----------------
         1          2 INACTIVE
         2          2 INACTIVE
         3          2 CURRENT

SQL> alter database drop logfile group 1;

Database altered.

SQL> alter database add logfile group 1 size 50m;

Database altered.

SQL> alter database drop logfile group 2;

Database altered.

SQL> alter database add logfile group 2 size 50m;

Database altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> select group#, members,status from v$log;

    GROUP#    MEMBERS STATUS
---------- ---------- ----------------
         1          2 ACTIVE
         2          2 CURRENT
         3          2 ACTIVE

SQL> /

    GROUP#    MEMBERS STATUS
---------- ---------- ----------------
         1          2 ACTIVE
         2          2 CURRENT
         3          2 ACTIVE

SQL> /

    GROUP#    MEMBERS STATUS
---------- ---------- ----------------
         1          2 ACTIVE
         2          2 CURRENT
         3          2 ACTIVE

SQL> /

    GROUP#    MEMBERS STATUS
---------- ---------- ----------------
         1          2 ACTIVE
         2          2 CURRENT
         3          2 ACTIVE

SQL> /

    GROUP#    MEMBERS STATUS
---------- ---------- ----------------
         1          2 ACTIVE
         2          2 CURRENT
         3          2 ACTIVE

SQL> /

    GROUP#    MEMBERS STATUS
---------- ---------- ----------------
         1          2 ACTIVE
         2          2 CURRENT
         3          2 ACTIVE

SQL> /

    GROUP#    MEMBERS STATUS
---------- ---------- ----------------
         1          2 ACTIVE
         2          2 CURRENT
         3          2 ACTIVE

SQL> /

    GROUP#    MEMBERS STATUS
---------- ---------- ----------------
         1          2 ACTIVE
         2          2 CURRENT
         3          2 INACTIVE

SQL> alter database drop logfile group 3;

Database altered.

SQL> select group#, member from v$logfile;

    GROUP# MEMBER
---------- --------------------------------------------------
         2 +DATA/test/onlinelog/group_2.264.692493817
         2 +DATA/test/onlinelog/group_2.265.692493831
         1 +DATA/test/onlinelog/group_1.262.692493755
         1 +DATA/test/onlinelog/group_1.263.692493769


11.Create pfile from spfile.
Create and retain a copy of the database pfile. You'll add more RAC specific parameters to the pfile later, in the Post

Installation


SQL> create pfile from spfile;

File created.


-------------------------------------------------------------------------------------
準備安裝crs軟體

 


12.兩端建立ORACLE 使用者 和DBA組,注意uid gid相同

13.配置使用者等效性

下面是兩個節點都做:
[oracle@pri ~]$ chmod 700 ~/.ssh
[oracle@pri ~]$ /usr/bin/ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/oracle/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /oracle/.ssh/id_rsa.
Your public key has been saved in /oracle/.ssh/id_rsa.pub.
The key fingerprint is:
0a:f6:07:73:56:3a:14:3b:a1:36:b6:81:df:83:80:71 oracle@pri
[oracle@pri ~]$ /usr/bin/ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/oracle/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /oracle/.ssh/id_dsa.
Your public key has been saved in /oracle/.ssh/id_dsa.pub.
The key fingerprint is:
eb:63:ed:18:2f:39:d6:41:f5:e7:36:43:e4:22:fd:0b oracle@pri


只在NODE1:
[oracle@pri ~]$ more ~/.ssh/authorized_keys
/oracle/.ssh/authorized_keys: No such file or directory
[oracle@pri ~]$ touch ~/.ssh/authorized_keys
[oracle@pri ~]$ cd ~/.ssh
[oracle@pri .ssh]$ ll
total 20
-rw-r--r-- 1 oracle dba   0 Jul 18 00:12 authorized_keys
-rw------- 1 oracle dba 736 Jul 18 00:10 id_dsa
-rw-r--r-- 1 oracle dba 600 Jul 18 00:10 id_dsa.pub
-rw------- 1 oracle dba 963 Jul 18 00:10 id_rsa
-rw-r--r-- 1 oracle dba 220 Jul 18 00:10 id_rsa.pub
-rw-r--r-- 1 oracle dba 620 Jul 2 22:40 known_hosts

[oracle@pri .ssh]$ ssh pri cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
[oracle@pri .ssh]$ ssh pri cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[oracle@pri .ssh]$ ssh standby cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[oracle@pri .ssh]$ ssh standby cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys


[oracle@pri .ssh]$ scp authorized_keys standby:/oracle/.ssh
oracle@standby's password:
authorized_keys                                                                                   100% 1648     1.6KB/s  

00:00   
[oracle@pri .ssh]$ chmod 600 ~/.ssh/authorized_keys(兩個節點 )

 

14.在XMANAGER 的shell中輸入:為了installer不用輸入密碼訪問node2

$ exec /usr/bin/ssh-agent $SHELL
$ /usr/bin/ssh-add

15.Preventing Oracle Clusterware Installation Errors Caused by stty Commands

During an Oracle Clusterware installation, Oracle Universal Installer uses SSH (if available) to run commands and copy

files to the other nodes. During the installation, hidden files on the system (for example, .bashrc or .cshrc) will cause

installation errors if they contain stty commands.


編輯.bashrc
if [ -t 0 ]; then
   stty intr ^C
fi

 

16.暫時要把OCR 的許可權改成root:dba
[root@pri tmp]# chown root:dba /dev/raw/raw2

 

 

 

 

 

 

 

 

 

清除


rm -rf /etc/oracle/
rm -f /etc/init.d/init.cssd
rm -f /etc/init.d/init.crs
rm -f /etc/init.d/init.crsd
rm -f /etc/init.d/init.evmd
rm -f /etc/rc2.d/K96init.crs
rm -f /etc/rc2.d/S96init.crs
rm -f /etc/rc3.d/K96init.crs
rm -f /etc/rc3.d/S96init.crs
rm -f /etc/rc5.d/K96init.crs
rm -f /etc/rc5.d/S96init.crs
rm -Rf /etc/oracle/scls_scr
rm -f /etc/inittab.crs
cp /etc/inittab.orig /etc/inittab
rm -rf /oracle/product/10.2.0.1/crs
rm -rf /oracle/oraInventory/


轉載請標明出處:http://hi.baidu.com/%C8%FD%B7%C9%D4%C6/blog/item/05d58fc3fd8a675cb219a8cd.html

相關文章