+------------------------------------------------------------------------------------------------------------+
| DRBD + Heartbeat + MySQL 설치 |
| 2008.009. 30. |
| |
| ; 자세한 설명은 달지 않았음. |
| ; 제가 설치한 환경에 맞춰서 작업했음. 필요에 따라 수정해서 사용 요망 |
| ; 이 문서는 모든 설치 및 테스트 후 재 구성 한 것임. 실수로 빠진 부분 있을 수 있음. |
| ; 인쇄방법 - EditPlus, 글꼴=굴림체, 글꼴 모양=Regular, 크기=9 |
| 자동 줄바꿈 사용, 모양 기준 칸에서 줄 바꿈, 모양 기준 칸 번호=110 |
+------------------------------------------------------------------------------------------------------------+
1. 기본 설정
+------------------------------------------------------------------------------------------------------------+
| 작업 서버 [Master]
| ===================================================================================
| [root-shell]# vi /etc/hosts
| 127.0.0.1 no1
| 192.168.2.109 no1
| 192.168.2.110 no2
| [root-shell]# vi /etc/sysconfig/network
| NETWORKING=yes
| NETWORKING_IPV6=no
| HOSTNAME=no1
| [root-shell]# shutdown -r now
| ...
| [root-shell]# _
+------------------------------------------------------------------------------------------------------------+
+------------------------------------------------------------------------------------------------------------+
| 작업 서버 [Slave]
| ===================================================================================
| [root-shell]# vi /etc/hosts
| 127.0.0.1 no2
| 192.168.2.109 no1
| 192.168.2.110 no2
|
| [root-shell]# vi /etc/sysconfig/network
| NETWORKING=yes
| NETWORKING_IPV6=no
| HOSTNAME=no2
| [root-shell]# shutdown -r now
| ...
| [root-shell]# _
+------------------------------------------------------------------------------------------------------------+
2. DRBD 설치
+------------------------------------------------------------------------------------------------------------+
| 작업 서버 [Master & Slave]
| ===================================================================================
| [root-shell]# cd /usr/local/src/
| [root-shell]# wget http://oss.linbit.com/drbd/8.2/drbd-8.2.6.tar.gz ./
| [root-shell]# tar zxvf drbd-8.2.4.tar.gz
| [root-shell]# cd drbd-8.2.6/
| [root-shell]# make rpm
| ...
| (if completed)...
| [root-shell]# cd dist/RPMS/i386/
| [root-shell]# ls -al
| -rw-r--r-- 1 root root 149968 Sep 28 06:31 drbd-8.2.6-3.i386.rpm
| -rw-r--r-- 1 root root 237445 Sep 28 06:31 drbd-debuginfo-8.2.6-3.i386.rpm
| -rw-r--r-- 1 root root 877977 Sep 28 06:31 drbd-km-2.6.18_92.el5-8.2.6-3.i386.rpm
| [root-shell]# rpm -Uvh drbd-*
| Preparing... ########################################### [100%]
| 1:drbd ########################################### [ 33%]
| 2:drbd-debuginfo ########################################### [ 67%]
| 3:drbd-km-2.6.18_92.el5 ########################################### [100%]
| [root-shell]# _
+------------------------------------------------------------------------------------------------------------+
3. DRBD 설정
+------------------------------------------------------------------------------------------------------------+
| 작업 서버 [Master & Slave]
| ===================================================================================
| [root-shell]# vi /etc/drbd.conf
| #
| # please have a a look at the example configuration file in
| # /usr/share/doc/drbd/drbd.conf
| #
| global { usage-count yes; }
| common { syncer { rate 10M; } }
| resource db {
| protocol C;
| # startup {
| # degr-wfc-timeout 10;
| # }
| net {
| cram-hmac-alg sha1;
| # timeout 1;
| }
| on no1 {
| device /dev/drbd0;
| disk /dev/sda4;
| address 192.168.2.109:7789;
| meta-disk internal;
| }
| on no2 {
| device /dev/drbd0;
| disk /dev/sda6;
| address 192.168.2.110:7789;
| meta-disk internal;
| }
| }
|
| [root-shell]# _
+------------------------------------------------------------------------------------------------------------+
4. DRBD Meta data 생성
+------------------------------------------------------------------------------------------------------------+
| 작업 서버 [Master & Slave]
| ===================================================================================
| [root-shell]# drbdadm create-md db
| ... Create meta-data....success
+------------------------------------------------------------------------------------------------------------+
5. filesystem 생성
+------------------------------------------------------------------------------------------------------------+
| 작업 서버 [Master]
| ===================================================================================
| [root-shell]# service drbd start
| ....... 상대 노드(no2)를 무한으로 기다린다. 무시하고 "yes"를 입력하여 빠져나온다.
| [root-shell]# drbdsetup /dev/drbd0 primary (-o)
| [root-shell]# mkfs.ext3 /dev/drbd0
+------------------------------------------------------------------------------------------------------------+
6. DRBD 구동
+------------------------------------------------------------------------------------------------------------+
| 작업 서버 [Master]
| ===================================================================================
| [root-shell]# server drbd start
| [root-shell]# _
+------------------------------------------------------------------------------------------------------------+
+------------------------------------------------------------------------------------------------------------+
| 작업 서버 [Slave]
| ===================================================================================
| [root-shell]# server drbd start
| [root-shell]# cat /proc/drbd
| version: 8.2.6 (api:88/proto:86-88)
| GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by root@no2, 2008-09-19 00:20:38
| 0: cs:Connected st:Secondary/Primary ds:UpToDate/UpToDate C r---
| ns:596 nr:404 dw:1000 dr:2809 al:0 bm:8 lo:0 pe:0 ua:0 ap:0
| [>...................] sync'ed: 0.3% (523443/961240)M
| finish: 14:30:08 speed: 50,236 (50,096) K/sec
| [root-shell]# _
+------------------------------------------------------------------------------------------------------------+
7. MySQL 설치
; data dir을 /db/mysql에 설치되도록
; my.cnf를 /db/mysql/my.cnf에 위치하고 /etc/my.cnf로 링크
; create-db는 MySQL에서만
+------------------------------------------------------------------------------------------------------------+
| 작업 서버 [Master]
| ===================================================================================
| [root-shell]# useradd -s /sbin/nologin -d /db/mysql mysql
| [root-shell]# cd /usr/local/src/
| [root-shell]# wget http://mysql.holywar.net/Downloads/MySQL-5.0/mysql-5.0.51.tar.gz
| [root-shell]# tar xvfz mysql-5.0.51.tar.gz
| [root-shell]# cd mysql-5.0.51
| [root-shell]# ./configure --prefix=/usr/local/mysql --with-client-ldflags=-all-static --with-pthread \
| --enable-thread-safe-client --without-debug --without-docs --without-bench \
| --enable-assembler --with-charset=euckr --localstatedir=/db/mysql \
| --with-mysqld-user=mysql \
| [root-shell]# make; make install
| [root-shell]# cp -av support-files/my-medium.cnf.sh /db/mysql/my.cf
| [root-shell]# ln -s /db/mysql/my.cnf /etc/
| [root-shell]# cp -av support-files/mysql.server.sh /etc/rc.d/init.d/mysqld
| [root-shell]# chmod 700 /etc/rc.d/init.d/mysqld
| [root-shell]# ./scripts/mysql_install_db.sh
| [root-shell]# chown -R mysql.mysql /db/mysql/
+------------------------------------------------------------------------------------------------------------+
+------------------------------------------------------------------------------------------------------------+
| 작업 서버 [Slave]
| ===================================================================================
| [root-shell]# useradd -s /sbin/nologin -d /db/mysql mysql
| [root-shell]# cd /usr/local/src/
| [root-shell]# wget http://mysql.holywar.net/Downloads/MySQL-5.0/mysql-5.0.51.tar.gz
| [root-shell]# tar xvfz mysql-5.0.51.tar.gz
| [root-shell]# cd mysql-5.0.51
| [root-shell]# ./configure --prefix=/usr/local/mysql --with-client-ldflags=-all-static --with-pthread \
| --enable-thread-safe-client --without-debug --without-docs --without-bench \
| --enable-assembler --with-charset=euckr --localstatedir=/db/mysql \
| --with-mysqld-user=mysql \
| [root-shell]# make; make install
| [root-shell]# ln -s /db/mysql/my.cnf /etc/
| [root-shell]# cp -av support-files/mysql.server.sh /etc/rc.d/init.d/mysqld
| [root-shell]# chmod 700 /etc/rc.d/init.d/mysqld
+------------------------------------------------------------------------------------------------------------+
8. Heartbeat 설치
+------------------------------------------------------------------------------------------------------------+
| 작업 서버 [Master & Slave]
| ===================================================================================
| [root-shell]# yum install heartbeat (에러나거나 3/4만 인스톨 될때는 다시한번)
| ...
| Complete!
| [root-shell]# _
+------------------------------------------------------------------------------------------------------------+
9. Heartbeat 설정
+------------------------------------------------------------------------------------------------------------+
| 작업 서버 [Master & Slave]
| ===================================================================================
| [root-shell]# vi /etc/ha.d/ha.cf
| logfacility daemon
| keepalive 500ms # 두 노드간에 얼마나 자주 heartbeat를 주고받을 것인가. 2 => 2초
| deadtime 10 # 호스트 죽었다고 판단하는 시간. 10초 지나면 failover 시작.
| warntime 5
| initdead 10
| #udpport 694 # UPD heartbeat 패킷을 보낼 포트
| #udp eth0 # heartbeat를 보낼 인터페이스
| #ping 192.168.2.1
| bcast eth0
| #respawn hacluster /usr/lib/heartbeat/ipfail
| use_logd yes
| debugfile /var/log/ha-debug
| logfile /var/log/ha-log
| #nice_failback on
| #crm on
| node no1
| node no2
| [root-shell]# _
+------------------------------------------------------------------------------------------------------------+
+------------------------------------------------------------------------------------------------------------+
| 작업 서버 [Master]
| ===================================================================================
| [root-shell]# ln -s /etc/rc.d/init.d/mysqld /etc/ha.d/resource.d/
| [root-shell]# vi /etc/ha.d/haresources
| no1 drbddisk::db Filesystem::/dev/drbd0::/db::ext3 mysqld 192.168.2.210
| [root-shell]# _
+------------------------------------------------------------------------------------------------------------+
+------------------------------------------------------------------------------------------------------------+
| 작업 서버 [Slave]
| ===================================================================================
| [root-shell]# ln -s /etc/rc.d/init.d/mysqld /etc/ha.d/resource.d/
| [root-shell]# vi /etc/ha.d/haresources
| no2 drbddisk::db Filesystem::/dev/drbd0::/db::ext3 mysqld 192.168.2.210
| [root-shell]# _
+------------------------------------------------------------------------------------------------------------+
10. Heartbeat 구동
+------------------------------------------------------------------------------------------------------------+
| 작업 서버 [Master & Slave]
| ===================================================================================
| [root-shell]# service heartbeat start
| [root-shell]# _
+------------------------------------------------------------------------------------------------------------+
EOF
'프로그래밍 > mysql' 카테고리의 다른 글
mysql - index 강제로 지정하기 (0) | 2012.07.19 |
---|---|
mysql - index desc로 생성 (0) | 2012.07.19 |
mysql - Drop 된 Mysql Binlog를 이용한 복구 과정 (0) | 2012.07.19 |
Mysql DB 부하 조사 (0) | 2012.07.19 |
mysql - alter enum (0) | 2012.07.19 |