Home > Tags > ミラーリング

ミラーリング

ミラーリングによるバックアップ

余っているPC其の一
CPU: Celelon2.80GHz
HDD: 60G
メモリ: 768MB

これを無理矢理有効活用するべく、メインサーバーのMySQLとフォルダをリアルタイムミラーリングによるバックアップ機として復活させてみました。

【MySQL編】

マスタ側(例:192.168.1.10)

MySQL設定ファイルに追加
[root@centos ~]# vi /etc/my.cnf
[mysqld]
log-bin
server-id = 1

DBのバックアップ
[root@centos ~]# cd /var/lib/mysql
[root@centos ~]# tar cpf /var/tmp/mysql.tar .

レプリケーション設定
[root@centos ~]# mysql -u root -p
mysql> grant replication slave, replication client on *.* to repl@"192.168.1.20" identified by 'replpasswd';
mysql> flush privileges;
mysql> show master status;
+-------------------+----------+--------------+------------------+
| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+----------+--------------+------------------+
| mysqld-bin.000001 |    28363 |              |                  |
+-------------------+----------+--------------+------------------+
1 row in set (0.01 sec)
  ↑メモる

MySQL再起動
[root@centos ~]# /etc/init.d/mysqld restart

スレーブ側(例:192.168.1.20)

バックアップデータ展開
[root@linux ~]# cd /var/lib/mysql
[root@linux ~]# rm -fr *
[root@linux ~]# tar xpf /var/tmp/mysql.tar

MySQL再起動
[root@linux ~]# /etc/init.d/mysqld restart

MySQL設定ファイルに追加
[root@linux ~]# vi /etc/my.cnf
[mysqld]
server-id = 2

レプリケーション設定
[root@linux ~]# mysql -u root -p
mysql> grant all privileges on wordpress.* to wordpress@localhost identified by 'wordpresspasswd'; ← WordPress用ユーザー追加
mysql> CHANGE MASTER TO
    -> MASTER_HOST='192.168.1.10',
    -> MASTER_USER='repl',
    -> MASTER_PASSWORD='replpasswd',
    -> MASTER_LOG_FILE='mysqld-bin.000001',
    -> MASTER_LOG_POS=28363;
mysql> start slave;

MySQL再起動
[root@centos ~]# /etc/init.d/mysqld restart

【フォルダ編】

フォルダ編はリアルタイムミラーリングツール導入(lsyncd+rsyncd)をご覧ください。

これでメインサーバーのHDDが何時逝っても大丈夫になりました。ただ、ミラーリング用サーバーは常に電源を入れているわけではありませんが・・・
さて、余っているPCは残り2台となりました。
余っているPC其の二
CPU: Pentium4 2.40GHz
HDD: 160G
メモリ: 1GB

余っているPC其の三(ThinkPad T20)
CPU: PentiumIII 700MHz
HDD: 12G
メモリ: 128MB

ThinkPadにはCentOS4までしか入らないし、もう完全にゴミかなぁ

Home > Tags > ミラーリング

Ads
Tag Cloud
Feeds
Counter

Return to page top