NFS共享儲存

賀子_DBA時代發表於2015-08-12

1.First we need to set up some NFS shares. In this case we will do this on the RAC1 node, but you can do the on a NAS or a third server if you have one available. On the RAC1 node create the following directories.

mkdir /shared_config

mkdir /shared_grid

mkdir /shared_home

mkdir /shared_data

Add the following lines to the "/etc/exports" file.    這個步驟控制著共享。只在主節點操作。

/shared_config               *(rw,sync,no_wdelay,insecure_locks,no_root_squash)

/shared_grid                 *(rw,sync,no_wdelay,insecure_locks,no_root_squash)

/shared_home                 *(rw,sync,no_wdelay,insecure_locks,no_root_squash)

/shared_data                 *(rw,sync,no_wdelay,insecure_locks,no_root_squash)

 

2.Run the following command to export the NFS shares.

chkconfig nfs on

service nfs restart

On both RAC1 and RAC2 create the directories in which the Oracle software will be installed.

mkdir -p /software/app/11.2.0/grid

mkdir -p /software/app/oracle/product/11.2.0/db_1

mkdir -p /software/oradata

mkdir -p /software/shared_config

chown -R oracle:oinstall /software/app /software/app/oracle /software/oradata /software/shared_config

chmod -R 775 /software/app /software/app/oracle /software/oradata /software/shared_config

3.Add the following lines to the "/etc/fstab" file.      #開機自動掛載 

nas1:/shared_config /software/shared_config  nfs  rw,bg,hard,nointr,tcp,vers=3,timeo=600,rsize=32768,wsize=32768,actimeo=0  0 0

nas1:/shared_grid   /software/app/11.2.0/grid  nfs  rw,bg,hard,nointr,tcp,vers=3,timeo=600,rsize=32768,wsize=32768,actimeo=0  0 0

nas1:/shared_home   /software/app/oracle/product/11.2.0/db_1  nfs  rw,bg,hard,nointr,tcp,vers=3,timeo=600,rsize=32768,wsize=32768,actimeo=0  0 0

nas1:/shared_data   /software/oradata  nfs  rw,bg,hard,nointr,tcp,vers=3,timeo=600,rsize=32768,wsize=32768,actimeo=0  0 0

4.Mount the NFS shares on both servers.

mount  /software/shared_config  

mount  /software/app/11.2.0/grid

mount  /software/app/oracle/product/11.2.0/db_1

mount  /software/oradata

5.Make sure the permissions on the shared directories are correct.

chown -R oracle:oinstall /software/shared_config

chown -R oracle:oinstall /software/app/11.2.0/grid

chown -R oracle:oinstall /software/app/oracle/product/11.2.0/db_1

chown -R oracle:oinstall /software/oradata


實際工作中的問題:RAC共享磁碟是利用的NFS
rac1: 192.168.3.21
rac2:192.168.3.26
[oracle@rac1 ~]$ df -h
檔案系統              容量  已用 可用 已用% 掛載點
/dev/sda2             142G  107G   29G  79% /
/dev/sda6              66G   48G   16G  76% /data
/dev/sda3              48G   20G   25G  45% /software
/dev/sda1             190M   14M  167M   8% /boot
tmpfs                  16G  537M   16G   4% /dev/shm
/dev/mapper/mpath2    2.0T  2.0T  0G  100% /backup
/dev/mapper/oraclep1 1008G  661G  297G  70% /software/oradata01
rac1:/shared_grid     142G  107G   29G  79% /software/app/11.2.0/grid
rac1:/shared_home     142G  107G   29G  79% /software/app/oracle/product/11.2.0/db_1
rac1:/shared_config   142G  107G   29G  79% /software/shared_config
rac1:/shared_data     142G  107G   29G  79% /software/oradata
none                   16G  128K   16G   1% /var/lib/xenstored
/dev/mapper/mpath3    2.0T  1.2T  645G  66% /software/oradata02
現在是/backup 這個目錄已經滿了   但是這個裡面是要存邏輯備份的,
因為這個這個目錄也是共享的,定時任務裡的指令碼路徑好多都是寫的/backup/expdp,所以要是不想一個一個去改指令碼,最好的辦法就是把一個新的檔案系統掛在到/backup/expdp  這個目錄下。下面是具體過程;
一:先把expdp重新命名成expdp1 ,然後重新在/backup下建立expdp 目錄。這步驟非常重要,因為如果你直接將一個新的檔案系統掛在到/backup/expdp,就會導致原來/backup/expdp下面的內容就看不到了。
[oracle@rac1 backup]$ mv expdp expdp1
第二:把新加進的磁碟,建立成檔案系統之後,
[oracle@rac1 backup]$ mount    /dev/mapper/mpath4         /backup/expdp
第三:然後把/backup/expdp1下所有內容mv到/backup/expdp下,這樣就能滿足不用修改指令碼,空間也是足夠的,以為這時候你雖然還是在/backup/expdp這個目錄裡寫東西,但是底層檔案系統已經改變。

但是這個時候還要讓他共享。
[oracle@rac1 backup]$ cat /etc/exports                  
#/software/oradata01    192.168.3.0/24(rw,sync,no_root_squash)
#/1TB   192.168.3.0/24(rw,sync,no_root_squash)
#/one   192.168.3.0/24(rw,sync,no_root_squash)
#/two   192.168.3.0/24(rw,sync,no_root_squash)
#/three 192.168.3.0/24(rw,sync,no_root_squash)
#/five  192.168.3.0/24(rw,sync,no_root_squash)
#/six   192.168.3.0/24(rw,sync,no_root_squash)
/shared_config               *(rw,sync,no_wdelay,insecure_locks,no_root_squash)
/shared_grid                 *(rw,sync,no_wdelay,insecure_locks,no_root_squash)
/shared_home                 *(rw,sync,no_wdelay,insecure_locks,no_root_squash)
/shared_data                 *(rw,sync,no_wdelay,insecure_locks,no_root_squash)
/software/oradata01          *(rw,sync,no_wdelay,insecure_locks,no_root_squash)
/software/oradata02          *(rw,sync,no_wdelay,insecure_locks,no_root_squash)
/backup 192.168.3.0/24(rw,sync,no_root_squash)
原來只是共享了/backup,
這時候你在 rac2只能看到有expdp這個目錄,但是這下面沒有任何內容。
[oracle@rac2 ~]$ df -h
檔案系統              容量  已用 可用 已用% 掛載點
/dev/sda2              76G   16G   57G  22% /
/dev/sda6             132G   87G   39G  69% /data
/dev/sda3              48G   23G   22G  52% /software
/dev/sda1             190M   20M  161M  11% /boot
tmpfs                  16G     0   16G   0% /dev/shm
rac1:/shared_data     142G  107G   29G  79% /software/oradata
rac1:/shared_grid     142G  107G   29G  79% /software/app/11.2.0/grid
rac1:/software/oradata01
                     1008G  661G  297G  70% /software/oradata01
rac1:/shared_config   142G  107G   29G  79% /software/shared_config
rac1:/shared_home     142G  107G   29G  79% /software/app/oracle/product/11.2.0/db_1
none                   16G  128K   16G   1% /var/lib/xenstored
rac1:/software/oradata02
                      2.0T  1.2T  645G  66% /software/oradata02
192.168.3.21:/backup  2.0T  1.3T  666G  66% /backup
[oracle@rac2 backup]$ cd expdp/
[oracle@rac2 expdp]$ ll
總計 0
 怎樣才可能讓rac2也能看到內容呢? 如下所示:
1.首先在rac1操作:  將/backup/expdp也新增到共享檔案中。
[oracle@rac1 backup]$ vi /etc/exports    
#/software/oradata01    192.168.3.0/24(rw,sync,no_root_squash)
#/1TB   192.168.3.0/24(rw,sync,no_root_squash)
#/one   192.168.3.0/24(rw,sync,no_root_squash)
#/two   192.168.3.0/24(rw,sync,no_root_squash)
#/three 192.168.3.0/24(rw,sync,no_root_squash)
#/five  192.168.3.0/24(rw,sync,no_root_squash)
#/six   192.168.3.0/24(rw,sync,no_root_squash)
/shared_config               *(rw,sync,no_wdelay,insecure_locks,no_root_squash)
/shared_grid                 *(rw,sync,no_wdelay,insecure_locks,no_root_squash)
/shared_home                 *(rw,sync,no_wdelay,insecure_locks,no_root_squash)
/shared_data                 *(rw,sync,no_wdelay,insecure_locks,no_root_squash)
/software/oradata01          *(rw,sync,no_wdelay,insecure_locks,no_root_squash)
/software/oradata02          *(rw,sync,no_wdelay,insecure_locks,no_root_squash)
/backup 192.168.3.0/24(rw,sync,no_root_squash)
/backup/expdp  192.168.3.0/24(rw,sync,no_root_squash)
2.重啟nfs服務:
[oracle@rac1 backup]$ service nfs restart
3,在rac2操作,重新掛載/backup
[oracle@rac2 ~]$ umount 192.168.3.21:/backup  /backup/   
[oracle@rac2 ~]$mount 192.168.3.21:/backup  /backup/  
4,這時候就會發現能看到了。
[oracle@rac2 expdp]$ ll 
-rw-r--r-- 1 oracle oinstall        2608 07-17 04:06 GLOBAL_DE_DE_150717-0405.log
-rw-r----- 1 oracle oinstall      471040 07-18 04:12 GLOBAL_DE_DE_150718-0411.dmp
-rw-r--r-- 1 oracle oinstall        2608 07-18 04:12 GLOBAL_DE_DE_150718-0411.log
-rw-r----- 1 oracle oinstall      471040 07-19 04:10 GLOBAL_DE_DE_150719-0409.dmp
-rw-r--r-- 1 oracle oinstall        2608 07-19 04:10 GLOBAL_DE_DE_150719-0409.log
-rw-r----- 1 oracle oinstall      471040 07-20 04:06 GLOBAL_DE_DE_150720-0404.dmp
-rw-r--r-- 1 oracle oinstall        2608 07-20 04:06 GLOBAL_DE_DE_150720-0404.log
-rw-r----- 1 oracle oinstall      471040 07-21 04:16 GLOBAL_DE_DE_150721-0415.dmp
-rw-r--r-- 1 oracle oinstall        2608 07-21 04:16 GLOBAL_DE_DE_150721-0415.log
-rw-r----- 1 oracle oinstall      471040 07-22 04:15 GLOBAL_DE_DE_150722-0413.dmp
-rw-r--r-- 1 oracle oinstall        2608 07-22 04:15 GLOBAL_DE_DE_150722-0413.log
-rw-r----- 1 oracle oinstall      471040 07-23 04:07 GLOBAL_DE_DE_150723-0405.dmp
-rw-r--r-- 1 oracle oinstall        2608 07-23 04:07 GLOBAL_DE_DE_150723-0405.log
-rw-r----- 1 oracle oinstall      471040 07-24 04:05 GLOBAL_DE_DE_150724-0404.dmp
-rw-r--r-- 1 oracle oinstall        2608 07-24 04:05 GLOBAL_DE_DE_150724-0404.log
-rw-r----- 1 oracle oinstall      471040 07-25 04:12 GLOBAL_DE_DE_150725-0411.dmp
-rw-r--r-- 1 oracle oinstall        2608 07-25 04:12 GLOBAL_DE_DE_150725-0411.log
最好再設定成開機自動掛載:
[oracle@rac2 ~]$ cat /etc/fstab 
LABEL=/1                /                       ext3    defaults        1 1
LABEL=/data             /data                   ext3    defaults        1 2
LABEL=/software         /software               ext3    defaults        1 2
LABEL=/boot1            /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda5         swap                    swap    defaults        0 0
# 192.168.3.21:/one     /one                    nfs     defaults        0 0
# 192.168.3.21:/1TB     /1TB                    nfs     defaults        0 0
# 192.168.3.21:/two     /two                    nfs     defaults        0 0
# 192.168.3.21:/three   /three                  nfs     defaults        0 0
# 192.168.3.21:/five    /five                   nfs     defaults        0 0
# 192.168.3.21:/six     /six                    nfs     defaults        0 0
rac1:/shared_config /software/shared_config  nfs  rw,bg,hard,nointr,tcp,vers=3,timeo=600,rsize=32768,wsize=32768,actimeo=0  0 0
rac1:/shared_grid   /software/app/11.2.0/grid  nfs  rw,bg,hard,nointr,tcp,vers=3,timeo=600,rsize=32768,wsize=32768,actimeo=0  0 0
rac1:/shared_home   /software/app/oracle/product/11.2.0/db_1  nfs  rw,bg,hard,nointr,tcp,vers=3,timeo=600,rsize=32768,wsize=32768,actimeo=0  0 0
rac1:/shared_data   /software/oradata  nfs  rw,bg,hard,nointr,tcp,vers=3,timeo=600,rsize=32768,wsize=32768,actimeo=0  0 0
rac1:/software/oradata01   /software/oradata01  nfs  rw,bg,hard,nointr,tcp,vers=3,timeo=600,rsize=32768,wsize=32768,actimeo=0  0 0
192.168.3.21:/backup    /backup                 nfs     defaults        0 0               #這就開機自動掛載了











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

相關文章