1. 程式人生 > >oracle11g rac 配置

oracle11g rac 配置

openfile:
192.168.10.40
DNS+NTP:
192.168.10.41


1.rpm安裝系統包:
rpm -Uvh binutils-*
rpm -ivh compat-libcap1-1.10-1.x86_64.rpm
rpm -Uvh compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm
rpm -Uvh elfutils-libelf-0.*
rpm -Uvh elfutils-libelf-devel-*
rpm -Uvh gcc-4.*
rpm -Uvh gcc-c++-4.*
rpm -Uvh glibc-2.*
rpm -Uvh glibc-common-2.*
rpm -Uvh glibc-devel-2.*
rpm -Uvh glibc-headers-2.*
rpm -Uvh ksh-2*
rpm -Uvh libaio-0.*
rpm -Uvh libaio-devel-0.*
rpm -Uvh libgcc-4.*
rpm -Uvh libstdc++-4.*
rpm -Uvh libstdc++-devel-4.*
rpm -Uvh make-3.*
rpm -Uvh sysstat-7.*
rpm -Uvh unixODBC-2.*
rpm -Uvh unixODBC-devel-2.*


2.建立使用者和組:
/usr/sbin/groupadd -g 501 oinstall
/usr/sbin/groupadd -g 502 dba
/usr/sbin/groupadd -g 503 oper
/usr/sbin/groupadd -g 504 asmadmin
/usr/sbin/groupadd -g 505 asmoper
/usr/sbin/groupadd -g 506 asmdba
/usr/sbin/useradd -g oinstall -G dba,asmdba,oper -u 500 oracle
/usr/sbin/useradd -g oinstall -G asmadmin,asmdba,asmoper,oper,dba -u 501 grid

3.建立目錄:

mkdir -p /u01/app/
chmod -R 775 /u01/app/

mkdir -p /u01/app/oraInventory
chown -R grid:oinstall /u01/app/oraInventory
chmod -R 775 /u01/app/oraInventory

mkdir -p /u01/app/grid
mkdir /u01/app/11.2.0/grid -p
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oracle/cfgtoollogs
chown -R grid:oinstall /u01/app/11.2.0
chown -R grid:oinstall /u01/app/grid
chown -R oracle:oinstall /u01/app/oracle/
chmod -R 775 /u01/app/oracle/
chmod -R 775 /u01/app/grid

4.修改hosts檔案

127.0.0.1              localhost.lbdb.com       localhost
192.168.40.11          node1.lbdb.com           node1
192.168.40.12          node2.lbdb.com           node2
10.10.10.11            node1-priv.lbdb.com      node1-priv
10.10.10.12            node2-priv.lbdb.com      node2-priv
192.168.40.13          node1-vip.lbdb.com       node1-vip
192.168.40.14          node2-vip.lbdb.com       node2-vip


192.168.40.15         node-scan.lbdb.com       node-scan
192.168.40.16         node-scan.lbdb.com       node-scan
192.168.40.17         node-scan.lbdb.com       node-scan

5.修改引數
cat >> /etc/security/limits.conf << EOF
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF

cat >> /etc/pam.d/login << EOF
session required /lib/security/pam_limits.so
EOF

cat >> /etc/sysctl.conf << EOF
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 8388608
kernel.shmmax = 536870912
kernel.shmmax = 1073741824
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
EOF



6.修改使用者環境變數:
su - grid

export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid/product/11.2/grid
export PATH=$PATH:/u01/app/grid/product/11.2/grid/bin
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
#根據具體環境設定
#export ORACLE_SID=+ASM1
#export ORACLE_SID=+ASM2

if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
        if [ $SHELL = "/bin/ksh" ]; then
             ulimit -p 16384
               ulimit -n 65536
       else
         ulimit -u 16384 -n 65536
        fi
       umask 022
fi





su - oracle

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2/db
export PATH=$PATH:/u01/app/oracle/product/11.2/db/bin
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
#根據具體環境設定
#export ORACLE_SID=bridge1
#export ORACLE_SID=bridge2
export ORACLE_UNQNAME=bridge 安裝資料庫時候 開啟em功能  需要設定
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
        if [ $SHELL = "/bin/ksh" ]; then
             ulimit -p 16384
               ulimit -n 65536
       else
         ulimit -u 16384 -n 65536
        fi
       umask 022
fi


7.停止ntp並刪除ntp配置檔案和服務(注意兩個節點都要操作)
/etc/init.d/ntpd stop
 mv /etc/ntp.conf /etc/ntp.conf-bak


8.掛載磁碟並分割槽
本文使用iscsic
rpm -ivh iscsi-initiator-utils-6.2.0.871-0.16.el5.x86_64.rpm
/etc/init.d/iscsi restart
/etc/init.d/iscsid restart
chkconfig iscsi on
chkconfig iscsid on
發現:
iscsiadm -m discovery -t sendtargets -p 192.168.10.40
手動掛起:
iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.28fcc085aa01 -p 192.168.10.40 -l

9.使用udev管理磁碟裝置
#安裝oracleasm
拍虛擬機器快照
 fdisk格式化磁碟
兩個節點執行:
vi /etc/udev/rules.d/60-raw.rules
新增如下內容:
ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="raw1", OWNER="grid",GROUP="asmadmin",MODE="660"
ACTION=="add", KERNEL=="sdc1", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="raw2", OWNER="grid",GROUP="asmadmin",MODE="660"
ACTION=="add", KERNEL=="sdd1", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="raw3", OWNER="grid",GROUP="asmadmin",MODE="660"
重啟udev:
start_udev


#oracleasm configure -i
#oracleasm init
#一個節點執行:
#oracleasm createdisk ocr_vote /dev/sdd1

10.安裝grid
上傳grid檔案到node1的grid使用者目錄下並解壓
執行./runInstaller 安裝


11.用oracle使用者登入,安裝oracle資料庫軟體,oracle

12.建立ASM 磁碟組
以grid使用者登入系統,使用asmca命令建立磁碟組


13.以oracle使用者執行dbca建立資料庫。
注意:
記憶體選擇70%時候報錯:
如下解決:
vi /etc/fstab
tmpfs                   /dev/shm                tmpfs   defaults,size=1250M        0 0
mount -o remount /dev/shm
兩個節點都要執行。

配置DNS伺服器:
首先確認主機名稱:
編輯hosts檔案
vi /etc/hosts                                      
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1                    localhost.zhou.com     localhost
192.168.10.87           www.zhou.com           www

一、安裝 DNS Server         
rpm -ivh bind-9.3.6-4.P1.el5_4.2.x86_64.rpm
rpm -ivh bind-chroot-9.3.6-4.P1.el5_4.2.x86_64.rpm                     
rpm -ivh caching-nameserver-9.3.6-4.P1.el5_4.2.x86_64.rpm
  二、配置 DNS Server
 
 (1)、建立主配置檔案 named.conf
  cd /var/named/chroot/etc
  cp -p named.caching-nameserver.conf named.conf
  vi named.conf   ###修改named.conf檔案,將原始檔中的所有localhost以及127.0.0.1修改成any,注意any;前後保留空格還有最後
  include "/etc/named.zones";名字  
  修改後如下:
                                                                          
[

[email protected] etc]# cat named.conf                                               
//                                                                           
// named.caching-nameserver.conf                                             
//                                                                           
// Provided by Red Hat caching-nameserver package to configure the           
// ISC BIND named(8) DNS server as a caching only nameserver                 
// (as a localhost DNS resolver only).                                       
//                                                                           
// See /usr/share/doc/bind*/sample/ for example named configuration files.   
//                                                                           
// DO NOT EDIT THIS FILE - use system-config-bind or an editor               
// to create named.conf - edits to this file will be lost on                 
// caching-nameserver package upgrade.                                       
//                                                                           
options {                                                                    
    listen-on port 53 { any; };                                                
    listen-on-v6 port 53 { ::1; };                                             
    directory     "/var/named";                                                  
    dump-file     "/var/named/data/cache_dump.db";                             
        statistics-file "/var/named/data/named_stats.txt";                 
        memstatistics-file "/var/named/data/named_mem_stats.txt";          
                                                                           
    // Those options should be used carefully because they disable port      
    // randomization                                                         
    // query-source    port 53;                                                 
    // query-source-v6 port 53;                                              
                                                                           
    allow-query     { any; };                                                
    allow-query-cache { any; };                                              
};                                                                         
logging {                                                                  
        channel default_debug {                                            
                file "data/named.run";                                     
                severity dynamic;                                          
        };                                                                 
};                                                                         
view localhost_resolver {                                                  
    match-clients        { any; };                                             
    match-destinations { any; };                                             
    recursion yes;                                                           
    include "/etc/named.zones";    ###此處需要修改,修改的名字為以下的    cp -p named.rfc1912.zones named.zones                                         
};                                                                         



(2)cp -p named.rfc1912.zones named.zones
 
  #以下兩個zone為新增的,包含正向和反向zone
  vi named.zones修改後的結果如下:  
   
[
[email protected]
etc]# cat named.zones                                                   
// named.rfc1912.zones:                                                           
//                                                                                
// Provided by Red Hat caching-nameserver package                                 
//                                                                                
// ISC BIND named zone configuration for zones recommended by                     
// RFC 1912 section 4.1 : localhost TLDs and address zones                        
//                                                                                
// See /usr/share/doc/bind*/sample/ for example named configuration files.        
//                                                                                
#zone "." IN {
#       type hint;
#       file "named.ca";
#};
zone "." IN {
        type hint;
        file "/dev/null";
};

                                                                                  
zone "localdomain" IN {                                                           
    type master;                                                                    
    file "localdomain.zone";                                                        
    allow-update { none; };                                                         
};                                                                                
                                                                                  
zone "localhost" IN {                                                             
    type master;                                                                    
    file "localhost.zone";                                                          
    allow-update { none; };                                                         
};                                                                                
                                                                                  
zone "0.0.127.in-addr.arpa" IN {                                                  
    type master;                                                                    
    file "named.local";                                                             
    allow-update { none; };                                                         
};                                                                                
                                                                                  
zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
        type master;                                                              
    file "named.ip6.local";                                                         
    allow-update { none; };                                                         
};                                                                                
                                                                                  
zone "255.in-addr.arpa" IN {                                                      
    type master;                                                                    
    file "named.broadcast";                                                         
    allow-update { none; };                                                         
};                                                                                
                                                                                  
zone "0.in-addr.arpa" IN {                                                        
    type master;                                                                    
    file "named.zero";                                                              
    allow-update { none; };                                                         
};                                                                                
zone "bridge.org" IN {                                                            
        type master;                                                              
        file "www.bridge.zero";       ###注意和主機名稱對應                                            
        allow-update { none; };                                                   
};                                                                                
zone "88.168.192.in-addr.arpa" IN {                                               
        type master;                                                              
        file "88.168.192.local";                                                  
        allow-update { none; };                                                   
};                                                                                


(3)#配置正向和反向搜尋資料庫解析檔案
      [
[email protected]
etc]# pwd  
      /var/named/chroot/etc  
      [[email protected] etc]# cd  ../var/named/    
      
      #同樣使用cp -p 方式複製檔案到新的正向和反向檔案
      [[email protected] named]# cp -p named.zero  www.bridge.zero  名字與上面的新增解析檔名字一樣
      [[email protected] named]# cp -p named.local 88.168.192.local   名字與上面的新增解析檔名字一樣
 
      #下面是修改之後的正向搜尋檔案,也可以將host檔案的其他ip對照編輯到正向搜尋檔案以實現解析  
      #如下面的例子將vip的參照關係也新增到解析檔案  
      

[[email protected] named]# cat www.bridge.zero
$TTL    86400
@               IN SOA  www.bridge.org.      root.bridge.org. (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
    IN    NS    www.bridge.org.
node-scan      IN   A   192.168.88.100
node-scan      IN   A   192.168.88.101
node-scan      IN   A   192.168.88.102
node1          IN   A   192.168.88.81
node2          IN   A   192.168.88.82
node1-vip      IN   A   192.168.88.91
node2-vip      IN   A   192.168.88.92



                                 
 #下面是修改之後的反向搜尋檔案   
 
 [[email protected] named]# cat 88.168.192.local
$TTL    86400
@       IN      SOA     www.bridge.org. root.bridge.org.  (
                                      1997022700 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
        IN      NS      www.bridge.org.
1       IN      PTR     www.bridge.org.
100     IN      PTR     node-scan.
101     IN      PTR     node-scan.
102     IN      PTR     node-scan.
81      IN      PTR     node1.
82      IN      PTR     node2.
91      IN      PTR     node1-vip.
92      IN      PTR     node2-vip.

   
dns配置注意:
修改許可權:
cd /var/run
chmod 777 named

檢視報錯資訊:
named -d 3 -f -g
tail -f /var/log/messages
建立soft link:
ln -s /var/named/chroot/etc/named.conf /etc/named.conf
ln -s /var/named/chroot/etc/named.zones /etc/named.zones

重啟那麼多服務
(4)為客戶端新增dns解析:

編輯 /etc/resolv.conf 檔案,
編輯後內容如下:
[[email protected] ~]# cat /etc/resolv.conf
search bridge.org       
nameserver 192.168.88.11
 
 修改 vi /etc/nsswitch.conf檔案:
[[email protected] ~]# cat /etc/nsswitch.conf
#
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
#
# Legal entries are:
#
#    nisplus or nis+        Use NIS+ (NIS version 3)
#    nis or yp        Use NIS (NIS version 2), also called YP
#    dns            Use DNS (Domain Name Service)
#    files            Use the local files
#    db            Use the local database (.db) files
#    compat            Use NIS on compat mode
#    hesiod            Use Hesiod for user lookups
#    [NOTFOUND=return]    Stop searching if not found so far
#

# To use db, put the "db" in front of "files" for entries you want to be
# looked up first in the databases
#
# Example:
#passwd:    db files nisplus nis
#shadow:    db files nisplus nis
#group:     db files nisplus nis

passwd:     files
shadow:     files
group:      files

#hosts:     db files nisplus nis dns
hosts:      dns files   #######更改此處的解析順序

# Example - obey only what nisplus tells us...
#services:   nisplus [NOTFOUND=return] files
#networks:   nisplus [NOTFOUND=return] files
#protocols:  nisplus [NOTFOUND=return] files
#rpc:        nisplus [NOTFOUND=return] files
#ethers:     nisplus [NOTFOUND=return] files
#netmasks:   nisplus [NOTFOUND=return] files     

bootparams: nisplus [NOTFOUND=return] files

ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files

netgroup:   nisplus

publickey:  nisplus

automount:  files nisplus
aliases:    files nisplus






 



RAC簡單維護:
srvctl:
1.啟動一個與資料庫相關的所有例項:
srvctl start database -d bridge

2.關閉一個與資料庫相關的所有例項:
srvctl stop database -d bridge

3.檢視資料庫的當前狀態:
srvctl status database -d bridge

4.啟動其中單一的例項:
srvctl start instance -d bridge -i bridge1
srvctl start instance -d bridge -n node1

5.表空間維護:
oracle 11G R2 RAC ASM 建立表空間:
CREATE TABLESPACE TBS_IMOOLLY DATAFILE '+DATA' SIZE 128M AUTOEXTEND ON NEXT 128M MAXSIZE 8192M;

刪除表空間:
DROP TABLESPACE tablespacename INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS;

oracle 11G R2 RAC ASM 建立臨時表空間:
CREATE TEMPORARY TABLESPACE TBS_IMOOLLY_TEMP TEMPFILE '+DATA' SIZE 128M AUTOEXTEND ON NEXT 128M MAXSIZE 8192M;