Copyright Notice: This article can be reproduced, please be sure to indicate the original source and author information in hyperlink when reprint. Original Source: http://www.aiview.com/notes/db2_using_raw.htm Author: Zhang Yang Alex_doesAThotmail.com Last updated: 2004-7-14
table of Contents
General Information Planning Disk Partition Create RAW Device Creating Database Planning Logs and Backup File Storage Additional Information Reference Resources
General information
The commands and codes in this article are compiled in the following environment:
IBM Xseriers 345 (Inter 32 Bit) Redhat Enterprise Linux 3.0 DB2 V8.1 for Linux host Connect an IBM EMP300 disk cabinet for database data storage. A total of 6 disks in a disk cabinet, a single block 146GB, 5 of which is made into RAID5, and one of the remaining options.
In RAID5, the verification information is not occupied separately, but is distributed on each disk according to the algorithm, so that the bottleneck generated by the read and write check information is avoided. Assuming a DB2 service has been installed on the host, an instance is created, named DB2, has not established a database, and the disk cabinet has been installed under the system, and the device we have obtained is SDB, not partition . Steps to establish a RAW device on disk arrays and perform data planning and data placing steps on disk arrays:
Planning disk partition
Sign in with root, partition the disk array, type in the root prompt:
#Fdisk / dev / sdb
Add 3 primary partitions SDB1, SDB2, SDB3, each partition 20GB, divided into system catalog table space, default system temporary table space, and new 32KB temporary table space, the remaining space is about 527GB all divided into the first 4 extension partitions SDB4, add 5 logical partitions SDB5, SDB6, SDB7, SDB8, SDB9, and the first two logical partitions each 160GB, and the third logical partition is 20GB, and the third logical partition is 20GB. Used as a user table space specifically placed, the remaining two logical partitions are 80GB, 93GB, respectively, and the two logical partitions are formatted using EXT3 for storage logs and database backups. Note: SDB1-SDB7 has not formatted, ready to serve as a RAW device, managed by DB2. The following is a disk status of the district:
Disk / dev / sdb: 587.2 GB, 587257085952 BYtes 254 Heads, 63 Sectors / Track, 71677 Cylinders Units = Cylinders of 16002 * 512 = 8193024 BYtes
Device Boot Start End Blocks Id System / dev / sdb1 1 2501 20010469 83 Linux / dev / sdb2 2502 5002 20010501 83 Linux / dev / sdb3 5003 7503 20010501 83 Linux / dev / sdb4 7504 71677 513456174 5 Extended / dev / sdb5 7504 27502 160011967 83 Linux / DEV / SDB6 27503 47501 160011967 83 Linux / dev / sdb7 47502 50002 20010469 83 Linux / DEV / SDB8 50003 60002 80009968 83 Linux / DEV / SDB9 60003 71677 93411643 83 Linux
Create a RAW device
Typically use the various logical partitions DB2 of the RAW device that cannot be used directly, you need to create a RAW device name using the RAW command: Type: # RAW -A
Query the currently established RAW device name, currently empty, we can use from the first device name, type in the root prompt:
# RAW / DEV / RAW / RAW1 / DEV / SDB1 # for System Catalog TableSpace (4K) # RAW / DEV / RAW / RAW2 / DEV / SDB2 # for System Temp TableSpace (4K) # RAW / DEV / RAW / RAW3 / dev / sdb3 # for System Temp TableSpace (32K) # RAW / DEV / RAW / RAW5 / DEV / SDB5 # for user tablespace1 (32k), storage table # RAW / DEV / RAW / RAW6 / DEV / SDB6 # User TableSpace1 (32K), Storage Table # RAW / DEV / RAW / RAW7 / DEV / SDB7 # for user tablespace2 (32k), storage index
At this point, we created 6 RAW device names, used to hand over DB2 direct management, check the situation of the RAW device name that has been created:
# Raw -a
/ dev / raw / Raw1: Bound to Major 8, Minor 17 / Dev / Raw / Raw2: Bound To Major 8, Minor 18 / DEV / RAW / RAW3: Bound To Major 8, Minor 19 / dev / Raw / Raw5: Bound To Major 8, Minor 21 / Dev / Raw / Raw6: Bound To Major 8, Minor 22 / DEV / RAW / RAW7: Bound To Major 8, Minor 23
If you want to delete a RAW device name (for example / dev / raw / RAW1), type in the root prompt:
# RAW / DEV / RAW / RAW1 0 0
Then modify the initialization file of the system, add the following to the /etc/rc.d/sysinit file:
RAW / DEV / RAW / RAW1 / DEV / SDB1 RAW / DEV / RAW / RAW2 / DEV / SDB2 RAW / DEV / RAW / RAW3 / DEV / SDB3 RAW / DEV / RAW / RAW5 / DEV / SDB5 RAW / DEV / RAW / RAW6 / DEV / SDB6 RAW / DEV / RAW / RAW7 / DEV / SDB7
This will re-establish the required RAW device name when the system is started next time. The default RAW device owner is DISK, you must let the owner of the database instance have access rights for this device, type in the root prompt:
# Chown DB2: Disk / dev / raw / RAW [1, 2, 3, 4, 5, 6, 7]
Change DB2 users to 7 naked devices, to this, these bare devices can already be referenced for DB2.
Create a database
The following is ready to use the above RAW device to create a database named NewDB, including the page size for 4KB system catalog table space, system temporary table space, and user table space; then new page size is 8KB, 16KB, 32KB buffer pool each Delete 4KB user tablespace, create a user table space for 2 32KBs of Size for user tables; create a 32KB page size user table space for storage index; new 32KB page Size system temporary table Space; we will complete the script of the above features to newDb.sql, and do this script in the following: Type the following command under the root prompt, go to DB2 users:
# Su - db2
Execute the above script:
$ db2 -td ";" -f newdb.sql
The database creation is completed. Download script code
Planning logs and backup file storage
Next, it is also necessary to plan a log and database backup, first format the partition used to log and database backup (this process takes a long time): Type at the root prompt:
# Mkfs.ext3 / dev / sdb8 # mkfs.ext3 / dev / sdb9
Create a directory of a DB2 database:
# MKDIR / DB2 # Chown DB2: DB2 / DB2 # SU - DB2
$ MKDIR / DB2 / DB2LOG $ MKDIR / DB2 / DB2BACKUP $ EXIT
Mount logical partitions to directory:
# Mount / dev / sdb8 / db2 / db2log # MOUNT / DEV / SDB9 / DB2 / DB2BACKUP
Update the log file path of the database:
# SU - DB2 $ DB2 Connect To NewDB $ DB2 UPDATE DB CFG Using NewLogPath '/ DB2 / DB2LOG'
The pause database makes the modification take effect. Use the Defer parameter to continue executing existing transactions, reject new connections, and post a command to activate the database after stopping success:
$ db2 quiesce DB Defer $ db2 unquiesce db $ exit
To this end, we have completed tasks that use the RAW device for data planning and data.
extra information
When the container has been created on the RAW device, if the database where the table space is not deleted through normal steps, the tablespace where the container or the container is not removed, and the DB2 will be reported again: The Container IS Already in Use this at this time should be used to release the Container flag using the DB2UNTAG command, and the operation of partitioning or formatting the disk is not imposing. Release the Container logo established on the RAW device RAW1:
# Su - db2 $ db2untag / dev / raw / raw1
Reference resource
Download scripts used to create a database