這篇文章主要介紹oracle中dbfs文件系統(tǒng)怎么用,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
從網(wǎng)站建設(shè)到定制行業(yè)解決方案,為提供網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)服務(wù)體系,各種行業(yè)企業(yè)客戶提供網(wǎng)站建設(shè)解決方案,助力業(yè)務(wù)快速發(fā)展。創(chuàng)新互聯(lián)將不斷加快創(chuàng)新步伐,提供優(yōu)質(zhì)的建站服務(wù)。
一、DBFS介紹
Dbfs在文件和目錄之上創(chuàng)建了一個(gè)標(biāo)準(zhǔn)的文件系統(tǒng)結(jié)構(gòu),并且將數(shù)據(jù)存儲(chǔ)在數(shù)據(jù)庫基表里面。DBFS很像NFS,因?yàn)樗峁┝艘粋€(gè)與本地文件系統(tǒng)相同的共享的網(wǎng)絡(luò)文件系統(tǒng)。與NFS一樣,由Server與Client組成。
在DBFS中,Server為Oracle數(shù)據(jù)庫,文件存儲(chǔ)在表的一個(gè)SecureFiles LOBs字段里面。一個(gè)PLSQL存儲(chǔ)過程的集合,提供了訪問文件系統(tǒng)的基本操作,比如說create、open、read、write,ls。DBFS目錄庫允許每個(gè)數(shù)據(jù)庫用戶創(chuàng)建一個(gè)或多個(gè)文件系統(tǒng),并且可以被clients使用。每個(gè)文件系統(tǒng)擁有專有的數(shù)據(jù)表,保證文件系統(tǒng)的內(nèi)容。
二、Client端安裝fuse
確定fuse版本
uname –a
Linux DB-SERVER-02 2.6.18-164.el5#1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
本機(jī)kernelversion 2.6.18
Kernel version 2.6.x
x>9都需要使用 fuse-2.7.4
下載fuse安裝包
下載地址:
http://fuse.sourceforge.net
或者
http://sourceforge.net/projects/fuse
檢查kernel-devel包
# rpm –q kernel-devel
如果沒有安裝,掛載安裝盤后安裝package
安裝fuse
$ tar -xzvf fuse-2.7.4.tar.gz
$ cd [fuse_src_dir]
$ ./configure --prefix=/usr --with-kernel=[yourkernel dir]
$ make
$ sudo su
# make install
# /sbin/depmod
# /sbin/modprobe fuse
# chmod 666 /dev/fuse
# echo "/sbin/modprobe fuse" >>/etc/rc.modules
示例
查看是否安裝了所需安裝包
[root@mytest ~]# rpm -q kernel-devel
package kernel-devel is not installed
掛載光盤
[root@mytest dev]# mount /dev/hdc /mnt
mount: block device /dev/hdc iswrite-protected,
mounting read-only
安裝kernel-devel包
[root@mytest Server]# rpm -ivh kernel-devel-2.6.18-308.el5.x86_64.rpm
Preparing... ########################################### [100%]
1:kernel-devel ###########################################[100%]
查看kernelversion
[root@mytest Server]# uname -a
Linux mytest 2.6.18-308.el5#1 SMP Sat Feb 25 12:40:07 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
ftp將fuse2.7.4上傳至服務(wù)器/root目錄下
[root@mytest ~]# pwd
/root
[root@mytest ~]# ls -l fuse-2.7.4.tar.gz
-rw-r--r-- 1 root root 506658 Jun 11 13:54 fuse-2.7.4.tar.gz
解壓
[root@mytest ~]# tar -xzvf fuse-2.7.4.tar.gz
[root@mytest ~]# cd fuse-2.7.4
安裝
[root@mytest fuse-2.7.4]#./configure
[root@mytest fuse-2.7.4]#make
[root@mytest fuse-2.7.4]#make install
[root@mytest fuse-2.7.4]#/sbin/depmod
[root@mytest fuse-2.7.4]#/sbin/modprobe fuse
[root@mytest fuse-2.7.4]#chmod 666 /dev/fuse
[root@mytest fuse-2.7.4]#echo "/sbin/modprobe fuse" >> /etc/rc.modules
三、Server端Oracle數(shù)據(jù)庫配置
Server端配置流程
1創(chuàng)建表空間
新建的表空間用來存儲(chǔ)dbfs中相關(guān)數(shù)據(jù)。
2創(chuàng)建用戶
新建用戶用來管理dbfs相關(guān)的文件以及源數(shù)據(jù)
3授權(quán)
管理dbfs的用戶需要擁有相關(guān)權(quán)限
4執(zhí)行dbfs初始化腳本
Dbfs配置腳本路徑:
$ORACLE_HOME/rdbms/admin/dbfs_create_filesystem_advanced
注意,需要使用新建的用戶執(zhí)行該腳本。
示例
使用dba用戶登錄
[oracle@mytest~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0Production on Thu Aug 2 13:40:42 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
開啟數(shù)據(jù)庫
SQL>startup
ORACLE instance started.
Total System Global Area 1653518336 bytes
Fixed Size 2213896 bytes
Variable Size 956303352 bytes
Database Buffers 687865856 bytes
Redo Buffers 7135232 bytes
Database mounted.
Database opened.
創(chuàng)建表空間fsts(這里使用大文件表空間)
SQL>create bigfile tablespace fsts
2 datafile '/u01/apps/oracle/oradata/david/fsts01.dbf'
3 size500m ;
Tablespace created.
創(chuàng)建用戶dexter
SQL> create user dexter identified byxiaojun default tablespace fsts quota unlimited on fsts ;
User created.
授權(quán)
SQL>grant create session,create table , create procedure , dbfs_role to dexter ;
Grant succeeded.
SQL> conn dexter/xiaojun
Connected.
執(zhí)行初始化腳本
SQL>@?/rdbms/admin/dbfs_create_filesystem_advanced fsts dir1 nocompressnodeduplicate noencrypt non-partition
四、客戶端掛載
客戶端使用需要用到dbfs_client命令,相關(guān)的程序都在Oracle client中,所以客戶端必須安裝Oracle client。
客戶端配置流程
1.使用root用戶
2. Add a new library path.
Command:
# echo "/usr/local/lib" >>/etc/ld.so.conf.d/usr_local_lib.conf
3. Change directory to lib , and create thefollowing symbolic links to the
libclntsh.so.11.1 and libnnz11.so libraries.
Command:
# cd /usr/local/lib
# ln -s $ORACLE_HOME/lib/libclntsh.so.11.1
# ln -s $ORACLE_HOME/lib/libnnz11.so
4. Locate libfuse.so, and create a symbolic linkthis library.
# locate libfuse.so
determined_path /libfuse.so
Command:
# ln –s determined_path /libfuse.so
5. Run ldconfig to create the links and cache for the new symbolic links.
Command:
# ldconfig
6. Create a symbolic link to dbfs_client in /sbin as mount.dbfs.
Command:
# ln -s $ORACLE_HOME/bin/dbfs_client/sbin/mount.dbfs
7. Login as admin user. (Oracle recommends th atyou do not perform the next step
as root user.)
8. Mount the DBFS store.
Command:
% dbfs_client @/dbfsdb -owallet,rw,user,direct_io /mnt/dbfs
9. [Optional] To test if the previo us step wassuccessful, list the dbfs directory.
Command:
# ls /mnt/dbfs
后臺(tái)執(zhí)行:
nohup dbfs_client ETLUser@DBConnectString/mnt/dbfs < passwordfile.f &
示例
[oracle@mytest~]$ mkdir /u01/dbfs
[oracle@mytest~]$ ls -l /u01
drwxr-xr-x 2 oracle oinstall 4096 Aug 2 13:51 dbfs
[root@mytest~]# echo "/usr/local/lib" >>/etc/ld.so.conf.d/usr_local_lib.conf
[root@mytest~]# cd /usr/local/lib
[root@mytestlib]# ln -s /u01/apps/oracle/product/11gr2/db_1/lib/libclntsh.so.11.1
[root@mytestlib]# ln -s /u01/apps/oracle/product/11gr2/db_1/lib/libnnz11.so
[root@mytestlib]# find / -name libfuse.so
/usr/local/lib/libfuse.so
[root@mytestlib]# ln -s /usr/local/lib/libfuse.so
[root@mytestlib]# ldconfig
[root@mytestlib]# ln -s /u01/apps/oracle/product/11gr2/db_1/bin/dbfs_client/sbin/mount.dbfs
[root@mytestlib]# su - oracle
配置密碼文件
使用oracle用戶作為dbfs掛載的管理用戶
創(chuàng)建密碼文件
echo xiaojun > passwd.t
查看客戶端的配置
[oracle@mytest~]$ vi $ORACLE_HOME/network/admin/tnsnames.ora
DAVID =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =mytest)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = david)
)
)
遠(yuǎn)程可以登錄
[oracle@mytest~]$ sqlplus dexter/xiaojun@david
SQL*Plus: Release 11.2.0.1.0Production on Thu Aug 2 14:17:32 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0- 64bit Production
With the Partitioning, OLAP, Data Mining andReal Application Testing options
SQL>
執(zhí)行掛載命令
nohup dbfs_client dexter@david /u01/dbfs < passwd.t &
[1] 11665
[oracle@mytest ~]$ nohup: appending outputto `nohup.out'
[oracle@mytest ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 30G 15G 14G 53% /
/dev/sda3 3.9G 473M 3.3G 13% /tmp
tmpfs 2.0G 943M 1.1G 48% /dev/shm
/dev/hdc 3.7G 3.7G 0 100% /mnt
dbfs 1.5M 57K 1.4M 4% /u01/dbfs
五、測(cè)試
[oracle@mytest ~]$ ll /u01
drwxr-xr-x 3 root root 0 Aug 2 14:20 dbfs
[oracle@mytest ~]$ ll /u01/dbfs/
total 0
drwxrwxrwx 3 root root 0 Aug 2 14:09 dir1
[oracle@mytest~]$ echo test > /u01/dbfs/dir1/test.t
[oracle@mytest~]$ ll /u01/dbfs/dir1/
total 1
-rw-r--r--1 oracle oinstall 5 Aug 2 14:21 test.t
[oracle@mytest ~]$ cat /u01/dbfs/dir1/test.t
Test
[oracle@mytest~]$ mkdir /u01/dbfs/dir1/sub_dir
[oracle@mytest~]$ echo ffccddssdd > /u01/dbfs/dir1/sub_dir/test2.t
[oracle@mytest~]$ sqlplus dexter/xiaojun@david
SQL*Plus: Release 11.2.0.1.0Production on Thu Aug 2 14:28:49 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0- 64bit Production
With the Partitioning, OLAP, Data Mining andReal Application Testing options
Pathtype=1表示文件 2表示目錄
[sql]view plaincopyprint?
1. SQL> select pathname , item , pathtype from t_dir1 ;
2. PATHNAME ITEM PATHTYPE
3. -------------------- ----------------------------
4. /test.t test.t 1
5. /sub_dir sub_dir 2
6. /sub_dir/test2.t test2.t 1
7. / ROOT 2
8. /.sfs .sfs 2
9. /.sfs/attributes attributes 2
10./.sfs/tools tools 2
11./.sfs/snapshots snapshots 2
12./.sfs/RECYCLE RECYCLE 2
13./.sfs/content content 2
14.
15.10 rows selected.
SQL> select pathname , item , pathtype from t_dir1 ;
PATHNAME ITEM PATHTYPE
-------------------- ----------------------------
/test.t test.t 1
/sub_dir sub_dir 2
/sub_dir/test2.t test2.t 1
/ ROOT 2
/.sfs .sfs 2
/.sfs/attributes attributes 2
/.sfs/tools tools 2
/.sfs/snapshots snapshots 2
/.sfs/RECYCLE RECYCLE 2
/.sfs/content content 2
10 rows selected.
配置完成
以上是“oracle中dbfs文件系統(tǒng)怎么用”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!