背景
oracle空間不足,發現dbf文件未按設計的路徑存放,linux磁盤掛載空間未利用,需要移動一下位置錯誤的dbf文件。
檢查文件系統
/home/oracle />df -h文件系統 容量 已用 可用 已用% 掛載點/dev/mapper/lv01-root 22G 4.5G 16G 23% /devtmpfs 3.8G 0 3.8G 0% /devtmpfs 3.9G 96K 3.9G 1% /dev/shmtmpfs 3.9G 153M 3.7G 4% /runtmpfs 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% /oradatatmpfs 781M 16K 781M 1% /run/user/42tmpfs 781M 0 781M 0% /run/user/1001tmpfs 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 sysdbaSQL*Plus: Release 12.1.0.2.0 Production onWed May 20 14:18:36 2020Copyright (c) 1982, 2014, Oracle. All rights reserved.ERROR:ORA-09817: Write to audit file failed.Linux-x86_64 Error: 28: No space left on deviceAdditional information: 12ORA-09945: Unable to initialize the audit trail fileLinux-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% /devtmpfs 3.9G 96K 3.9G 1% /dev/shmtmpfs 3.9G 153M 3.7G 4% /runtmpfs 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% /oradatatmpfs 781M 16K 781M 1% /run/user/42tmpfs 781M 0 781M 0% /run/user/1001tmpfs 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 sysdbaSQL/*Plus: Release 12.1.0.2.0 Production on Wed May 20 14:14:30 2020Copyright (c) 1982, 2014, Oracle. All rights reserved.Connected to:Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit ProductionWith the Partitioning, OLAP, Advanced Analytics and Real Application TestingoptionsSQL/> shutdown immediateDatabase 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 sysdbaSQL/*Plus: Release 12.1.0.2.0 Production on Wed May 20 14:33:30 2020Copyright (c) 1982, 2014, Oracle. All rights reserved.Connected to an idle instance.SQL/> startup mount;ORACLE instance started.Total System Global Area 2466250752 bytesFixed Size 2927384 bytesVariable Size 671089896 bytesDatabase Buffers 1778384896 bytesRedo Buffers 13848576 bytesDatabase mounted.SQL/> alter database rename file '/home/oracle/oradata/ora12c/upbs_data.dbf' to'/oradata/orcl/appdata/upbs_data.dbf';Database altered.
重啟數據庫服務
SQL/> shutdown immediateORA-01109: database not openDatabase dismounted.ORACLE instance shut down.SQL/> startupORACLE instance started.Total System Global Area 2466250752 bytesFixed Size 2927384 bytesVariable Size 671089896 bytesDatabase Buffers 1778384896 bytesRedo Buffers 13848576 bytesDatabase mounted.Database opened.SQL/>
plsql重新連接數據庫成功,刪除原來的dbf文件釋放空間
總結
到此這篇關于Oracle dbf文件移動的文章就介紹到這了,更多相關Oracle dbf文件移動內容請搜索武林網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持武林網!
新聞熱點
疑難解答