RAC安裝之一 安裝前準備

aishu521發表於2012-08-15
RAC安裝之一 安裝前準備 2011-06-20 19:57:42
版權宣告:原創作品,謝絕轉載!否則將追究法律責任。

  Oracle中的RAC技術是一門很高深的藝術,RAC是real application cluster的英文縮寫,中文翻譯為真實應用叢集。oracle的叢集為多個資料庫例項對應一個資料庫,因而需要使用到共享儲存,也就是所謂的盤陣(一盤多機),在本文中使用ISCSI共享儲存實現;RAC的安裝是個繁瑣的過程,需要一定的linux或者unix系統基礎,因而筆者將會整理一個RAC在centos4.8的上安裝系列教程,本節為教程的第一講 ———— 安裝前的環境準備。

本節總的內容包括以下幾個要點:
1:安裝linux作業系統,配置IP和主機名
2:調整系統引數
3:配置共享儲存
4:配置raw裝置
5:配置ASM

環境介紹:
作業系統:Centos4.8  64位(節點)
節點1主機名:rac1.766.com  
節點1IP地址:192.168.50.191/192.168.122.191 
節點2主機名:rac2.766.com
節點2IP地址:192.168.50.192/192.168.122.192

一:安裝作業系統

  1. 1:這裡採取PXE自動方式進行push安裝,安裝所有的軟體包,可參考:http://ylw6006.blog.51cto.com/470441/587303  
  2.  
  3. 2:配置hosts檔案,兩個節點應當一致,rac1-vip所對應的ip可以不存在  
  4. [root@rac1 ~]# cat /etc/hosts  
  5. # Do not remove the following line, or various programs  
  6. # that require network functionality will fail.  
  7. 127.0.0.1               localhost.localdomain localhost  
  8.  
  9. 192.168.50.191          rac1.766.com          rac1  
  10. 192.168.122.191         rac1-priv.766.com     rac1-priv  
  11. 10.0.0.1                rac1-vip.766.com      rac1-vip  
  12.  
  13.  
  14. 192.168.50.192          rac2.766.com          rac2  
  15. 192.168.122.192         rac2-priv.766.com     rac2-priv  
  16. 10.0.0.2                rac2-vip.766.com      rac2-vip  
  17.  
  18. 3:關閉selinux  
  19. [root@rac1 ~]# getenforce   
  20. Disabled  
  21.  
  22. 4:建立 Oracle 組和使用者帳戶,兩個節點的oracle使用者的uid,gid應當保持一致  
  23. [root@rac1 ~]# groupadd  oinstall  
  24. [root@rac1 ~]# groupadd  dba  
  25. [root@rac1 ~]# useradd -g oinstall -G dba oracle  
  26. [root@rac1 ~]# echo "oracle" |passwd --stdin oracle  
  27. Changing password for user oracle.  
  28. passwd: all authentication tokens updated successfully.  
  29.  
  30. [root@rac1 ~]# id oracle  
  31. uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba) 

二:調整系統引數

  1. 1:修改核心和系統引數  
  2. [root@rac2 ~]# id oracle  
  3. uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba)  
  4.  
  5. [root@rac1 ~]# cat >> /etc/sysctl.conf <<EOF 
  6. > kernel.shmall = 2097152 
  7. > kernel.shmmax = 2147483648 
  8. > kernel.shmmni = 4096 
  9. > kernel.sem = 250 32000 100 128  
  10. > fs.file‐max = 65536 
  11. > net.ipv4.ip_local_port_range = 1024 65000  
  12. > net.core.rmem_default = 262144 
  13. > net.core.rmem_max = 262144 
  14. > net.core.wmem_default = 262144 
  15. > net.core.wmem_max = 262144 
  16. > EOF  
  17.  
  18. [root@rac1 ~]# sysctl -p  
  19. [root@rac1 ~]# cat >> /etc/security/limits.conf <<EOF 
  20. > oracle soft nproc 2047  
  21. > oracle hard nproc 16384  
  22. > oracle soft nofile 1024  
  23. > oracle hard nofile 65536  
  24. > EOF  
  25.  
  26. [root@rac1 ~]# cat >> /etc/pam.d/login <<EOF 
  27. > session required /lib/security/pam_limits.so  
  28. > EOF  
  29.  
  30. [root@rac1 ~]# cat >> /etc/modprobe.conf <<EOF 
  31. > options hangcheck-timer hangcheck_tick=30 hangcheck_margin=180 
  32. > EOF  
  33.  
  34. [root@rac1 ~]# modprobe -v hangcheck-timer  
  35. insmod /lib/modules/2.6.18-164.el5/kernel/drivers/char/hangcheck-timer.ko hangcheck_tick=30 hangcheck_margin=180 
  36.  
  37. 2:修改oracle使用者環境變數,節點2的ORACLE_SID變數需要改成racdb2  
  38. [root@rac1 ~]# su - oracle  
  39. [oracle@rac1 ~]$ cat .bash_profile   
  40. # .bash_profile  
  41.  
  42. # Get the aliases and functions  
  43. if [ -f ~/.bashrc ]; then  
  44.         . ~/.bashrc  
  45. fi  
  46.  
  47. # User specific environment and startup programs  
  48.  
  49. PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:/root/bin  
  50.  
  51. export EDITOR=vim 
  52. export ORACLE_SID=racdb1 
  53. export ORACLE_BASE=/u01/app/oracle  
  54. export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1  
  55. export ORA_CRS_HOME=$ORACLE_BASE/product/10.2.0/crs_1  
  56. export LD_LIBRARY_PATH=/lib  
  57. alias sqlplus='/usr/local/rlwrap/bin/rlwrap sqlplus' 
  58. alias rman='/usr/local/rlwrap/bin/rlwrap rman' 
  59. export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS' 
  60. export NLS_LANG=american_america.UTF8  
  61. export PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:$PATH
  62. umask 022  
  63.  
  64.  
  65. 3:建立相關目錄  
  66. [oracle@rac1 ~]$ mkdir -p $ORACLE_BASE/admin  
  67. [oracle@rac1 ~]$ mkdir -p $ORACLE_HOME  
  68. [oracle@rac1 ~]$ mkdir -p $ORA_CRS_HOME  
  69.  
  70. 4:配置oracle使用者等效性  
  71. [oracle@rac1 ~]$ ssh-keygen -t rsa  
  72. Generating public/private rsa key pair.  
  73. Enter file in which to save the key (/home/oracle/.ssh/id_rsa):   
  74. Created directory '/home/oracle/.ssh'.  
  75. Enter passphrase (empty for no passphrase):   
  76. Enter same passphrase again:   
  77. Your identification has been saved in /home/oracle/.ssh/id_rsa.  
  78. Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.  
  79. The key fingerprint is:  
  80. 99:4c:75:0b:3a:81:11:6a:e8:71:74:9e:94:89:00:d4 oracle@rac1.766.com  
  81. [oracle@rac1 ~]$ ssh-keygen -t dsa  
  82. Generating public/private dsa key pair.  
  83. Enter file in which to save the key (/home/oracle/.ssh/id_dsa):   
  84. Enter passphrase (empty for no passphrase):   
  85. Enter same passphrase again:   
  86. Your identification has been saved in /home/oracle/.ssh/id_dsa.  
  87. Your public key has been saved in /home/oracle/.ssh/id_dsa.pub.  
  88. The key fingerprint is:  
  89. df:f6:c0:ab:7f:84:91:af:d8:d8:e0:fd:76:77:74:f2 oracle@rac1.766.com  
  90.  
  91. [oracle@rac1 ~]$ cat .ssh/id_dsa.pub  >> .ssh/authorized_keys   
  92. [oracle@rac1 ~]$ cat .ssh/id_rsa.pub  >> .ssh/authorized_keys   
  93. [oracle@rac1 ~]$ scp /home/oracle/.ssh/authorized_keys oracle@rac2.766.com:/home/oracle/.ssh/  
  94.  
  95. 驗證:不需要密碼登入  
  96. 在rac1節點上面分別ssh rac1;ssh rac1.766.com ; ssh rac2; ssh rac2.766.com   
  97. 在rac2節點上面分別ssh rac1;ssh rac1.766.com ; ssh rac2; ssh rac2.766.com   

三:配置共享儲存

  1. 伺服器IP:192.168.50.4   
  2. 作業系統:RHEL6 64位  
  3.  
  4. 1:伺服器端,詳細配置步驟可參考http://ylw6006.blog.51cto.com/470441/580568  
  5. [root@rhel6 ~]# lvcreate -n sharedisk -L 80G VolGroup00  
  6.   Logical volume "sharedisk" created  
  7. [root@rhel6 ~]# yum -y install scsi-target-utils.x86_64  
  8. [root@rhel6 ~]# service tgtd start  
  9. [root@rhel6 ~]# service tgtd restart  
  10. Stopping SCSI target daemon: [  OK  ]  
  11. Starting SCSI target daemon: [  OK  ]  
  12. [root@rhel6 ~]# chkconfig --add tgtdrules   
  13. [root@rhel6 ~]# service tgtdrules start  
  14. Starting Tgtdrules Server:  
  15.  
  16. [root@rhel6 ~]# service tgtdrules status  
  17. Target 1: iqn.2011-06-01.com.766.rac:shareddisk  
  18.     System information:  
  19.         Driver: iscsi  
  20.         State: ready  
  21.     I_T nexus information:  
  22.     LUN information:  
  23.         LUN: 0  
  24.             Type: controller  
  25.             SCSI ID: IET     00010000  
  26.             SCSI SN: beaf10  
  27.             Size: 0 MB  
  28.             Online: Yes  
  29.             Removable media: No  
  30.             Backing store type: rdwr  
  31.             Backing store path: None  
  32.         LUN: 1  
  33.             Type: disk  
  34.             SCSI ID: IET     00010001  
  35.             SCSI SN: beaf11  
  36.             Size: 85899 MB  
  37.             Online: Yes  
  38.             Removable media: No  
  39.             Backing store type: rdwr  
  40.             Backing store path: /dev/VolGroup00/sharedisk  
  41.     Account information:  
  42.     ACL information:  
  43.         192.168.50.191  
  44.         192.168.50.192  
  45.  
  46.  
  47.  
  48. 2:配置共享儲存客戶端,centos4和rhel5以及rhel6的配置略微有點不同  
  49. [root@rac1 ~]# wget ftp://ftp.is.co.za/mirror/centos/4.8/os/x86_64/CentOS/RPMS/iscsi-initiator-utils-4.0.3.0-8.x86_64.rpm  
  50. [root@rac1 ~]# rpm -ivh iscsi-initiator-utils-4.0.3.0-8.x86_64.rpm   
  51. warning: iscsi-initiator-utils-4.0.3.0-8.x86_64.rpm: V3 DSA signature: NOKEY, key ID 443e1821  
  52. Preparing...                ########################################### [100%]  
  53.    1:iscsi-initiator-utils  ########################################### [100%]  
  54.      
  55. [root@rac1 ~]# grep -v '^#' /etc/iscsi.conf  |grep -v '^$'  
  56. DiscoveryAddress=192.168.50.4  
  57. TargetName=iqn.2011-06-01.com.766.rac:shareddisk  
  58. Enabled=yes    
  59.      
  60. [root@rac1 ~]# service iscsi start  
  61. Checking iscsi config:  [  OK  ]  
  62. Loading iscsi driver:  [  OK  ]  
  63. Starting iscsid: [  OK  ]  
  64.  
  65. [root@rac1 ~]# iscsi-ls  
  66. *******************************************************************************  
  67. SFNet iSCSI Driver Version ...4:0.1.11-7(14-Apr-2008)  
  68. *******************************************************************************  
  69. TARGET NAME             : iqn.2011-06-01.com.766.rac:shareddisk  
  70. TARGET ALIAS            :   
  71. HOST ID                 : 0  
  72. BUS ID                  : 0  
  73. TARGET ID               : 0  
  74. TARGET ADDRESS          : 192.168.50.4:3260,1  
  75. SESSION STATUS          : ESTABLISHED AT Sun Jun 19 07:23:36 CST 2011  
  76. SESSION ID              : ISID 00023d000001 TSIH 100  
  77. *******************************************************************************  
  78.  
  79. [root@rac1 ~]# fdisk -l  
  80. Disk /dev/sda: 85.8 GB, 85899345920 bytes  
  81. 255 heads, 63 sectors/track, 10443 cylinders  
  82. Units = cylinders of 16065 * 512 = 8225280 bytes  
  83. Disk /dev/sda doesn't contain a valid partition table 

四:配置raw裝置

  1. 1:將共享儲存/dev/sda分成8個分割槽,前5個分割槽sda5-9分別為2G,sda10-12分別為20G  
  2. [root@rac1 ~]# fdisk -l  
  3. Disk /dev/sda: 85.8 GB, 85899345920 bytes  
  4. 255 heads, 63 sectors/track, 10443 cylinders  
  5. Units = cylinders of 16065 * 512 = 8225280 bytes  
  6.  
  7.    Device Boot      Start         End      Blocks   Id  System  
  8. /dev/sda1               1       10443    83883366    5  Extended  
  9. /dev/sda5               1         244     1959867   83  Linux  
  10. /dev/sda6             245         488     1959898+  83  Linux  
  11. /dev/sda7             489         732     1959898+  83  Linux  
  12. /dev/sda8             733         976     1959898+  83  Linux  
  13. /dev/sda9             977        1220     1959898+  83  Linux  
  14. /dev/sda10           1221        3653    19543041   83  Linux  
  15. /dev/sda11           3654        6086    19543041   83  Linux  
  16. /dev/sda12           6087        8519    19543041   83  Linux  
  17. [root@rac1 ~]#   
  18.  
  19. 2:將sda5-9繫結為裸裝置,節點2上需要做相同的配置  
  20. [root@rac1 ~]# cat /etc/sysconfig/rawdevices   
  21. # This file and interface are deprecated.  
  22. # Applications needing raw device access should open regular  
  23. # block devices with O_DIRECT.  
  24. # raw device bindings  
  25. # format:  <rawdev> <major> <minor> 
  26. #          <rawdev> <blockdev> 
  27. # example: /dev/raw/raw1 /dev/sda1  
  28. #          /dev/raw/raw2 8 5  
  29. /dev/raw/raw5    /dev/sda5  
  30. /dev/raw/raw6    /dev/sda6  
  31. /dev/raw/raw7    /dev/sda7  
  32. /dev/raw/raw8    /dev/sda8  
  33. /dev/raw/raw9    /dev/sda9  
  34.  
  35. [root@rac1 ~]# service rawdevices restart  
  36. [root@rac1 ~]# raw -qa  
  37. /dev/raw/raw5:  bound to major 8, minor 5  
  38. /dev/raw/raw6:  bound to major 8, minor 6  
  39. /dev/raw/raw7:  bound to major 8, minor 7  
  40. /dev/raw/raw8:  bound to major 8, minor 8  
  41. /dev/raw/raw9:  bound to major 8, minor 9  
  42.  
  43. [root@rac1 ~]# ll /dev/raw/raw*  
  44. crw-rw----  1 oracle oinstall 162,  5 Jun 19 08:10 /dev/raw/raw5  
  45. crw-rw----  1 oracle oinstall 162,  6 Jun 19 08:10 /dev/raw/raw6  
  46. crw-rw----  1 oracle oinstall 162,  7 Jun 19 08:10 /dev/raw/raw7  
  47. crw-rw----  1 oracle oinstall 162,  8 Jun 19 08:10 /dev/raw/raw8  
  48. crw-rw----  1 oracle oinstall 162,  9 Jun 19 08:10 /dev/raw/raw9  
  49. [root@rac1 ~]# chkconfig rawdevices on 

五:配置ASM

  1. 1:從oracle網站下載並安裝相應的包,節點2上需要做相同的配置  
  2. [root@rac1 ~]# cat down.txt   
  3. http://oss.oracle.com/projects/oracleasm-support/dist/files/RPMS/rhel4/amd64/2.1.3/oracleasm-support-2.1.3-1.el4.x86_64.rpm    
  4. http://download.oracle.com/otn_software/asmlib/oracleasmlib-2.0.4-1.el4.x86_64.rpm    
  5. http://oss.oracle.com/projects/oracleasm/dist/files/RPMS/rhel4/amd64/2.0.5/2.6.9-89.EL/oracleasm-2.6.9-89.EL-debuginfo-2.0.5-1.el4.x86_64.rpm  
  6. http://oss.oracle.com/projects/oracleasm/dist/files/RPMS/rhel4/amd64/2.0.5/2.6.9-89.EL/oracleasm-2.6.9-89.EL-2.0.5-1.el4.x86_64.rpm   
  7. [root@rac1 ~]# wget -i down.txt  
  8. [root@rac1 ~]# rpm -ivh *.rpm  
  9. warning: oracleasm-2.6.9-89.EL-2.0.5-1.el4.x86_64.rpm: V3 DSA signature: NOKEY, key ID b38a8516  
  10. Preparing...                ########################################### [100%]  
  11.    1:oracleasm-support      ########################################### [ 25%]  
  12.    2:oracleasm-2.6.9-89.EL  ########################################### [ 50%]  
  13.    3:oracleasm-2.6.9-89.EL-d########################################### [ 75%]  
  14.    4:oracleasmlib           ########################################### [100%]  
  15.  
  16. 2:配置asm,節點2上需要做相同的配置   
  17. [root@rac1 ~]# /etc/init.d/oracleasm configure  
  18. Configuring the Oracle ASM library driver.  
  19.  
  20. This will configure the on-boot properties of the Oracle ASM library  
  21. driver.  The following questions will determine whether the driver is  
  22. loaded on boot and what permissions it will have.  The current values  
  23. will be shown in brackets ('[]').  Hitting <ENTER> without typing an  
  24. answer will keep that current value.  Ctrl-C will abort.  
  25.  
  26. Default user to own the driver interface []: oracle  
  27. Default group to own the driver interface []: oinstall  
  28. Start Oracle ASM library driver on boot (y/n) [n]: y  
  29. Scan for Oracle ASM disks on boot (y/n) [y]: y  
  30. Writing Oracle ASM library driver configuration: done  
  31. Initializing the Oracle ASMLib driver: [  OK  ]  
  32. Scanning the system for Oracle ASMLib disks: [  OK  ]    
  33.  
  34. 3:建立ASM磁碟  
  35. [root@rac1 ~]# /etc/init.d/oracleasm createdisk VOL1 /dev/sda10  
  36. Marking disk "VOL1" as an ASM disk: [  OK  ]  
  37. [root@rac1 ~]# /etc/init.d/oracleasm createdisk VOL2 /dev/sda11  
  38. Marking disk "VOL2" as an ASM disk: [  OK  ]  
  39. [root@rac1 ~]# /etc/init.d/oracleasm createdisk VOL3 /dev/sda12  
  40. Marking disk "VOL3" as an ASM disk: [  OK  ]  
  41. [root@rac1 ~]# /etc/init.d/oracleasm listdisks  
  42. VOL1  
  43. VOL2  
  44. VOL3  
  45.  
  46. 3:在節點2上應該可以看到同樣的結果  
  47. [root@rac2 ~]# /etc/init.d/oracleasm  enable  
  48. Writing Oracle ASM library driver configuration: done  
  49. Initializing the Oracle ASMLib driver: [  OK  ]  
  50. Scanning the system for Oracle ASMLib disks: [  OK  ]  
  51. [root@rac2 ~]# /etc/init.d/oracleasm listdisks  
  52. VOL1  
  53. VOL2  
  54. VOL3 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15187685/viewspace-741101/,如需轉載,請註明出處,否則將追究法律責任。

相關文章