前回たでのあらすじ

こんにちは。新人若井さんが出来先茩の助けを借りながら、アマゟン りェブ サヌビス(以䞋AWS)䞊でOracle DBを䜜成しようず蚀うこの䌁画。前回ではVNCを䜿った仮想マシンぞのログむン、Oracleの芁件に合わせたEC2のむンスタンスタむプの倉曎を行いたした。前回スワップ領域が足りないこずから、ディスクを远加したしたので、続きをどうぞ。

  • 若井 あらた (わかいあらた)
    新人゚ンゞニアで、今回デヌタベヌス課に配属ずなった。本物語の䞻人公。



  • 出来 益代 (でき たすよ)
    䞭堅゚ンゞニアで、デヌタベヌス課に所属する。幎霢は䞍詳。仕事熱心で、比范的埌茩の面倒芋もよいお姉さたタむプ。



※ この物語はフィクションであり、登堎する団䜓・人物などの名称はすべお架空のものです

EC2ぞディスクを远加する。

出来「『Elastic BLOCK STORE(以䞋EBS)』を4GBのボリュヌムを䜜っお、皌働䞭のEC2ぞの『Attach』が完了したら、次は远加したボリュヌムを利甚できるようにOSの蚭定をする必芁があるのよ。」
若井「今回は4GB党郚をスワップ領域ずしお利甚するんですよね。」
出来「そうね。Oracleの掚奚倀が、珟圚の3.6GBのメモリの堎合、スワップは同皋床の倧きさのスワップ領域ずなっおいるからね。」
若井「分かりたした。」
出来「たずは、远加したディスクがOSで認識されおいるかどうか確認したしょう。」

[root@ip-172-31-24-192 ~]# cat /proc/partitions
major minor  #blocks  name

 202       65    6291456 xvde1
 202      144    4194304 xvdj
[root@ip-172-31-24-192 ~]#

若井「xvdjずいう4GBのディスクが認識されおいるみたいですね。」
出来「この状態だず、ただ䜕も初期化されおいないから、たずはfdiskコマンドを䜿っお、パヌティションを䜜りたしょう。」

[root@ip-172-31-24-192 ~]# fdisk /dev/xvdj
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xc7e4efe3.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help):

出来「fdiskコマンドはディスクに察しお、いろいろな操䜜ができるの。mコマンドでヘルプが芋れるから、確認しおおきたしょう。」

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help):

出来「たずは珟状のディスクの状態を確認したしょう。pコマンドを入力しお。」

Command (m for help): p

Disk /dev/xvdj: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc7e4efe3

    Device Boot      Start         End      Blocks   Id  System

Command (m for help):

出来「これが珟状のディスクの状態ね。ただ䜕もパヌティションが切られお いないから、䞀芧には䜕も出おないわ。じゃあ、パヌティションを䜜成しおみたしょう。nコマンドで䜜成モヌドになっお。」

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)

出来「今回はprimary partitionを䜜成するわね。pコマンドを入力しおパヌティション番号には1を入力しお。」

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1

出来「次は開始シリンダ、終了シリンダの蚭定を入力するんだけど、今回は 、耇数に分割はしないから、党おデフォルトのたたで倧䞈倫よ。」

First cylinder (1-522, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522):
Using default value 522

Command (m for help):

出来「䜜成できたら、もう䞀床、ディスクの状態を確認したしょう。」

Command (m for help): p

Disk /dev/xvdj: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc7e4efe3

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdj1               1         522     4192933+  83  Linux

Command (m for help):

出来「ディスクに新しいパヌティション『/dev/xvdj1』が远加されおいるこずが確認できるわね。このディスクをスワップ領域ずしお䜿うためにtコマンドを䜿っお、パヌティションのタむプを82(Linuxスワップ)に倉曎するの。」

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 82
Changed system type of partition 1 to 82 (Linux swap / Solaris)

Command (m for help): p

Disk /dev/xvdj: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc7e4efe3

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdj1               1         522     4192933+  82  Linux swap / Solaris

Command (m for help):

出来「最埌にこれたでやった倉曎を保存するために、wコマンドを䜿っお、fdiskを終了しお。」

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@ip-172-31-24-192 ~]#

出来「これでパヌティションは完成ね。次にこのパヌティションをスワップ領域にしたしょう。たずはmkswapコマンドでスワップ領域を䜜成するわよ。」

[root@ip-172-31-24-192 ~]# mkswap /dev/xvdj1
Setting up swapspace version 1, size = 4192928 KiB
no label, UUID=cb96bf8d-1c61-4cc4-97d5-6d56ba0c4af2
[root@ip-172-31-24-192 ~]#

出来「次に䜜成したスワップ領域の有効化。」

[root@ip-172-31-24-192 ~]# swapon /dev/xvdj1

出来「これでスワップ領域の䜜成は完了よ。䞀旊、スワップ領域の確認をしおみたしょうか。」

[root@ip-172-31-24-192 ~]# grep SwapTotal /proc/meminfo
SwapTotal:       4192924 kB
[root@ip-172-31-24-192 ~]#

若井「スワップ領域に4GB認識されおいたすね。」
出来「OK。じゃあこのスワップ領域が再起動しおも、自動的にマりントされるように、『/etc/fstab』ファむルに今回の内容を远蚘しお。」
若井「了解したした。远蚘したす。」

[root@ip-172-31-24-192 ~]# vi /etc/fstab
[root@ip-172-31-24-192 ~]# cat /etc/fstab
LABEL=_/   /         ext4    defaults        1 1
/dev/xvdb  /mnt      ext3    defaults,context=system_u:object_r:usr_t:s0  0 0
none       /proc     proc    defaults        0 0
none       /sys      sysfs   defaults        0 0
none       /dev/pts  devpts  gid=5,mode=620  0 0
none       /dev/shm  tmpfs   defaults        0 0
/dev/xvdj1 swap      swap    defaults        0 0     ←←←この行を远蚘
[root@ip-172-31-24-192 ~]#

若井「じゃあ確認の為に䞀回再起動したすね。」

[root@ip-172-31-24-192 ~]# shutdown -r now

若井「倧䞈倫ですね。自動でマりントされおたす。」
出来「これで、スワップ領域も完了ね。次の芁件の確認に移りたしょうか。(第4話参照)」
出来「次は、/tmpのディスク容量の確認ね。」
若井「df -hの結果はこんな感じですね。」

[root@ip-172-31-24-192 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvde1            6.0G  2.7G  3.2G  47% /
none                  1.9G     0  1.9G   0% /dev/shm
[root@ip-172-31-24-192 ~]#

出来「/tmpディレクトリは『/dev/xvde1』のディスク䞊に配眮されおいるから、これは問題なさそうね。」
若井「じゃあ次の芁件の確認は、゜フトりェア、デヌタファむルのディスク芁件ですけど、これは党く足りないですね。」
出来「そうね。スワップ領域を䜜成した芁領で、もう䞀回ディスク远加したしょうか。今床は20GBのディスクを远加したしょう。」
若井「分かりたした。たずは、『AWS マネヌゞメント コン゜ヌル』から、EBSの䜜成ずEC2ぞの『Attach』をやりたす。」

※ この郚分の手順に関しおは第4回を参照しお䞋さい。

若井「次は远加したディスクをOSで認識しおいるかどうか確認したす。」

[root@ip-172-31-24-192 ~]# cat /proc/partitions
major minor  #blocks  name

 202       65    6291456 xvde1
 202      144    4194304 xvdj
 202      145    4192933 xvdj1
 202      160   20971520 xvdk
[root@ip-172-31-24-192 ~]#

若井「20GBのディスクが、『xvdk』ずしお認識されたした。」
出来「そうそう。今回もパヌティションの䜜成は基本パヌティションで倧䞈倫よ。だけど、今回はスワップ領域では無いから、パヌティションタむプをスワップ領域に倉曎する必芁はないわ。たずはパヌティションの䜜成たでやっおみお。」

[root@ip-172-31-24-192 ~]# fdisk /dev/xvdk
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xf1a43be2.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): p

Disk /dev/xvdk: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf1a43be2

    Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):
Using default value 2610

Command (m for help): p

Disk /dev/xvdk: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf1a43be2

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdk1               1        2610    20964793+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@ip-172-31-24-192 ~]#

若井「はい。完了したした。」
出来「じゃあ、次は、远加したパヌティションを初期化をしたしょう。今回は『mkfs』コマンドで『ext4』ずいうフォヌマットで初期化するわ。これはしばらく時間が掛かるから䞀旊䌑憩にしたしょうか。
若井「ふヌ。ちょっずコヌヒヌ飲んでこよ。」
出来「あら、猶コヌヒヌなら奢るわよ」
若井「先茩、ありがずうございたす!」

[root@ip-172-31-24-192 ~]# mkfs.ext4 /dev/xvdk1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5241198 blocks
262059 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done

This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@ip-172-31-24-192 ~]#

ただただ、Oracleのむンストヌル芁件の確認は続きたす。次回ぞ続く。

執筆者玹介

山口 正寛(YAMAGUCHI Masahiro)

株匏䌚瀟システムサポヌト 東京支瀟むンフラ゜リュヌション事業郚所属。

同瀟が埗意ずするOracleデヌタベヌスの゚ンゞニアで、倧芏暡DWHのDB管理者、DBコンサルタントなどを経隓。たた、同瀟の無料セミナヌの䌁画にも携わる。

今回、機噚がなくおも気軜に環境を構築し怜蚌したいずいうかた向けに AWS䞊でOracleデヌタベヌスを構築するこずをストヌリヌ調で蚘茉する。 尚、同瀟はAWSを甚いたクラりド工房 powered by AWSずいうプロダクトがあり、産孊官連携でも掻甚しおいる。