背景
oracle空間不足,發現dbf文件未按設計的路徑存放,linux磁盤掛載空間未利用,需要移動一下位置錯誤的dbf文件。
檢查文件系統
/home/oracle \&;df -h
文件系統 容量 已用 可用 已用% 掛載點
/dev/mapper/lv01-root 22G 4.5G 16G 23% /
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.9G 96K 3.9G 1% /dev/shm
tmpfs 3.9G 153M 3.7G 4% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 190M 132M 44M 75% /boot
/dev/mapper/lv02-home 20G 19G 0 100% /home
/dev/mapper/oradatalv-oradata 30G 18G 9.8G 65% /oradata
tmpfs 781M 16K 781M 1% /run/user/42
tmpfs 781M 0 781M 0% /run/user/1001
tmpfs 781M 0 781M 0% /run/user/0
home掛載點下空間已達到100%。
檢查大文件
/home/oracle/oradata/ora12c \&;ls -lh
總用量 8.7G
\-rw-r-----. 1 oracle oinstall 6.7G 5月 20 13:54 upbs_data.dbf
\-rw-r-----. 1 oracle oinstall 2.0G 5月 20 05:06 upbs_index.dbf
發現是dbf文件過大后,準備移動一下。應該存放數據庫文件的oradata掛載點下還有剩余空間可以存放dbf文件。
/home/oracle/oradata/ora12c >sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on
Wed May 20 14:18:36 2020
Copyright (c) 1982, 2014, Oracle. All rights reserved.
ERROR:
ORA-09817: Write to audit file failed.
Linux-x86_64 Error: 28: No space left on device
Additional information: 12
ORA-09945: Unable to initialize the audit trail file
Linux-x86_64 Error: 28: No space left on device
oracle sqlplus直接登錄失敗,顯示空間不足。
刪除審計文件日志
/home/oracle/audit \&;rm \*
/home/oracle/audit \&;ll
總用量 0
刪除后查看磁盤空間,發現剛刪的審計文件有點少
/home/oracle/audit \&;df -h
文件系統 容量 已用 可用 已用% 掛載點
/dev/mapper/lv01-root 22G 4.5G 16G 23% /
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.9G 96K 3.9G 1% /dev/shm
tmpfs 3.9G 153M 3.7G 4% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 190M 132M 44M 75% /boot
/dev/mapper/lv02-home 20G 19G 60K 100% /home
/dev/mapper/oradatalv-oradata 30G 18G 9.8G 65% /oradata
tmpfs 781M 16K 781M 1% /run/user/42
tmpfs 781M 0 781M 0% /run/user/1001
tmpfs 781M 0 781M 0% /run/user/0
刪除后有60k空間剩余,開始沒發現aud文件路徑有問題, 不是正常的aud路徑。
重新查找清理審計日志釋放空間
/home/oracle/app/oracle/admin/orcl \&;find ./ -name \*aud
查詢出結果后清除前30天的
/home/oracle/app/oracle/admin/orcl \&;find ./ -name \*aud -mtime +30 \|xargs rm
-f
關閉數據庫
/home/oracle/audit \&;sqlplus / as sysdba
SQL\*Plus: Release 12.1.0.2.0 Production on Wed May 20 14:14:30 2020
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing
options
SQL\&; shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
復制dbf文件
/home/oracle/oradata/ora12c \&;cp upbs_data.dbf
/oradata/orcl/appdata/upbs_data.dbf
登錄數據庫修改dbf文件路徑
home/oracle/app/oracle/admin/orcl \&;sqlplus / as sysdba
SQL\*Plus: Release 12.1.0.2.0 Production on Wed May 20 14:33:30 2020
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to an idle instance.
SQL\&; startup mount;
ORACLE instance started.
Total System Global Area 2466250752 bytes
Fixed Size 2927384 bytes
Variable Size 671089896 bytes
Database Buffers 1778384896 bytes
Redo Buffers 13848576 bytes
Database mounted.
SQL\&; alter database rename file '/home/oracle/oradata/ora12c/upbs_data.dbf' to
'/oradata/orcl/appdata/upbs_data.dbf';
Database altered.
重啟數據庫服務
SQL\&; shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL\&; startup
ORACLE instance started.
Total System Global Area 2466250752 bytes
Fixed Size 2927384 bytes
Variable Size 671089896 bytes
Database Buffers 1778384896 bytes
Redo Buffers 13848576 bytes
Database mounted.
Database opened.
SQL\&;
plsql重新連接數據庫成功,刪除原來的dbf文件釋放空間
總結
到此這篇關于Oracle dbf文件移動的文章就介紹到這了,更多相關Oracle dbf文件移動內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:- Oracle表空間數據文件移動的方法
- 在ORACLE移動數據庫文件
- 在ORACLE移動數據庫文件