Oracle11gR2中已經集成了direct nfs driver,而在此以前是沒有改驅動的linux
也就是說在11gR2中,通過簡單設置以後,就能直接利用其餘NAS存儲設備了。sql
和傳統的nfs比,好處是提升了性能和配置的簡便性.數據庫
下面簡要描述一下direct nfs 的配置過程。後端
環境以下:兩臺linux5.5服務器
其中:一臺安裝oracle11gR2,也是nfs client (IP:192.168.133.11,NAME:edbj2p1);oracle
一臺nfs server (IP:192.168.133.12,NAME:edbj2p2) ;app
服務器端共享的目錄: /vol/oradatatcp
客戶端掛載點:/u02/oradata/prod1性能
建立的表空間:shared_dataui
1.配置服務端edbj2p2
[root@edbj2p2 ~]# echo '/vol/oradata 192.168.133.11(rw,no_root_squash,insecure)' >> /etc/exports
注意:這裏必定要加 insecure,不然,沒法正常使用dnfs
[root@edbj2p2 ~]# exportfs -arv
[root@edbj2p2 ~]# service nfs restart
--肯定服務端的nfs共享
[root@edbj2p2 ~]# showmount -e edbj2p2
Export list for edbj2p2:
/vol/oradata 192.168.133.11
2.配置客戶端edbj2p1
2.1 肯定portmap服務運行
[root@edbj2p2 ~]# service portmap status
portmap (pid 3540) is running...
2.2先確認在客戶端機器能夠看到服務器端共享出來的nfs
[root@edbj2p1 ~]# showmount -e edbj2p2
Export list for edbj2p2:
/vol/oradata 192.168.133.11
2.3調整libodm11.so文件
[oracle@edbj2p1 ~]$ cd $ORACLE_HOME/lib
[oracle@edbj2p1 lib]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/lib
--修改libodm11.so,使用libnfsodm11.so
[oracle@edbj2p1 lib]$ mv libodm11.so libodm11.so.bak
[oracle@edbj2p1 lib]$ ln -s libnfsodm11.so libodm11.so
或者 一條命令搞定:
make -f ins_rdbms.mk dnfs_on
確認一下
[oracle@edbj2p1 lib]$ ls -ltr libodm*
-rw-r--r-- 1 oracle oinstall 5266 Sep 18 2011 libodm11.a
-rw-r--r-- 1 oracle oinstall 8957 Sep 18 2011 libodmd11.so
lrwxrwxrwx 1 oracle oinstall 12 Feb 5 16:05 libodm11.so.bak -> libodmd11.so
lrwxrwxrwx 1 oracle oinstall 14 Feb 6 11:39 libodm11.so -> libnfsodm11.so
2.4 建立oranfstab文件
--進入$ORACLE_HOME/dbs目錄
[oracle@edbj2p1 lib]$ cd $ORACLE_HOME/dbs
[oracle@edbj2p1 dbs]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/dbs
--建立 oranfstab
[oracle@edbj2p1 dbs]$ touch oranfstab
[oracle@edbj2p1 dbs]$ echo 'server:edbj2p2' >> oranfstab
[oracle@edbj2p1 dbs]$ echo 'path:192.168.133.12' >> oranfstab
[oracle@edbj2p1 dbs]$ echo 'export: /vol/oradata mount: /u02/oradata/prod1' >> oranfstab
其中:server:edbj2p2 表明nfs server的hostname
path:192.168.133.12 表明nfs server的IP
export: /vol/oradata 表明服務器端的目錄
mount: /u02/oradata/prod1 表明nfs client上的目錄
--在客戶端事先建好目錄
[root@edbj2p1 ~]# mkdir -p /u02/oradata/prod1
[root@edbj2p1 ~]# chown -R oracle:oinstall /u02/oradata/prod1
[root@edbj2p1 ~]# chmod -R 775 /u02/oradata/prod1
3.加載nfs (在客戶端操做)
3.1 直接加載nfs
mount -t nfs edbj2p2:/vol/oradata /u02/oradata/prod1
3.2 永久生效,須要修改/etc/fstab
192.168.133.12:/vol/oradata /u02/oradata/prod1 nfs defaults 0 0
3.3 檢查掛載結果
[root@edbj2p1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
...
192.168.133.12:/vol/oradata
16G 2.8G 12G 20% /u02/oradata/prod1
4.dnfs生效 (在客戶端操做)
只有重起數據庫,才能生效
sqlplus /nolog
sql>startup force
檢查數據庫日誌,有如下記錄:
...
diagnostic_dest = "/u01/app/oracle/product/11.2.0/dbhome_1"
Oracle instance running with ODM: Oracle Direct NFS ODM Library Version 3.0
Mon Feb 06 14:35:54 2017
...
Direct NFS: attempting to mount /vol/oradata on filer edbj2p2 defined in oranfstab
Direct NFS: channel config is:
channel id [0] local path [192.168.133.12]
Direct NFS: mount complete dir /vol/oradata on edbj2p2 mntport 854 nfsport 2049
Direct NFS: channel id [0] path [192.168.133.12] to filer [edbj2p2] via local is UP
Direct NFS: channel id [1] path [192.168.133.12] to filer [edbj2p2] via local is UP
5.在dnfs上創建表空間 (在客戶端操做)
create tablespace SHARED_DATA datafile '/u02/oradata/prod1/shared_data01.dbf' size 10m;
題外話:
create tablespace SHARED_DATA datafile '/u02/oradata/prod1/shared_data01.dbf' size 10m
Direct NFS: please check that oradism is setuid
若是後端報這個錯,須要設置setuid
chown root oradism
chmod u+s oradism
6.驗證:
6.1 v$dnfs_servers中,svrname應該是oranfstab中的server後面的項目
col dirname for a13
col SVRNAME for a10
select * from v$dnfs_servers;
1* select * from v$dnfs_servers
ID SVRNAME DIRNAME MNTPORT NFSPORT WTMAX RTMAX
1 edbj2p2 /vol/oradata 854 2049 32768 32768
6.2 數據文件使用狀況
col filename for a40
select * from V$DNFS_FILES
FILENAME FILESIZE PNUM SVR_ID
/u02/oradata/prod1/shared_data01.dbf 10493952 10 1
6.3 dnfs通道狀況
col path for a20
col local for a10
set line 200
select * from V$DNFS_CHANNELS
PNUM SVRNAME PATH LOCAL CH_ID SVR_ID SENDS RECVS PINGS
10 edbj2p2 192.168.133.12 0 1 0 0 0
10 edbj2p2 192.168.133.12 1 1 0 0 0
11 edbj2p2 192.168.133.12 0 1 0 0 0
11 edbj2p2 192.168.133.12 1 1 0 0 0
30 edbj2p2 192.168.133.12 0 1 0 0 0
6.4 服務器端端口鏈接狀況:
[root@edbj2p2 oradata]# netstat -an |grep 2049
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN
tcp 0 0 192.168.133.12:2049 192.168.133.11:20295 ESTABLISHED
tcp 0 0 192.168.133.12:2049 192.168.133.11:51581 ESTABLISHED
tcp 0 0 192.168.133.12:2049 192.168.133.11:690 ESTABLISHED
tcp 0 0 192.168.133.12:2049 192.168.133.11:36340 ESTABLISHED
tcp 0 0 192.168.133.12:2049 192.168.133.11:15344 ESTABLISHED
udp 0 0 0.0.0.0:2049 0.0.0.0:*