EC2インスタンスのディスク容量を拡張する
以前に構築したEC2インスタンスでmongodbにログを貯めていったところ、
すぐに使用容量が一杯になってしまいました。
Volumeを見ると、デフォルトの8GB...orz
思い切って100GBに拡張してみたその手順。
mysql 自動起動設定確認
# chkconfig --list mysqld mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
mysql 自動起動設定OFF
# chkconfig mysqld off # chkconfig --list mysqld mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
mysql slaveステータス確認
mysql> SHOW SLAVE STATUS\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Slave_IO_Running: Yes Slave_SQL_Running: Yes
mysql> STOP SLAVE; Query OK, 0 rows affected (0.01 sec) mysql> SHOW SLAVE STATUS\G *************************** 1. row *************************** Slave_IO_State: Slave_IO_Running: No Slave_SQL_Running: No
mysql 停止
# service mysqld stop Stopping mysqld: [ OK ]
td-agent 停止
# service td-agent stop Shutting down td-agent: [ OK ]
mongodb 停止
# /etc/init.d/mongod stop Stopping mongod: [ OK ]
インスタンスの停止
AWS Management Console上で対象インスタンスを選択して、Action > Instance Lifecycle > stop
EBSのスナップショット作成
ELASTIC BLOCK STORE > Volumes > 対象のVolume選択 > Actions > Create Snapshot
スナップショットから100GBに拡張したVolumeを作成
Snapshots > Cleate Volume from Snapshot > Sizeに100GBと入力 > 現在のEBSのAvailability Zoneと同じものを選択
インスタンスに紐付けるEBSの変更
Volumes > Detach Volume > 表示されるPATHをメモる > Yes, Detach
新しく作ったVolumeを選択 > Attach Volume > インスタンス選択 > 前回と同じPATH > Yes,Attach
インスタンスの起動
対象インスタンスを選択して、Action > Instance Lifecycle > start
EBSリサイズ
# resize2fs /dev/sda1 # df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda1 99G 5.9G 92G 6% / tmpfs 3.7G 0 3.7G 0% /dev/shm
mongodb 起動 (起動に失敗したのでリペア起動)
# /etc/init.d/mongod start Starting mongod: about to fork child process, waiting until server is ready for connections. forked process: 1391 all output going to: /var/log/mongo/mongod.log ERROR: child process failed, exited with error number 100 [FAILED] # mongod --dbpath=/var/lib/mongodb --repair Thu Jul 4 14:56:20.973 [initandlisten] MongoDB starting : pid=1395 port=27017 dbpath=/var/lib/mongodb 64-bit host=xxxxxxxxx Thu Jul 4 14:56:20.973 [initandlisten] db version v2.4.4 Thu Jul 4 14:56:20.973 [initandlisten] git version: 4ec1fb96702c9d4c57b1e06dd34eb73a16e407d2 Thu Jul 4 14:56:20.974 [initandlisten] build info: Linux xxxxxxxxx #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49 Thu Jul 4 14:56:20.974 [initandlisten] allocator: tcmalloc Thu Jul 4 14:56:20.974 [initandlisten] shutdown: going to close listening sockets... Thu Jul 4 14:56:20.974 [initandlisten] shutdown: going to flush diaglog... Thu Jul 4 14:56:20.974 [initandlisten] shutdown: going to close sockets... Thu Jul 4 14:56:20.974 [initandlisten] shutdown: waiting for fs preallocator... Thu Jul 4 14:56:20.974 [initandlisten] shutdown: closing all files... Thu Jul 4 14:56:20.974 [initandlisten] closeAllFiles() finished Thu Jul 4 14:56:20.974 dbexit: really exiting now
td-agent 起動
# service td-agent start Starting td-agent: [ OK ]
mysql 起動
# service mysqld start Starting mysqld: [ OK ]