Thứ Sáu, 19 tháng 2, 2021

Xử lý khi u01, u02 chứa datafile đầy 99% - 100%

Tình huống: Khi u01, u02 đầy 99,100% nguy cơ treo, dừng database, ứn dụng
Cấp cứu các datafile đang AUTOEXTEND ON thì cần OFF GẤP theo script sau:

select 'alter database datafile ' || file_id || ' autoextend off;' from dba_data_files where file_name like '/u01%' or file_name like '/u02%';

Chạy câu lệnh vừa sinh ra:

alter database datafile 1 autoextend off;
alter database datafile 2 autoextend off;
alter database datafile 3 autoextend off;
alter database datafile 4 autoextend off;
alter database datafile 5 autoextend off;
alter database datafile 6 autoextend off;
alter database datafile 8 autoextend off;
alter database datafile 9 autoextend off;
alter database datafile 10 autoextend off;
alter database datafile 11 autoextend off;
alter database datafile 12 autoextend off;
alter database datafile 13 autoextend off;

Tiếp theo là chuyển dữ liệu sang phân vùng khác theo link: https://www.tranvanbinh.vn/2018/09/chuyen-datafile-cua-tablespace-data.html, chi tiết bên dưới

File System_Quy trình chuyển datafile của tablespace DATA, INDX sang phân vùng mới bằng cách copy datafile

Muc đích
- Chuyển đổi tablespace từ phân vùng /u01 sang phân vùng u02 hoặc sang phân vùng tốc độc thâp như  SATA bằng cách copy datafile
- Ứng cứu phân vùng /u01 đầy 99, 100% cần chuyển 1 số datafile để tránh đầy sang phân vùng /u02

0.Kiểm tra dung lượng tablespace: 100MB
select round(sum(bytes)/1024/1024, 2) from dba_data_files where tablespace_name like 'DATA2018%' order by file_name desc;

select * from dba_data_files where tablespace_name like 'DATA2018%' order by file_name desc;

1.Read only, Offline tablespace
-- Chuyen tablespace ve che do read only
--alter tablespace DATA2018 read only;
Select 'alter tablespace ' || tablespace_name || ' read only;' from dba_tablespaces where tablespace_name like 'DATA2018';

2.Copy data file sang phân vùng mới
--cp  /u01/app/oracle/oradata/orcl/data2018_001.dbf /u02/app/oracle/oradata/orcl/data2018_001.dbf
select 'cp  ' || file_name || ' /u02' || substr(file_name,5,50) ||';' from dba_data_files  where tablespace_name like 'DATA2018' order by file_name desc;

oracle@$ more cp_df_u02.sh
date;
cp  /u01/app/oracle/oradata/orcl/data2018_001.dbf /u02/app/oracle/oradata/orcl/data2018_001.dbf;
date;

3.Offline tablespace (option)
--alter tablespace DATA2018 offline;
Select 'alter tablespace ' || tablespace_name || ' offline;' from dba_tablespaces where tablespace_name like 'DATA2018';

4.Lấy d/s cac data file cần xóa, chạy cuối cùng
--mv /u01/app/oracle/oradata/orcl/data2018_001.dbf /u01/app/oracle/oradata/orcl/data2018_001.dbf.xxx ;
select 'mv ' || file_name ||  ' ' ||file_name ||'.xxx ;' from dba_data_files where tablespace_name='DATA2018'

5.Rename data files sang  đường dẫn mới
--alter tablespace DATA2018 rename datafile '/u01/app/oracle/oradata/orcl/data2018_001.dbf' to '/u02/app/oracle/oradata/orcl/data2018_001.dbf';
select 'alter tablespace ' || tablespace_name|| ' rename datafile ''' || file_name || ''' to ' ||   '''/u02' || substr(file_name,5,50) ||''';' from dba_data_files
where tablespace_name like 'DATA2018%' order by file_name desc;

6.Online, read only tablespace
--alter tablespace DATA2018 online;
Select 'alter tablespace ' || tablespace_name || ' online;' from dba_tablespaces where tablespace_name like 'DATA2018%';

7.Check 1 partition bất kỳ
--Kiểm tra danh sách file và check point time (cùng thời điểm)
--/u02/app/oracle/oradata/orcl/data2018_001.dbf    6    DATA2018    AVAILABLE    6    ONLINE    1049587    READ ONLY    1065492    1065492    06/09/2018 2:00:42 PM
select a.file_name, a.file_id, a.tablespace_name,a.status,a.relative_fno,a.online_status,
b."CREATION_CHANGE#",b.enabled,b."CHECKPOINT_CHANGE#",b."LAST_CHANGE#",b.checkpoint_time
from dba_data_files a,v$datafile b
where a.file_id=b.file#
and a.tablespace_name in ('DATA2018')
order by tablespace_name,file_name;

Select  file_name, tablespace_name from dba_data_files where tablespace_name like 'DATA2018%' order by file_name desc;

select * from dba_segments where tablespace_name like 'DATA2018%' order by segment_type;

-- select du lieu tại 1 partition bất kỳ
Select * from TP1 partition(DATA20180819);

8. Xóa datafile ở đường dẫn cũ
--(Thực hiện theo bước 4)
mv /u01/app/oracle/oradata/orcl/data2018_001.dbf /u01/app/oracle/oradata/orcl/data2018_001.dbf.xxx ;

9.Read write TBS
alter tablespace DATA2018 read write;

=============================
* KHOÁ HỌC ORACLE DATABASE A-Z ENTERPRISE trực tiếp từ tôi giúp bạn bước đầu trở thành những chuyên gia DBA, đủ kinh nghiệm đi thi chứng chỉ OA/OCP, đặc biệt là rất nhiều kinh nghiệm, bí kíp thực chiến trên các hệ thống Core tại VN chỉ sau 1 khoá học.
* CÁCH ĐĂNG KÝ: Gõ (.) hoặc để lại số điện thoại hoặc inbox https://m.me/tranvanbinh.vn hoặc Hotline/Zalo 090.29.12.888
* Chi tiết tham khảo:
https://bit.ly/oaz_w
hoặc
https://bit.ly/oaz_fp
=============================
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile: 0902912888
⚡️ Skype: tranbinh48ca
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: http://bit.ly/ytb_binhoraclemaster
👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhoracle
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội

=============================
học oracle database
Các tìm kiếm liên quan đến học oracle
database
Tự học Oracle
Tài liệu Oracle 12c tiếng Việt
Hướng dẫn sử dụng Oracle Database
Oracle SQL cơ bản
Oracle SQL là gì
Khóa học Oracle Hà Nội
Học chứng chỉ Oracle ở đầu
Khóa học Oracle online
khóa học pl/sql
học dba
học dba ở việt nam
khóa học dba
khóa học dba sql
tài liệu học dba oracle
Khóa học Oracle online
học oracle sql
học oracle ở đâu tphcm
học oracle bắt đầu từ đâu
học oracle ở hà nội
oracle database tutorial
oracle database 12c
oracle database là gì
oracle database 11g
oracle download
oracle database 19c
oracle dba tutorial
oracle tunning
sql tunning
oracle 12c
oracle dataguard
oracle goldengate
oracle weblogic
oracle exadata
hoc solaris
hoc linux
hoc aix

ĐỌC NHIỀU

Trần Văn Bình - Oracle Database Master