1. 程式人生 > 資料庫 >阿里雲上建立Oracle RAC-靜默模式

阿里雲上建立Oracle RAC-靜默模式

編前語:

小編成功在上搭建Oracle RAC斷斷續續花了1個月的時間,中間的過程簡直是痛苦,網上很多的資料都是基於圖形化介面的,也有靜默模式但是步驟都非常的粗略,可能是寫這樣的步驟太費時間了。這篇文章可以說是從零開始,所有的步驟都有截圖。希望可以幫到大家。如果你是才開始接觸RAC請仔細閱讀文中的每一個字,特別關注裡面的一些提示,可以讓你節約很多時間

背景:

公司使用的資料庫目前為Oracle單機模式,為了提高資料的可用性。需要搭建Oracle叢集。於是開始在網上搜索,搭建RAC的文章很多,但是大部分都是基於虛擬機器的。公司的伺服器全部執行在上,於是借鑑下面大神的文章開始搭建,大神的文章過於豪放,細節沒有覆蓋,所有撰寫這篇博文

參考文件:

重點:

為了繞開對於組播的限制,叢集中節點的通訊利用N2N

步驟:

資源準備

  a. ECS 伺服器2臺, CentOS 6.8 x86-64

  b. 塊儲存2塊 (截至目前,塊儲存還處於公測,需要提交申請開通,本人提交申請以後等了3天,讓後提工單去催的)

   20G用於選舉,250G用於資料庫以及Grid安裝

  c. Oracle 以及 Grid安裝檔案(版本:11g),下載地址如下

     

  d. N2N軟體

     

e. ASM軟體

  

1.修改主機名

#vi /etc/sysconfig/network節點1# Created by anacondaNETWORKING=yesHOSTNAME=rac1NETWORKING_IPV6=noPEERNTP=noNOZEROCONF=yes節點2# Created by anacondaNETWORKING=yesHOSTNAME=rac2NETWORKING_IPV6=noPEERNTP=noNOZEROCONF=yes

 2. 安裝Oracle準備,節點規劃完全複製參考文件裡面的

儲存元件和參考文件有點不同,這個塊儲存以後肯定很貴的,所以生產環境可以根據資料庫大小來配置。我是80*3=240G,所以我申請了250G的共享塊儲存

元件

型別

卷大小

ASM卷組名

ASM 冗餘

裝置名

OCR/VF

ASM

5G

DG_OCR

NORMAL

/dev/vdb1,/dev/vdb2,/dev/vdb3

資料&歸檔

ASM

80G

DG_DATA

NORMAL

/dev/vdc1,/dev/vdc2,/dev/vdc3

  塊儲存掛載以後:

Disk /dev/vda: 64.4 GB, 64424509440 bytes, 125829120 sectors

Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0008d73a

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048   125827071    62912512   83  Linux

Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xf8683fec

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/vdc: 268.4 GB, 268435456000 bytes, 524288000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xdd02467a

   Device Boot      Start         End      Blocks   Id  System

3.安裝N2N軟體

  #將N2N軟體上傳到伺服器

#在兩個節點都要安裝N2Nunzip n2n-master.zip&nbsp;cd  n2n-mastermake #如果make 提示openssl出錯,安裝openssl(命令: yum install -y openssl openssl-devel)make PREFIX=/opt/n2n install 安裝完畢後啟動supernode服務(N2N支援兩個supernode,我這裡只在節點1上面開啟supernode)nohup /opt/n2n/sbin/supernode -l 65530 & #用其中一個節點來當N2N的supernode,我用的節點1, 節點1/opt/n2n/sbin/edge -d edge0 -a 10.10.10.101 -s 255.255.255.0 -c dtstack -k dtstack -l 172.18.56.21:65530 -E -r #這裡的172.18.56.21是我ECS伺服器的eth0介面IP,也就是supernode的真實IP,如果你起了兩個supernode可以直接在-l引數裡面新增第二個節點,如-l 172.18.56.21:65530,172.18.56.22:65530/opt/n2n/sbin/edge -d edge1 -a 192.168.100.101 -s 255.255.255.0 -c dtstack -k dtstack -l 172.18.56.21:65530 -E -r #配置完成以後節點會多兩個虛擬網絡卡[root@rac1 n2n-master]# ifconfigedge0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1400        inet 10.10.10.101  netmask 255.255.255.0  broadcast 10.10.10.255        ether 4e:c7:9c:a7:73:95  txqueuelen 1000  (Ethernet)        RX packets 0  bytes 0 (0.0 B)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 0  bytes 0 (0.0 B)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 edge1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1400        inet 192.168.100.101  netmask 255.255.255.0  broadcast 192.168.100.255        ether 46:76:79:d8:1b:eb  txqueuelen 1000  (Ethernet)        RX packets 0  bytes 0 (0.0 B)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 0  bytes 0 (0.0 B)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500        inet 172.18.56.21  netmask 255.255.240.0  broadcast 172.18.63.255        ether 00:16:3e:08:48:66  txqueuelen 1000  (Ethernet)        RX packets 19861  bytes 24810887 (23.6 MiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 6122  bytes 2000836 (1.9 MiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 節點2 /opt/n2n/sbin/edge -d edge0 -a 10.10.10.102 -s 255.255.255.0 -c dtstack -k dtstack -l 172.18.56.21:65530 -E -r/opt/n2n/sbin/edge -d edge1 -a 192.168.100.102 -s 255.255.255.0 -c dtstack -k dtstack -l 172.18.56.21:65530 -E -r

4.修改/etc/hosts

節點110.10.10.101 rac110.10.10.102 rac210.10.10.103 rac1-vip10.10.10.104 rac2-vip192.168.100.101 rac1-priv192.168.100.102 rac2-priv10.10.10.105 scan-ip#172.18.56.21 rac1節點210.10.10.101 rac110.10.10.102 rac210.10.10.103 rac1-vip10.10.10.104 rac2-vip192.168.100.101 rac1-priv192.168.100.102 rac2-priv10.10.10.105 scan-ip#172.10.56.22 rac2

5.修改核心引數

#vi /etc/sysctl.conffs.aio-max-nr = 1048576fs.file-max = 6815744kernel.shmall =7864320 #記憶體大小/4096分頁大小 kernel.shmmax = 52451655680 #記憶體大小kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.ipv4.ip_local_port_range = 9000 65500net.core.rmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048586vm.nr_hugepages = sga/pagesize  #開啟hugepage,oracle鎖定記憶體防止換出 #sysctl –p 

6.配置NTP

#oracle rac必須進行時鐘同步,如果沒有時鐘同步,按照下面的方式配置,讓oracle自身來解決/sbin/service ntpd stopchkconfig ntpd offmv /etc/ntp.conf /etc/ntp.conf.org

7.關閉防火牆,自動的CentOS是關閉了防火強的,你是用虛擬機器,需要執行這一步

chkconfig --list iptableschkconfig iptables offchkconfig --list iptablesservice iptables stopservice network restart關閉selinux/etc/selinux/configdisable

8.修改使用者限制

#vi /etc/security/limits.conforacle           soft    nofile          4096oracle           hard   nofile          65536oracle           soft    nproc          2047oracle           hard   nproc          16384oracle           soft   stack          10240grid           soft    nofile          4096grid            hard   nofile          65536grid            soft    nproc          2047grid            hard   nproc          16384grid            soft   stack          10240*           soft   memlock         18874368*           hard   memlock          18874368

9. /etc/pam.d/login

echo "session    required     pam_limits.so" >>/etc/pam.d/login

10.安裝需要的包

一般要安裝下面的軟體包yum install -y compat-libstdc++-33yum install -y elfutils-libelf-develyum install -y gcc-c++yum install -y kshyum install -y libaio-develyum install -y libstdc++-develyum install -y libXpyum install -y numactl-develyum install -y unixODBCyum install -y unixODBC-develyum install -y compat-libcap1.x86_64

11.格式化共享磁碟,這點和參考文件有點區別,他是通過3塊盤進行冗餘,我是一塊盤上劃三個分割槽。如果是生產hua環境,建議劃三塊盤,將選舉磁碟和資料盤分到3個不同的盤。由於是共享磁碟,這個操作在一個節點上進行就OK

[root@rac1 ~]# fdisk /dev/vdbWelcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them.Be careful before using the write command.  Command (m for help): nPartition type:   p   primary (0 primary, 0 extended, 4 free)   e   extendedSelect (default p): pPartition number (1-4, default 1): 1First sector (2048-41943039, default 2048): Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +5GPartition 1 of type Linux and of size 5 GiB is set Command (m for help): nPartition type:   p   primary (1 primary, 0 extended, 3 free)   e   extendedSelect (default p): pPartition number (2-4, default 2): First sector (10487808-41943039, default 10487808): Using default value 10487808Last sector, +sectors or +size{K,M,G} (10487808-41943039, default 41943039): +5GPartition 2 of type Linux and of size 5 GiB is set Command (m for help): nPartition type:   p   primary (2 primary, 0 extended, 2 free)   e   extendedSelect (default p): pPartition number (3,4, default 3): 3First sector (20973568-41943039, default 20973568): Using default value 20973568Last sector, +sectors or +size{K,M,G} (20973568-41943039, default 41943039): +5GPartition 3 of type Linux and of size 5 GiB is set Command (m for help): wThe partition table has been altered! Calling ioctl() to re-read partition table.Syncing disks.

[root@rac1 ~]# fdisk /dev/vdcWelcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them.Be careful before using the write command.  Command (m for help): nPartition type:   p   primary (0 primary, 0 extended, 4 free)   e   extendedSelect (default p): pPartition number (1-4, default 1): 1First sector (2048-524287999, default 2048): Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-524287999, default 524287999): +80GPartition 1 of type Linux and of size 80 GiB is set Command (m for help): nPartition type:   p   primary (1 primary, 0 extended, 3 free)   e   extendedSelect (default p): pPartition number (2-4, default 2): First sector (167774208-524287999, default 167774208): Using default value 167774208Last sector, +sectors or +size{K,M,G} (167774208-524287999, default 524287999): +80GPartition 2 of type Linux and of size 80 GiB is set Command (m for help): nPartition type:   p   primary (2 primary, 0 extended, 2 free)   e   extendedSelect (default p): pPartition number (3,4, default 3): First sector (335546368-524287999, default 335546368): Using default value 335546368Last sector, +sectors or +size{K,M,G} (335546368-524287999, default 524287999): +80GPartition 3 of type Linux and of size 80 GiB is set Command (m for help): wThe partition table has been altered! Calling ioctl() to re-read partition table.Syncing disks.[root@iZwz9igcce8m634htwm1xwZ ~]# fdisk -l Disk /dev/vda: 64.4 GB, 64424509440 bytes, 125829120 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x0008d73a    Device Boot      Start         End      Blocks   Id  System/dev/vda1   *        2048   125827071    62912512   83  Linux Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0xf8683fec    Device Boot      Start         End      Blocks   Id  System/dev/vdb1            2048    10487807     5242880   83  Linux/dev/vdb2        10487808    20973567     5242880   83  Linux/dev/vdb3        20973568    31459327     5242880   83  Linux Disk /dev/vdc: 268.4 GB, 268435456000 bytes, 524288000 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0xdd02467a    Device Boot      Start         End      Blocks   Id  System/dev/vdc1            2048   167774207    83886080   83  Linux/dev/vdc2       167774208   335546367    83886080   83  Linux/dev/vdc3       335546368   503318527    83886080   83  Linux[root@rac1~]# 

12.安裝ASM,這裡安裝會升級kernel到el7(用CentOS 7裝叢集應該會好一點)

yum install -y http://download.oracle.com/otn_software/asmlib/oracleasmlib-2.0.4-1.el6.x86_64.rpm

yum install -y http://oss.oracle.com/projects/oracleasm-support/dist/files/RPMS/rhel6/amd64/2.1.8/oracleasm-support-2.1.8-1.el6.x86_64.rpm

13.建立grid,oracle使用者(grid主要用於管理叢集,oracle主要用於管理資料庫,所以待會在配置ASM的時候要把使用者設定為grid,不然後面會出現磁碟許可權的問題)

/usr/sbin/groupadd -g 501 oinstall/usr/sbin/groupadd -g 502 asmadmin/usr/sbin/groupadd -g 503 dba/usr/sbin/groupadd -g 504 oper/usr/sbin/groupadd -g 505 asmdba/usr/sbin/groupadd -g 506 asmoper/usr/sbin/useradd -u 501 -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid/usr/sbin/useradd -u 502 -g oinstall -G dba,asmdba,oper oracle #配置環境變數#Grid#vi /home/grid/.bash_profileumask 022export ORACLE_BASE=/u01/app/grid_baseexport ORACLE_HOME=/u01/app/grid_homeexport ORACLE_SID=+ASM1  #第二個節點+ASM2export PATH=/usr/sbin:$PATHexport PATH=$ORACLE_HOME/bin:$PATH #Oracle#vi /home/oracle/.bash_profileumask 022export ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1export ORA_GRID_HOME=/u01/app/grid_homeexport ORACLE_UNQNAME=OAODZ1  #第二個節點orcl2export ORACLE_SID=OAODZ1 #第二個節點orcl2export PATH=/usr/sbin:$PATHexport PATH=$ORACLE_HOME/bin:$PATHexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:/usr/libexport CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlibexport NLS_LANG=AMERICAN_AMERICA.ZHS16GBKexport NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"export TNS_ADMIN=$ORACLE_HOME/network/adminexport LANG=en_US.UTF-8

太長了,轉到下一篇