Focus On Oracle

Installing, Backup & Recovery, Performance Tuning,
Troubleshooting, Upgrading, Patching

Oracle Engineered System


当前位置: 首页 » 技术文章 » Oracle

Oracle ACFS and DBFS(一)

11g中Oracle引入了ACFS(ASM Cluster File System)和DBFS(Database File System)

ACFS是ASM集群文件系统,依赖于ASM,是通过在ASM DiskGroup上创建ASM Volumes,再将ASM Volumes分配空间,然后创建acfs文件系统,挂载到服务器上。


Oracle Automatic Storage Management Cluster File System (Oracle ACFS) is a multi-platform, scalable file system, and storage management technology that extends Oracle Automatic Storage Management (Oracle ASM) functionality to support customer files maintained outside of Oracle Database. Oracle ACFS supports many database and application files, including executables, database trace files, database alert logs, application reports, BFILEs, and configuration files. Other supported files are video, audio, text, images, engineering drawings, and other general-purpose application file data.



The Oracle ASM Dynamic Volume Manager (Oracle ADVM) provides volume management services and a standard disk device driver interface to clients. File systems and other disk-based applications send I/O requests to Oracle ADVM volume devices as they would to other storage devices on a vendor operating system.
DBFS 是数据库文件系统,是将Oracle数据库当成文件系统来使用,在内部文件已SecureFiles LOBs的形式存在数据库的表中,在操作系统上也可以查看。DBFS的推出一方面迎合了市场的需要,另外一方面11g SecureFiles LOB(compression, deduplication and encryption)新特性有直接关系。在Linux上,通过dbfs_client的接口和FUSE结合使直接访问操作系统存取文件成为现实。

Oracle Database File System (DBFS) creates a standard file system interface on top of files and directories that are stored in database tables. Oracle DBFS is similar to the Network File System (NFS) protocol in that it provides a shared network file system that looks like a local file system.It has both server and client component.

In DBFS, the database is the server where the files are stored as secure LOB's . A set of PL/SQL procedures implement the file system access primitives like open,create etc.This implementation is termed as DBFS content Repository.

DBFS client component runs on the client machine. On linux, the dbfs_client interfaces with FUSE kernel module to implement a files system mount point that provides transparent access to the files stored in database.



ACFS和DBFS的区别

ACFS
A.数据库文件和非数据库文档都可以存在ACFS上,易扩展、多平台,通过NFS也可以远程挂载
B.ACFS依赖于ASM,是ASM技术的扩展,在SIHA/Oracle Restart上创建也可以
C.ACFS是独立于数据库的,数据库在关闭的状况下也可以访问,只要ASM运行即可
更多特性,请看以下描述
Oracle ACFS dynamic file system resizing.
Maximized performance through direct access to Oracle ASM disk group storage.
Balanced distribution of Oracle ACFS across Oracle ASM disk group storage for increased I/O parallelism.
Data reliability through Oracle ASM mirroring protection mechanisms.
Oracle ASM is the preferred storage manager for all database files. It has been specifically designed and optimized to provide the best performance for database file types. For a list of file types supported by Oracle ASM.
Oracle ACFS is the preferred file manager for non-database files. It is optimized for general purpose files.
Oracle ACFS does not support any file type that can be directly stored in Oracle ASM, except where explicitly noted in the documentation. Not supported means Oracle Support Services does not take calls and development does not fix bugs associated with storing unsupported file types in Oracle ACFS.
Starting with Oracle Automatic Storage Management 11g Release 2 (11.2.0.3), Oracle ACFS supports RMAN backups (BACKUPSET file type), archive logs (ARCHIVELOG file type), and Data Pump dumpsets (DUMPSET file type). Note that Oracle ACFS snapshots are not supported with these files.
Oracle ACFS does not support files for the Oracle Grid Infrastructure home.
Oracle ACFS does not support Oracle Cluster Registry (OCR) and voting files.
Oracle ACFS functionality requires that the disk group compatibility attributes for ASM and ADVM be set to 11.2 or greater.

DBFS
A.不能存放数据库文件到DBFS上,只有非数据库文件可以存放在DBFS文件上
B.DBFS不需要ASM,这个是可选项
C.DBFS文件系统会随着数据库的备份而备份,这是由于DBFS的特性决定的
D.DBFS需要至少一个运行的数据库来存放

如何配置和使用ACFS
第一步需要检查ACFS/ADVM模块是否安装,如果没有安装通过下面的步骤可以安装。
Verify the ACFS/ADVM modules
[root@ohs1 ~]# lsmod |grep oracle
oracleacfs           1598952  0
oracleadvm            210368  0
oracleoks             265408  2 oracleacfs,oracleadvm
oracleasm              46100  1
[root@ohs1 ~]# 

安装ACFS/ADVM模块(如果已安装,请跳过这一步)
[root@ohs1 bin]# pwd
/pgold/orgrid/oracle/product/112/bin
[root@ohs1 bin]# ls acfsroot
acfsroot
[root@asmgrid bin]# ./acfsroot install
ACFS-9300: ADVM/ACFS distribution files found.
ACFS-9312: Existing ADVM/ACFS installation detected.
ACFS-9314: Removing previous ADVM/ACFS installation.
ACFS-9315: Previous ADVM/ACFS components successfully removed.
ACFS-9307: Installing requested ADVM/ACFS software.
ACFS-9308: Loading installed ADVM/ACFS drivers.
ACFS-9321: Creating udev for ADVM/ACFS.
ACFS-9323: Creating module dependencies - this may take some time.
ACFS-9327: Verifying ADVM/ACFS devices.
ACFS-9309: ADVM/ACFS installation correctness verified.

[root@asmgrid ~]# acfsload start

ACFS-9327: Verifying ADVM/ACFS devices.
ACFS-9322: completed
[oracle@ohs1 acfs]$ acfsload
ACFS-9228: usage: acfsload {start|stop} [-s]
[oracle@ohs1 acfs]$ acfsdriverstate
ACFS-9206: usage: acfsdriverstate [-orahome <ORACLE_HOME>] <installed | loaded | version | supported> [-s]
[oracle@ohs1 acfs]$ acfsdriverstate version
ACFS-9325:     Driver OS kernel version = 2.6.18-8.el5PAE(i386).
ACFS-9326:     Driver Oracle version = 110803.1.
[oracle@ohs1 acfs]$ acfsdriverstate loaded
ACFS-9203: true
[oracle@ohs1 acfs]$ acfsdriverstate supported
ACFS-9200: Supported
[oracle@ohs1 acfs]$ acfsroot
ACFS-9337: Usage: acfsroot <install|uninstall|version_check|enable|disable> [arguments]
ACFS-9386:  For more information, use acfsroot <command> -h
[oracle@ohs1 acfs]$ acfsroot version_check
[oracle@ohs1 acfs]$
以下步骤通过asmcmd命令行来完成,这些操作还可以通过sqlplus连接ASM实例来完成,也可以通过asmca来完成。

创建和查看Diskgroup

ASMCMD> mkdg '<dg name="ohsdba" redundancy="external"><dsk string="/dev/oracleasm/disks/ASMDISK9"/></dg>'
ASMCMD>
ASMCMD> lsdg ohsdba
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512   4096  1048576      2447     2397                0            2397              0             N  OHSDBA/
ASMCMD> 


创建Volume

ASMCMD> volcreate -G ohsdba -s 1G ohs1
ORA-15032: not all alterations performed
ORA-15221: ASM operation requires compatible.asm of 11.2.0.0.0 or higher (DBD ERROR: OCIStmtExecute)
ASMCMD>
ASMCMD> lsattr -l -G ohsdba
Name  Value
ASMCMD>


设置磁盘组的属性

ASMCMD> setattr -G ohsdba compatible.asm 11.2.0.0.0
ASMCMD> lsattr -l -G ohsdba
Name                     Value       
access_control.enabled   FALSE       
access_control.umask     066         
au_size                  1048576     
cell.smart_scan_capable  FALSE       
compatible.asm           11.2.0.0.0  
compatible.rdbms         10.1.0.0.0  
disk_repair_time         3.6h        
sector_size              512         
ASMCMD> setattr -G ohsdba compatible.rdbms 11.2.0.0.0


查看磁盘组的属性

ASMCMD> lsattr -l -G ohsdba
Name                     Value       
access_control.enabled   FALSE       
access_control.umask     066         
au_size                  1048576     
cell.smart_scan_capable  FALSE       
compatible.asm           11.2.0.0.0  
compatible.rdbms         11.2.0.0.0  
disk_repair_time         3.6h        
sector_size              512         
ASMCMD>


查看volume的状态

ASMCMD> volstat

DISKGROUP NUMBER / NAME:  3 / OHSDBA
---------------------------------------
  VOLUME_NAME
     READS           BYTES_READ      READ_TIME       READ_ERRS       
     WRITES          BYTES_WRITTEN   WRITE_TIME      WRITE_ERRS      
  -------------------------------------------------------------
  OHS1
     0               0               0               0               
     0               0               0               0  


查看volume的信息

ASMCMD> volinfo -G ohsdba ohs1
Diskgroup Name: OHSDBA
         Volume Name: OHS1
         Volume Device: /dev/asm/ohs1-109
         State: ENABLED
         Size (MB): 1024
         Resize Unit (MB): 32
         Redundancy: UNPROT
         Stripe Columns: 4
         Stripe Width (K): 128
         Usage:
         Mountpath:
ASMCMD> 

Resize volume ohs1到1.5G
ASMCMD> volresize -G ohsdba -s 1.5G ohs1
ASMCMD> volinfo -G ohsdba ohs1
Diskgroup Name: OHSDBA
         Volume Name: OHS1
         Volume Device: /dev/asm/ohs1-109
         State: ENABLED
         Size (MB): 1536
         Resize Unit (MB): 32
         Redundancy: UNPROT
         Stripe Columns: 4
         Stripe Width (K): 128
         Usage:
         Mountpath:
ASMCMD>
[orgrid@ohs1 ~]$ ls -l /dev/asm/ohs1-109
brwxrwx--- 1 root oinstall 252, 55809 May 10 00:23 /dev/asm/ohs1-109
[orgrid@ohs1 ~]$
[oracle@ohs1 ~]$ asmcmd volinfo -a
Diskgroup Name: OHSDBA
         Volume Name: OHS1
         Volume Device: /dev/asm/ohs1-109
         State: ENABLED
         Size (MB): 1536
         Resize Unit (MB): 32
         Redundancy: UNPROT
         Stripe Columns: 4
         Stripe Width (K): 128
         Usage: ACFS
         Mountpath: /acfs 

查看alert_+ASM1.log
SQL> /* ASMCMD */create diskgroup ohsdba external redundancy  disk  '/dev/oracleasm/disks/ASMDISK9'
NOTE: Assigning number (3,0) to disk (/dev/oracleasm/disks/ASMDISK9)
SUCCESS: /* ASMCMD */create diskgroup ohsdba external redundancy  disk  '/dev/oracleasm/disks/ASMDISK9'
NOTE: diskgroup resource ora.OHSDBA.dg is online
SQL> /* ASMCMD */ALTER DISKGROUP OHSDBA SET ATTRIBUTE 'compatible.asm' = '11.2.0.0.0'
SQL> /* ASMCMD */ALTER DISKGROUP OHSDBA SET ATTRIBUTE 'compatible.rdbms' = '11.2.0.0.0'
SQL> /* ASMCMD */alter diskgroup ohsdba add volume 'ohs1' size 1G
SQL> /* ASMCMD */alter diskgroup OHSDBA resize volume 'OHS1' size 1536m
通过日志我们可以看到,asmcmd里面的命令实际上调用的还是ASM实例的信息。


创建ACFS filesystem

/sbin/mkfs -t acfs /dev/asm/ohs1-109
[oracle@ohs1 ~]$ /sbin/mkfs -t acfs /dev/asm/ohs1-109
mkfs.acfs: version                   = 11.2.0.3.0
mkfs.acfs: on-disk version           = 39.0
mkfs.acfs: volume                    = /dev/asm/ohs1-109
mkfs.acfs: volume size               = 1610612736
mkfs.acfs: Format complete.
[oracle@ohs1 ~]$ 


注册ASM Volume (ADVM) & ACFS filesystem in the Oracle Registry

[oracle@ohs1 ~]$ /sbin/acfsutil registry -f -a /dev/asm/ohs1-109 /acfs
acfsutil registry: mount point /acfs successfully added to Oracle Registry
[oracle@ohs1 ~]$


挂载和卸载ACFS文件系统

卸载文件系统
As root, mount the ACFS filesystem on the ASM Volume (ADVM)
[root@ohs1 bin]# mount -t acfs /dev/asm/ohs1-109 /acfs
[root@ohs1 bin]# df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              7080540   3440120   3274944  52% /
/dev/sda3              5096400   3820124   1013212  80% /stage
/dev/sda2             15227040   7569660   6871400  53% /u01
tmpfs                   517580    153436    364144  30% /dev/shm
/dev/asm/ohs1-109      1572864     73964   1498900   5% /acfs
[root@ohs1 bin]#

[root@ohs1 acfs]# /sbin/mount.acfs -o all
[root@ohs1 acfs]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             6.8G  3.3G  3.2G  52% /
/dev/sda3             4.9G  3.7G  990M  80% /stage
/dev/sda2              15G  7.3G  6.6G  53% /u01
tmpfs                 506M  150M  356M  30% /dev/shm
/dev/asm/ohs1-109     1.5G   73M  1.5G   5% /acfs
[root@ohs1 acfs]# cd /acfs
[root@ohs1 acfs]# ls
lost+found


卸载文件系统

[root@ohs1 acfs]#/sbin/umount -t acfs -a
[root@ohs1 acfs]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             6.8G  3.3G  3.2G  52% /
/dev/sda3             4.9G  3.7G  990M  80% /stage
/dev/sda2              15G  7.2G  6.7G  52% /u01
tmpfs                 506M  150M  356M  30% /dev/shm


查看ACFS文件系统的信息

[oracle@ohs1 ~]$ cd /acfs/
[oracle@ohs1 acfs]$ pwd
/acfs
[oracle@ohs1 acfs]$ ls -l
total 64
drwx------ 2 root root 65536 May 10 00:43 lost+found
[oracle@ohs1 acfs]$ mount|grep asm
oracleasmfs on /dev/oracleasm type oracleasmfs (rw)
/dev/asm/ohs1-109 on /acfs type acfs (rw)
[oracle@ohs1 acfs]$ df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              7080540   3440120   3274944  52% /
/dev/sda2             15227040   7472528   6968532  52% /u01
tmpfs                   517580    153436    364144  30% /dev/shm
/dev/asm/ohs1-109      1572864     73964   1498900   5% /acfs
[oracle@ohs1 acfs]$


创建ACFS Snapshot

[root@ohs1 ~]# /sbin/acfsutil snap create acfs_snapshot /acfs
acfsutil snap create: Snapshot operation is complete.


查看ACFS文件系统信息

[root@ohs1 ~]# /sbin/acfsutil info fs /acfs
/acfs
    ACFS Version: 11.2.0.3.0
    flags:        MountPoint,Available
    mount time:   Tue May 10 00:59:03 2016
    volumes:      1
    total size:   1610612736
    total free:   1467764736
    primary volume: /dev/asm/ohs1-109
        label:                 
        flags:                 Primary,Available,ADVM
        on-disk version:       39.0
        allocation unit:       4096
        major, minor:          252, 55809
        size:                  1610612736
        free:                  1467764736
        ADVM diskgroup         OHSDBA
        ADVM resize increment: 33554432
        ADVM redundancy:       unprotected
        ADVM stripe columns:   4
        ADVM stripe width:     131072
    number of snapshots:  1
    snapshot space usage: 49152
    replication status: DISABLED
[root@ohs1 ~]#


查看ACFS快照信息

通过acfsutil查看,也可通过ASM实例查看
[root@ohs1 acfs]# /sbin/acfsutil snap info acfs_snapshot /acfs
snapshot name:               acfs_snapshot
RO snapshot or RW snapshot:  RO
snapshot creation time:      Tue May 10 01:05:25 2016

[root@ohs1 acfs]#
[root@ohs1 acfs]#
[root@ohs1 acfs]# pwd
/acfs
[root@ohs1 acfs]# ls
hosts  lost+found
[root@ohs1 acfs]# ls -a
.  ..  hosts  lost+found
[root@ohs1 acfs]# cd .ACFS
[root@ohs1 .ACFS]# ls
repl  snaps
[root@ohs1 .ACFS]# cd snaps/
[root@ohs1 snaps]# ls
acfs_snapshot
[root@ohs1 snaps]# cd acfs_snapshot/
[root@ohs1 acfs_snapshot]# ls
hosts  lost+found
[root@ohs1 acfs_snapshot]#


通过数据库查看ACFS快照信息

[oracle@ohs1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Tue May 10 01:09:24 2016
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Real Application Clusters and Automatic Storage Management options
SQL> select substr(fs_name,1,24) filesystem, substr(snap_name,1,18) snapshot, create_time time from v$asm_acfssnapshots;
FILESYSTEM               SNAPSHOT           TIME
------------------------ ------------------ ---------
/acfs                    acfs_snapshot      10-MAY-16
SQL> 


通过acfsutil resize

[oracle@ohs1 ~]$ /sbin/acfsutil size 2G /acfs
acfsutil size: new file system size: 2147483648 (2048MB)
[oracle@ohs1 ~]$ asmcmd volinfo -a
Diskgroup Name: OHSDBA
         Volume Name: OHS1
         Volume Device: /dev/asm/ohs1-109
         State: ENABLED
         Size (MB): 2048
         Resize Unit (MB): 32
         Redundancy: UNPROT
         Stripe Columns: 4
         Stripe Width (K): 128
         Usage: ACFS
         Mountpath: /acfs
[oracle@ohs1 ~]$
SQL> col fs_name for a10
SQL> col vol_device for a20
SQL> select FS_NAME, VOL_DEVICE, TOTAL_MB , FREE_MB from V$ASM_ACFSVOLUMES;
FS_NAME    VOL_DEVICE             TOTAL_MB    FREE_MB
---------- -------------------- ---------- ----------
/acfs      /dev/asm/ohs1-109          2048 1910.76953
SQL>


acfsutil帮助信息

[oracle@ohs1 ~]$ /sbin/acfsutil

Usage: acfsutil [-h] command ...   # (Version 11.2.0.3.0)
                   -h - help
    Command Subcmd    Arguments
----------- --------- ----------------------------------------------------------
       help                                    - display this message
    version                                    - display ACFS version information
       info fs                                 - Display all ACFS file systems
       info fs        [<path> ...]             - Display specific ACFS file sys
       info fs        -o <item> <path>         - Display specific file sys item:
       info fs        -o                           freespace,     totalspace,
       info fs        -o                           mountpoints,   volumes,
       info fs        -o                           available,     ismountpoint,
       info fs        -o                           isavailable,   iscorrupt,
       info fs        -o                           isadvm,        diskgroup,
       info fs        -o                           redundancy,    resizeincrement,
       info fs        -o                           stripewidth,   stripecolumns,
       info fs        -o                           primaryvolume, replication,
       info fs        -o                           isreplprimary, isreplstandby
       info fs        -s <<interval> <count>> <path> - Display ACFS file system statistics
       info file      <path> [<path> ...]      - Display specific file info
       info id        <file-identifier> <mountpoint> -
       info id              Display the pathname associated with the given  
       info id              ACFS file identifier and mountpoint.
...
...
[oracle@ohs1 ~]$ 

ACFS注意事项

RAC中可通过srvctl增加ACFS文件系统

create a new ACFS single filesystem resource using srvctl add filesystem. You must be root or asmadmin to perform this operation.  You will need to specify options:
Usage: srvctl add filesystem -d <volume_device> -v <volume_name> -g <dg_name> [-m <mountpoint_path>] [-u <user>]

On release 11.2.0.3 & onwards, “acfsroot enable” command is present & used (for early releases (11.2.0.1 & 11.2.0.2) “acfsroot reregister” command can be used instead)

ACFS is supported for Grid Infrastructure 12.1.0.2 or later on Exadata

Reference
ACFS Guie
http://docs.oracle.com/cd/E11882_01/server.112/e18951/asmfilesystem.htm#OSTMG31000

DBFS Guide
Database SecureFiles and Large Objects Developer's Guide
http://docs.oracle.com/cd/E11882_01/appdev.112/e18294/toc.htm
http://docs.oracle.com/cd/E11882_01/appdev.112/e18294/adlob_client.htm#ADLOB0006


关键词:asm 

相关文章

Oracle ASM from 10g to 18c
在18c中通过ASM Flex DiskGroup克隆PDB
Exadata and ASM
Oracle ASM Storage Limits
12c 如何将Standard ASM转化为Flex ASM
How to use amdu(ASM Metadata Dump Utility)
How to use kfed(Kernel Files metadata Editor)
How to use kfod(Kernel Files OSM Disk)
如何计算ASM磁盘头自动备份的位置
What is disk_repair_time?
Find block in ASM
12c新特性ASMFD
Top