今天在Linux下經過sqlplus / as sysdba啓動數據庫時報如下錯誤:
ERROR:
ORA-09817: Write to audit file failed.
Linux-x86_64 Error: 28: No space left on device
ORA-09945: Unable to initialize the audit trail file
Linux-x86_64 Error: 28: No space left on device
通過檢查發現緣由是Linux的虛擬機根分區已經使用100%,以致於服務不能正常進行:
[oracle@etl110 ~]$ df -h
文件系統 容量 已用 可用 已用% 掛載點
/dev/mapper/VolGroup00-lvm_root
16G 15G 0 100% /
/dev/mapper/VolGroup00-lv_home
2.0G 68M 1.8G 4% /home
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 579M 0 579M 0% /dev/shm node
考慮將虛擬機磁盤空間由20G擴大到40G,基於LVM操做,如下爲操做過程:
第一步:使用VMware工具擴容分配的硬盤空間
1.vmware 提供一個命令行工具,在Windows下爲vmware-vdiskmanager.exe 位於 vmware 的安裝目錄下,好比vmware-vdiskmanager.exe;
在Linux下有直接的vmware-vdiskmanager指令;
進行的操做:在 windows 下進入命令行窗口,轉到 vmware 的安裝目錄,執行vmware-vdiskmanager.exe;在Linux下,直接
敲入vmware-vdiskmanager ,可執行該指令擴充使用的指令: vmware-vdiskmanager -x 40Gb vmdisk1.vmdk。 linux
說明:要擴容的系統這時不能在運行 ,參數 "-x" 表示要擴展虛擬機硬盤空間,緊隨其後的數字是要擴展到的大小 ,而非
增長量(本例爲擴展到40GB,這是一個磁盤總量,包含了原先的磁盤容量)。最後是指定要操做的虛擬機磁盤的具體文件,要是
路徑名中有空格,必須以雙引號括起來。按回車鍵開始執行,執行完畢,退出命令提示符窗口,重啓 VMware ,會發現虛擬機硬
盤空間已變成40GB了。 sql
2.咱們重啓虛擬機後,發現虛擬機的硬盤是變成40GB,但進入 linux 系統後,用 "df -h"查看發現硬盤空間仍是原先那麼大。
雖然已經擴大了磁盤,可是因爲尚未通過分區,指定文件系統,因此 linux 操做系統沒法識別。其實就至關於你的硬盤雖然大了,
可是你並無對其進行分區是一個道理。 數據庫
第二步:使用Linux下的fdisk工具進行分區
首先,須要以root身份登陸系統。
fdisk -l 命令打印當前的磁盤分區表:
[root@etl110 ~]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2610 20860402+ 8e Linux LVM
(1)鍵入命令:fdisk /dev/sda,sda就是通過擴容的硬盤,爲 SCSI 硬盤, IDE 類型硬盤對應爲 hda ,是對該硬盤進行操做;
(2)鍵入:m回車列出 fdisk 的幫助;
(3)鍵入:n回車用於添加新分區,此時, fdisk 會讓你選擇添加爲邏輯分區呢(編號從 5 開始)仍是主分區(編號 1 到 4 )
鍵入p選擇主分區;鍵入l選擇邏輯分區 ,此處咱們鍵入p選擇主分區,回車後此時fdisk會讓你選擇主分區的編號,若是已經有了
主分區sda1,sda2,那麼編號就選3,即要建立的該分區爲sda3,接下來fdisk 又會讓你選擇該分區的開始值就是分區的Start值以
及End值,直接回車選擇默認值便可;最後鍵入w寫入分區表,整個操做過程以下,後面帶#號的爲我加的註釋,方便理解。
[root@etl110 ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 5221.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): m #獲取命令幫助列表
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n #新建分區
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3 #建立id號爲3的分區
First cylinder (2611-5221, default 2611): #直接回車,使用默認值
Using default value 2611
Last cylinder or +size or +sizeM or +sizeK (2611-5221, default 5221): #直接回車,使用默認值
Using default value 5221
Command (m for help): t #修改系統分區的id號
Partition number (1-4): 3 #指定要修改的分區id號
Hex code (type L to list codes): 8e #指定要改爲的id號,8e表明LVM
Changed system type of partition 3 to 8e (Linux LVM)
Command (m for help): w #寫入分區表
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 設備或資源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.
[root@etl110 ~]# reboot
重啓系統後就能夠在/dev/下看到sda3了 windows
第三步:格式化該新添加的分區
鍵入命令:mkfs -t ext3 /dev/sda3,將/dev/sda3格式化爲ext3格式,操做過程以下所示:
[root@etl110 ~]# mkfs -t ext3 /dev/sda3
mke2fs 1.39 (29-May-2006)
warning: 334 blocks unused.
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2626560 inodes, 5242880 blocks
262160 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
16416 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
到此爲止,咱們就新建了一個分區/dev/sda3,此時咱們已經能夠經過掛載來使用這個新的空間;可是,由於數據庫是安裝在
根目錄上的,目前根目錄空間已經使用完畢,因此能把新建的分區使用在更目錄上,分擔根目錄的空間,才能解決問題。 oracle
第四步:基於LVM擴充根分區
[root@etl110 ~]# lvs
/dev/hdc: open failed: 找不到介質
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lv_home VolGroup00 -wi-ao 2.00G
lvm_root VolGroup00 -wi-ao 15.59G
lvm_swap VolGroup00 -wi-ao 2.28G
[root@etl110 ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
[root@etl110 ~]# vgextend VolGroup00 /dev/sda3
/dev/hdc: open failed: 找不到介質
Volume group "VolGroup00" successfully extended
[root@etl110 ~]# vgdisplay
/dev/hdc: open failed: 找不到介質
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size 39.88 GB
PE Size 32.00 MB
Total PE 1276
Alloc PE / Size 636 / 19.88 GB
Free PE / Size 640 / 20.00 GB
VG UUID J7KBM7-dcwF-3SXr-WLlL-IJIg-LuNy-3rp0jg
主要查看Free PE / Size 640 / 20.00 GB,說明咱們最多能夠有20G的擴充空間。
最後,運行如下命令給根分區增長空間:
[root@etl110 ~]# df -h
文件系統 容量 已用 可用 已用% 掛載點
/dev/mapper/VolGroup00-lvm_root
16G 15G 0 100% /
/dev/mapper/VolGroup00-lv_home
2.0G 68M 1.8G 4% /home
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 579M 0 579M 0% /dev/shm app
[root@etl110 ~]# lvextend -L +20G /dev/mapper/VolGroup00-lvm_root /dev/sda3
/dev/hdc: open failed: 找不到介質
Extending logical volume lvm_root to 35.59 GB
Logical volume lvm_root successfully resized
[root@etl110 ~]# cat /etc/fstab
/dev/VolGroup00/lvm_root / ext3 defaults 1 1
/dev/VolGroup00/lv_home /home ext3 defaults 1 2
LABEL=/boot /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
/dev/VolGroup00/lvm_swap swap swap defaults 0 0
檢查文件系統:e2fsck -f /dev/mapper/VolGroup00-lvm_root
而後,告訴系統,分割區大小有調整:resize2fs /dev/mapper/VolGroup00-lvm_root
[root@etl110 ~]# e2fsck -f /dev/mapper/VolGroup00-lvm_root
e2fsck 1.39 (29-May-2006)
/dev/mapper/VolGroup00-lvm_root is mounted.
WARNING!!! Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.
Do you really want to continue (y/n)? yes
/dev/mapper/VolGroup00-lvm_root: recovering journal
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/VolGroup00-lvm_root: ***** FILE SYSTEM WAS MODIFIED *****
/dev/mapper/VolGroup00-lvm_root: ***** REBOOT LINUX *****
/dev/mapper/VolGroup00-lvm_root: 225531/4088000 files (1.6% non-contiguous), 3897107/4087808 blocks
[root@etl110 ~]# resize2fs /dev/mapper/VolGroup00-lvm_root
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/VolGroup00-lvm_root is mounted on /; on-line resizing required
Performing an on-line resize of /dev/mapper/VolGroup00-lvm_root to 9330688 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-lvm_root is now 9330688 blocks long.
到此全部操做完畢,使用df -h來查看擴充後的空間大小:
[root@etl110 ~]# df -h
文件系統 容量 已用 可用 已用% 掛載點
/dev/mapper/VolGroup00-lvm_root
35G 15G 19G 44% /
/dev/mapper/VolGroup00-lv_home
2.0G 68M 1.8G 4% /home
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 579M 0 579M 0% /dev/shm ide