您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關oracle12c RAC如何創建ADVM和ACFS的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
ACFS是oracle database 11gR2的一個新特性。關于ACFS的更多信息請參考官方文檔。這篇文章是基于12C RAC環境寫的,不知道在非RAC環境中,還能不能使用ACFS呢,有興趣的朋友可以測試下。以下內容是如何使用asmca、命令行以及sql語句去創建ADVM,進而創建ACFS。其中在操作系統中會用到mount、umount、acfsutil、mkfs.acfs、srvctl等幾個命令。其中的acfsutil是不屬于任何一個rpm軟件包的,只有你安裝了grid組件之后才會出現。
ADVM主要是為了使除了數據庫之外的第三方應用程序也可以使用asm存儲,這樣不限于使asm局限于自家的數據庫領域。要想使用ADVM首先必須安裝grid,已經創建好了asm磁盤,asm磁盤組。一個advm卷可以占用一個磁盤組的所有空間,也可以占用部分空間,一個advm卷的空間只能來自于一個asm磁盤組,但是一個asm磁盤組可以創建多個advm卷。每次創建的advm卷都會在/dev/asm/目錄下產生一個文件,用于創建文件系統。
1、使用asmca命令進行圖形化工具創建
(1)在創建ADVM之間,首選in需要創建ASM磁盤組,下圖是創建好的磁盤組,ACFS磁盤組用于接下來的實驗使用
(2)點擊Volumes->create,輸入卷名稱和卷大小以及選擇ASM磁盤組
(3)ADVM創建成功,發現state是未啟用的狀態
(4)在卷wjqvol1上創建ACFS文件系統,并選擇自動掛載,輸入掛載點
(5)【可忽略】點擊show command,查看創建ACFS的相關命令,便于后續可以手動的去創建ACFS
(6)點擊ok后,提示執行下面的腳本
(7)切換到root用戶,執行該腳本,然后點擊close
(8)查看ACFS文件系統在RAC的兩個節點都掛載成功
[grid@c01n01 ~]$ df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/xvda2 ext3 9.7G 2.8G 6.4G 31% /
tmpfs tmpfs 4.0G 1.3G 2.8G 31% /dev/shm
/dev/xvda1 ext3 243M 83M 147M 37% /boot
/dev/xvdc1 ext3 2.0G 38M 1.9G 2% /home
/dev/xvdd1 ext3 20G 12G 7.1G 62% /u01
/dev/asm/wjqvol1-245
acfs 2.0G 145M 1.9G 8% /wjqacfs
[grid@c01n01 ~]$
[grid@c01n01 ~]$ ssh c01n02 "df -Th"
Filesystem Type Size Used Avail Use% Mounted on
/dev/xvda2 ext3 9.7G 3.8G 5.5G 41% /
tmpfs tmpfs 4.0G 1.3G 2.8G 31% /dev/shm
/dev/xvda1 ext3 243M 83M 147M 37% /boot
/dev/xvdc1 ext3 2.0G 37M 1.9G 2% /home
/dev/xvdd1 ext3 20G 12G 7.2G 61% /u01
/dev/asm/wjqvol1-245
acfs 2.0G 145M 1.9G 8% /wjqacfs
(9)查看ACFS相關的信息
(10)查看crs資源可以發現剛才創建好的ADVM以及ACFS
(11)進入掛載點,進行讀寫測試
2、使用命令創建ADVM
(1)在grid用戶下執行asmcmd命令,創建ADVM
[grid@c01n01 ~]$ asmcmd -p
ASMCMD [+] > volinfo -G acfs wjqvol1 #該命令查看已存在卷的信息
Diskgroup Name: ACFS
Volume Name: WJQVOL1
Volume Device: /dev/asm/wjqvol1-245
State: ENABLED
Size (MB): 2048
Resize Unit (MB): 32
Redundancy: UNPROT
Stripe Columns: 4
Stripe Width (K): 128
Usage: ACFS
Mountpath: /wjqacfs
(2)通過volcreate命令創建ADVM,并通過volinfo查看卷的信息
[grid@c01n01 ~]$ asmcmd -p
ASMCMD [+] > volcreate -G acfs -s 1G wjqvol2
ASMCMD [+] > volinfo -G acfs wjqvol2
Diskgroup Name: ACFS
Volume Name: WJQVOL2
Volume Device: /dev/asm/wjqvol2-245
State: ENABLED
Size (MB): 1024
Resize Unit (MB): 32
Redundancy: UNPROT
Stripe Columns: 4
Stripe Width (K): 128
Usage:
Mountpath:
(3)可以通過volresize調整ADVM卷的大小
ASMCMD [+] > volresize -G acfs -s 1.5G wjqvol2
ASMCMD [+] > volinfo -G acfs wjqvol2
Diskgroup Name: ACFS
Volume Name: WJQVOL2
Volume Device: /dev/asm/wjqvol2-245
State: ENABLED
Size (MB): 1536
Resize Unit (MB): 32
Redundancy: UNPROT
Stripe Columns: 4
Stripe Width (K): 128
Usage:
Mountpath:
注意:調小的時候會出現下面的提示信息
ASMCMD [+] > volresize -G acfs -s 1G wjqvol2
The requested size is smaller than the current size.
Data corruption may occur.
Are you sure? [y/n]: y
ASMCMD [+] >
ASMCMD [+] > volinfo -G acfs wjqvol2
Diskgroup Name: ACFS
Volume Name: WJQVOL2
Volume Device: /dev/asm/wjqvol2-245
State: ENABLED
Size (MB): 1024
Resize Unit (MB): 32
Redundancy: UNPROT
Stripe Columns: 4
Stripe Width (K): 128
Usage:
Mountpath:
(4)通過volstat查看卷的使用相關信息
ASMCMD [+acfs] > volstat
DISKGROUP NUMBER / NAME: 3 / ACFS
---------------------------------------
VOLUME_NAME
READS BYTES_READ READ_TIME READ_ERRS
WRITES BYTES_WRITTEN WRITE_TIME WRITE_ERRS
-------------------------------------------------------------
WJQVOL1
2685 1510912 47.366 0
1407 5386240 43.44 0
WJQVOL2
0 0 0 0
0 0 0 0
WJQVOL3
0 0 0 0
0 0 0 0
3、通過SQL命令創建ADVM
(1)通過SQLplus進去,執行SQL語句
[grid@c01n01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Fri May 4 11:46:52 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options
SQL> alter diskgroup acfs add volume wjqvol3 size 1G;
alter diskgroup acfs add volume wjqvol3 size 1G
*
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-15260: permission denied on ASM disk group
注意:sqlplus下創建advm不能使用sysdba權限登錄,否則會報權限不足,需要使用sysasm權限
SQL> alter diskgroup acfs add volume wjqvol3 size 1G;
Diskgroup altered.
(2)使用sysasm權限登錄進行創建
[grid@c01n01 ~]$ sqlplus / as sysasm
SQL*Plus: Release 12.1.0.1.0 Production on Fri May 4 11:53:08 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options
SQL> alter diskgroup acfs resize volume wjqvol3 size 1.1G;
alter diskgroup acfs resize volume wjqvol3 size 1.1G
*
ERROR at line 1:
ORA-02017: integer value required
注意:通過SQL語句調整ADVM大小時,只能整數倍的調整
SQL> alter diskgroup acfs resize volume wjqvol3 size 2G;
alter diskgroup acfs resize volume wjqvol3 size 2G
*
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-15041: diskgroup "ACFS" space exhausted
注意:調整的ADVM大小操作ASM磁盤組的大小會出現如上的報錯信息
SQL> alter diskgroup acfs resize volume wjqvol3 size 2G;
Diskgroup altered.
(4)查看asm文件的相關信息
SQL> select group_number,bytes,type from v$asm_file;
GROUP_NUMBER BYTES TYPE
------------ ---------- --------------------
1 1536 ASMPARAMETERFILE
1 165974016 OCRFILE
1 7680 PASSWORD
1 62922752 DATAFILE
1 419438592 DATAFILE
1 629153792 DATAFILE
1 2147491840 DATAFILE
1 104865792 DATAFILE
1 9945088 CONTROLFILE
1 52429312 ONLINELOG
1 52429312 ONLINELOG
1 52429312 ONLINELOG
1 20979712 TEMPFILE
1 3584 PARAMETERFILE
1 7680 PASSWORD
1 954212352 DATAFILE
1 838868992 DATAFILE
1 5251072 DATAFILE
1 183508992 DATAFILE
1 18956288 CONTROLFILE
1 52429312 ONLINELOG
1 52429312 ONLINELOG
1 109060096 TEMPFILE
1 376840192 DATAFILE
1 78651392 DATAFILE
1 52429312 ONLINELOG
1 52429312 ONLINELOG
1 3584 PARAMETERFILE
2 18956288 CONTROLFILE
2 52429312 ONLINELOG
2 52429312 ONLINELOG
2 52429312 ONLINELOG
2 52429312 ONLINELOG
3 2147483648 ASMVOL
3 1073741824 ASMVOL
3 2147483648 ASMVOL
36 rows selected.
(4)查看ADVM卷的相關信息
SQL> select volume_name,size_mb,state,volume_device,mountpath from v$asm_volume;
VOLUME_NAME SIZE_MB STATE VOLUME_DEVICE MOUNTPATH
--------------- ---------- -------- ------------------------------ ----------
WJQVOL1 2048 REMOTE /dev/asm/wjqvol1-245 /wjqacfs
WJQVOL2 1024 REMOTE /dev/asm/wjqvol2-245
WJQVOL3 2048 REMOTE /dev/asm/wjqvol3-245
(5)查看ADVM卷的使用相關信息
SQL> select volume_name,reads,writes,read_errs,bytes_read,bytes_written from v$asm_volume_stat;
VOLUME_NAME READS WRITES READ_ERRS BYTES_READ BYTES_WRITTEN
--------------- ---------- ---------- ---------- ---------- -------------
WJQVOL1 0 0 0 0 0
WJQVOL2 0 0 0 0 0
WJQVOL3 0 0 0 0 0
(6)查看/dev/asm路徑下上面創建的ADVM卷文件
[root@c01n01 ~]# ll /dev/asm/
total 0
brwxrwx--- 1 root asmadmin 252, 125441 May 3 16:01 wjqvol1-245
brwxrwx--- 1 root asmadmin 252, 125442 May 4 11:45 wjqvol2-245
brwxrwx--- 1 root asmadmin 252, 125443 May 4 11:53 wjqvol3-245
上述已經實驗
(1)格式化成ext4文件系統
[root@c01n01 ~]# mkfs.ext4 /dev/asm/wjqvol2-245
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
(2)掛載
[root@c01n01 ~]# mkdir /wjqext4
[root@c01n01 ~]# mount /dev/asm/wjqvol2-245 /wjqext4
[root@c01n01 ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/xvda2 ext3 11G 3.0G 6.9G 31% /
tmpfs tmpfs 4.3G 1.3G 3.0G 31% /dev/shm
/dev/xvda1 ext3 254M 87M 154M 37% /boot
/dev/xvdc1 ext3 2.2G 39M 2.0G 2% /home
/dev/xvdd1 ext3 21G 12G 7.7G 62% /u01
192.0.2.1:/stage
nfs 11G 11G 0 100% /stage
/dev/asm/wjqvol1-245
acfs 2.2G 152M 2.0G 8% /wjqacfs
/dev/asm/wjqvol2-245
ext4 1.1G 35M 969M 4% /wjqext4
注意:ACFS不能用于linux根分區,不能用于grid的安裝目錄,不支持數據庫文件(即asm存儲的文件),使用acfs要依賴于advm卷
(1)格式化成acfs文件系統
[root@c01n01 ~]# mkfs.acfs /dev/asm/wjqvol3-245
mkfs.acfs: version = 12.1.0.1.0
mkfs.acfs: on-disk version = 39.0
mkfs.acfs: volume = /dev/asm/wjqvol3-245
mkfs.acfs: volume size = 2147483648
mkfs.acfs: Format complete.
(2)掛載,注意:這里只是臨時掛載,只能在RAC的當前節點看到,其他的節點看不到
[root@c01n01 ~]# mkdir /wjqacfs.man
[root@c01n01 ~]# mount /dev/asm/wjqvol3-245 /wjqacfs.man
mount: you must specify the filesystem type
[root@c01n01 ~]# mount -t acfs /dev/asm/wjqvol3-245 /wjqacfs.man
[root@c01n01 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/xvda2 ext3 9.7G 2.8G 6.4G 31% /
tmpfs tmpfs 4.0G 1.3G 2.8G 31% /dev/shm
/dev/xvda1 ext3 243M 83M 147M 37% /boot
/dev/xvdc1 ext3 2.0G 38M 1.9G 2% /home
/dev/xvdd1 ext3 20G 12G 7.1G 62% /u01
/dev/asm/wjqvol1-245
acfs 2.0G 145M 1.9G 8% /wjqacfs
/dev/asm/wjqvol2-245
ext4 1008M 34M 924M 4% /wjqext4
/dev/asm/wjqvol3-245
acfs 2.0G 43M 2.0G 3% /wjqacfs.man
(3)通過SQL查看掛載情況
SQL> select volume_name,size_mb,state,volume_device,mountpath from v$asm_volume;
VOLUME_NAME SIZE_MB STATE VOLUME_DEVICE MOUNTPATH
--------------- ---------- -------- -------------------- ---------------
WJQVOL1 2048 REMOTE /dev/asm/wjqvol1-245 /wjqacfs
WJQVOL2 1024 REMOTE /dev/asm/wjqvol2-245
WJQVOL3 2048 REMOTE /dev/asm/wjqvol3-245 /wjqacfs.man
(4)查看crs資源可以發現,可以看到創建ADVM卷,但是wjqvol3卷上創建的ACFS文件系統卻看不到
(5)通過asmca可以發現,在wjqvol3上創建的ACFS的state處于UNKNOWN[未掛載狀態]
(6)下面通過命令進行永久的掛載
永久掛載:
[grid@c01n01 ~]$ srvctl add filesystem -d /dev/asm/wjqvol3-245 -m /wjqacfs.man -u grid -fstype ACFS -autostart ALWAYS
PRCN-2018 : Current user grid is not a privileged user
注意:這里在grid下執行上述命令提示沒有權限,只能在root用戶下執行
[root@c01n01 ~]# /u01/app/12.1.0/grid/bin/srvctl add filesystem -d /dev/asm/wjqvol3-245 -m /wjqacfs.man -u grid -fstype ACFS -autostart ALWAYS
啟動該文件系統,然后查看是否自動掛載
[root@c01n01 ~]# /u01/app/12.1.0/grid/bin/srvctl start filesystem -d /dev/asm/wjqvol3-245
[root@c01n01 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/xvda2 ext3 9.7G 2.8G 6.4G 31% /
tmpfs tmpfs 4.0G 1.3G 2.8G 31% /dev/shm
/dev/xvda1 ext3 243M 83M 147M 37% /boot
/dev/xvdc1 ext3 2.0G 38M 1.9G 2% /home
/dev/xvdd1 ext3 20G 12G 7.1G 62% /u01
192.0.2.1:/stage
nfs 9.9G 9.7G 0 100% /stage
/dev/asm/wjqvol1-245
acfs 2.0G 145M 1.9G 8% /wjqacfs
/dev/asm/wjqvol2-245
ext4 1008M 34M 924M 4% /wjqext4
/dev/asm/wjqvol3-245
acfs 2.0G 43M 2.0G 3% /wjqacfs.man
查看crs資源發現,存在該文件系統,并且可以看到掛載的路徑
再次通過asmca查看,發現在wjqvol3上創建的ACFS的state是mount狀態
[grid@c01n01 ~]$ acfsutil version
acfsutil version: 12.1.0.1.0
[grid@c01n01 ~]$ acfsutil info fs
/wjqacfs
ACFS Version: 12.1.0.1.0
flags: MountPoint,Available
mount time: Thu May 3 16:01:14 2018
volumes: 1
total size: 2147483648
total free: 1996140544
primary volume: /dev/asm/wjqvol1-245
label:
flags: Primary,Available,ADVM
on-disk version: 39.0
allocation unit: 4096
major, minor: 252, 125441
size: 2147483648
free: 1996140544
ADVM diskgroup ACFS
ADVM resize increment: 33554432
ADVM redundancy: unprotected
ADVM stripe columns: 4
ADVM stripe width: 131072
number of snapshots: 0
snapshot space usage: 0
replication status: DISABLED
/wjqacfs.man
ACFS Version: 12.1.0.1.0
flags: MountPoint,Available
mount time: Fri May 4 12:19:50 2018
volumes: 1
total size: 2147483648
total free: 2103123968
primary volume: /dev/asm/wjqvol3-245
label:
flags: Primary,Available,ADVM
on-disk version: 39.0
allocation unit: 4096
major, minor: 252, 125443
size: 2147483648
free: 2103123968
ADVM diskgroup ACFS
ADVM resize increment: 33554432
ADVM redundancy: unprotected
ADVM stripe columns: 4
ADVM stripe width: 131072
number of snapshots: 0
snapshot space usage: 0
replication status: DISABLED
(1)創建ACFS的快照
[grid@c01n01 ~]$ acfsutil snap create wjqvol1 /wjqacfs
acfsutil snap create: Snapshot operation is complete.
(2)快照創建成功后,在ACFS的掛載路徑下會自動生成一個.ACFS的目錄,該目錄下的snaps可以查看快照
[grid@c01n01 wjqvol1]$ pwd
/wjqacfs/.ACFS/snaps/wjqvol1
[grid@c01n01 wjqvol1]$ ll
total 4
d????????? ? ? ? ? ? lost+found
-rw-r--r-- 1 grid oinstall 18 May 3 16:11 test.txt
(3)更新之前創建快照前的文件test.txt
[root@c01n01 wjqacfs]# echo "This is snapshot" >> test.txt
[root@c01n01 wjqacfs]# cat test.txt
This is acfs test
This is snapshot
(4)查看快照文件和現在文件的差異
[root@c01n01 wjqacfs]# cat .ACFS/snaps/wjqvol1/test.txt
This is acfs test
(5)刪除快照
[root@c01n01 ~]# acfsutil snap delete wjqvol1 /wjqacfs
acfsutil snap delete: Snapshot operation is complete.
[root@c01n01 ~]# acfsutil registry -d /wjqacfs.man
acfsutil registry: ACFS-03135: unable to locate mount point /wjqacfs.man in Oracle Registry
acfsutil registry: ACFS-03112: unable to remove mount point /wjqacfs.man from Oracle Registry
注意:如果出現如上的報錯,說明在crs中沒有該ACFS的資源,并沒有注冊到crs中,需要你按照永久掛載的方式進行注冊后即可進行
[root@c01n01 ~]# acfsutil registry -d /wjqacfs.man
acfsutil registry: successfully removed ACFS mount point /wjqacfs.man from Oracle Registry
3、查看掛載情況以及crs資源是否存在該ACFS信息
[root@c01n01 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/xvda2 ext3 9.7G 2.8G 6.4G 31% /
tmpfs tmpfs 4.0G 1.3G 2.8G 31% /dev/shm
/dev/xvda1 ext3 243M 83M 147M 37% /boot
/dev/xvdc1 ext3 2.0G 38M 1.9G 2% /home
/dev/xvdd1 ext3 20G 12G 7.1G 62% /u01
192.0.2.1:/stage
nfs 9.9G 9.7G 0 100% /stage
/dev/asm/wjqvol1-245
acfs 2.0G 145M 1.9G 8% /wjqacfs
/dev/asm/wjqvol2-245
ext4 1008M 34M 924M 4% /wjqext4
[root@c01n01 ~]# ll /dev/asm/
total 0
brwxrwx--- 1 root asmadmin 252, 125441 May 3 16:01 wjqvol1-245
brwxrwx--- 1 root asmadmin 252, 125442 May 4 12:15 wjqvol2-245
brwxrwx--- 1 root asmadmin 252, 125443 May 4 13:41 wjqvol3-245
[grid@c01n01 ~]$ asmcmd -p
ASMCMD [+] > voldisable -G acfs wjqvol3#首先disbaleADVM卷,然后在刪除
ASMCMD [+] > volinfo -G acfs wjqvol3
Diskgroup Name: ACFS
Volume Name: WJQVOL3
Volume Device: /dev/asm/wjqvol3-245
State: DISABLED
Size (MB): 2048
Resize Unit (MB): 32
Redundancy: UNPROT
Stripe Columns: 4
Stripe Width (K): 128
Usage:
Mountpath:
ASMCMD [+] > voldelete -G acfs wjqvol3 #刪除ADVM卷
確認卷已經完全的刪除
ASMCMD [+] > volstat
DISKGROUP NUMBER / NAME: 3 / ACFS
---------------------------------------
VOLUME_NAME
READS BYTES_READ READ_TIME READ_ERRS
WRITES BYTES_WRITTEN WRITE_TIME WRITE_ERRS
-------------------------------------------------------------
WJQVOL1
3049 5919744 53.171 0
1551 5567488 46.828 0
WJQVOL2
93 377856 .254 0
12397 50778112 4330.134 0
[root@c01n01 ~]# ll /dev/asm/
total 0
brwxrwx--- 1 root asmadmin 252, 125441 May 3 16:01 wjqvol1-245
brwxrwx--- 1 root asmadmin 252, 125442 May 4 12:15 wjqvol2-245
感謝各位的閱讀!關于“oracle12c RAC如何創建ADVM和ACFS”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。