Articles Comments

Oracle DBA & All IT » Database, DBA, DBA, Oracle, Unix, รวม Script ต่างๆ » มหากาพย์ export/import ตอนที่ 1 Compress and Split File

มหากาพย์ export/import ตอนที่ 1 Compress and Split File

มหากาพย์  export/import ตอนที่ 1 Compress and Split File

หายไปนานมาก….กกกก เลยอยากจะมาเสนอวิธีการ export/import แบบต่างๆ ไว้เป็นแนวทางให้เพื่อนๆไปทำกัน สำหรับ datapump โปรดติดตามตอนต่อไปหลังจากเสร็จสิ้นมหากาพย์นี้ หุหุ

วันนี้กลับมาแนะนำวิธีการ export dmp file แบบ compress and split file เพื่อการประหยัดพื้นที่บน storage 

ตัวอย่างการ export
nohup echo|exp file=>(compress|split -b 1024m – /data01/exp_data-) log=/data01/exp_data.log owner=scott indexes=y constraints=y userid=system/password@db1

สังเกตุจาก command สีแดงคือที่แตกต่างจากที่เรา exp ทั่วไป มีการใส่ parameter ดังนี้
– compress คือการบีบขนาดของไฟล์ให้เล็กลง
– split คือการแบ่งเป็นไฟล์ๆ ตามไซด์ที่เรากำหนดใน parameter ตัวถัดไป
– 1024m คือ size ที่เราจะให้แบ่งขนาดแต่ละไฟล์

หน้าตาของ file ที่เราจะได้ออกมา aa-ag คือจะไล่ไปเรื่อยๆจนกว่าจะครบโดยการแบ่งไฟล์ละ 1024m 

1073741824 Feb 18 12:02 exp_data-aa
1073741824 Feb 18 12:14 exp_data-ab
1073741824 Feb 18 12:26 exp_data-ac
1073741824 Feb 18 12:38 exp_data-ad
1073741824 Feb 18 12:52 exp_data-ae
1073741824 Feb 18 13:06 exp_data-af
241002239  Feb 18 13:09 exp_data-ag
845        Feb 18 13:09 exp_data.log

ตัวอย่างการ import file ที่เราทำการ compress and split ไว้

echo|imp file=<(cat /data01/exp_data-* |zcat ) fromuser=scott touser=scott  log=imp_data.log indexes=y constraints=y ignore=y commit=y buffer=5000000 userid=system/password@db2

หมายเหตุ: สำหรับใช้รันบน solaris

.. Preview : 3128

Written by

บอกเล่าสิ่งที่พบเจอมาในการทำงาน ประสบการณ์การทำงานด้าน DBA ถ่ายทอดกันด้วยภาษาง่ายๆ บ้านๆ " ทุกอย่างไม่อยาก แต่... แค่ตั้งใจไม่พอ ต้องลงมือทำ และทำ GoodLuck " Fanpage: www.facebook.com/DBAor .. "Oracle Database Consultant " ..

Filed under: Database, DBA, DBA, Oracle, Unix, รวม Script ต่างๆ · Tags: , , , , , , ,