久々にAmazon EC2とEBSを使ってみました。過去にMySQLの設定していたと思ったのですが、していなかったようなので改めて設定。使用しているEC2のAMIはFedore Core 8ベースです。(お勧めのAmazon EC2のPublic AMIs)
EBSの設定は、こちらを参考にしてください。
Amazon Elastic Block Store (EBS)を使ってみた
MySQLのインストールと稼働確認
# yum install mysql-server # yum install mysql # /etc/init.d/mysqld start Support MySQL by buying support/licenses at http://shop.mysql.com [ OK ] Starting MySQL: [ OK ] # mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.0.45 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.00 sec)
とりあえずインストールまで完了です。一旦止めて、EBS上にデータ等を移動させます。設定ファイルを書き換えるのが面倒くさいのと、yumとの整合性を考えて、データ等をEBS上に移動させてシンボリックリンクを貼るだけにとどめておきます。
# /etc/init.d/mysqld stop Stopping MySQL: [ OK # mv /var/lib/mysql /vol/lib # ls /vol/lib mysql # cd /var/lib # ln -s /vol/lib/mysql/ mysql # /etc/init.d/mysqld start Starting MySQL: [ OK ]
稼働の確認と、データベースの作成テスト
mysql> create database hoge; Query OK, 1 row affected (0.00 sec) mysql> exit Bye # ls /vol/lib/mysql/ hoge ib_logfile0 ib_logfile1 ibdata1 mysql mysql.sock test
おっけいです。
参考
http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1663&categoryID=100
Amazon Elastic Block Store(EBS)でmysqlを動かしてみたよ