Heartbeat

一、安装Heartbeat

Linuxe操作平台 rhel-5.4(安装MYSQL、Linux开发环境)

IP设置
master  eth0 192.168.0.201/255.255.255.0
         eth1 172.16.1.1/255.255.0.0
slave    eth0 192.168.0.202
         eth1 172.16.1.2

1> 安装
   下列包必须安装:
   flex
   bison
   libet
   net-snmp-devel
   OpenIPMI
   docbook-style-xsl

   <<1>> 安装 Reusable-Cluster-Components-glue-1.0.5.tar.bz2.tar
         先添加用户:
        useradd -M hacluster
        groupadd haclient
        usermod -G haclient hacluster

         $ ./autogen.sh
         $ ./configure
         $ make
         $ sudo make install

    <<2>> 安装 Heartbeat-3-0-STABLE-3.0.3.tar.bz2.tar
      $ ./bootstrap 
./ConfigureMe configure
make
make install

   <<3>> 安装 Cluster-Resource-Agents-agents-1.0.3.tar.bz2.tar
      $ ./autogen.sh 
./configure 
make 
make install

   <<4>> 拷贝配置文件
        cd /etc/ha.d
        cp ~/Heartbeat-3-0-STABLE-3.0.3/doc/ha.cf ./
        cp ~//root/Cluster-Resource-Agents-agents-1.0.3/heartbeat/shellfuncs ./
        cp ~/Heartbeat-3-0-STABLE-3.0.3/doc/haresources ./
        创建authkeys文件  
        auth 1
        1 crc
        chmod 0600 /etc/ha.d/authkeys

2> 配置
<<1>> ha.cf
     debugfile /var/log/ha-debug
     logfile /var/log/ha-log
     logfacility     local0
     keepalive 2
     deadtime 30
     warntime 10
     initdead 120
     udpport 694 
     ucast eth1 172.16.1.2   (这个配置是在master上做的,在slave上此处填写master的IP)
     auto_failback on
     node    master
     node    slave
<<2>> haresource
     master IPaddr::192.168.0.204/24/eth0
<<3>> 启动Hreatbeat前复制配置文件
     $ cd /etc/ha.d/
     $ cp -R ./* /usr/etc/ha.d/

二、MySQL主-主热备

1、数据库同步设置
启动MySql服务 (Service mysqld start)
master:192.168.0.201
slave:192.168.0.202

2、设置root账户
mysql –u root –p
set password=password(‘mysql’); 
grant all privileges on *.* to 'adcc'@'%' identified by 'adcc' with grant option;
在master上增加一个slave可以登录的帐号:
grant all privileges on *.* to 'bgs'@'192.168.0.202’ identified by 'bgs' with grant

option;
  在slave上增加一个master可以登录的帐号:
grant all privileges on *.* to 'bgs'@'192.168.0.201’ identified by 'bgs' with grant

option;
3、 配置数据库参数
  以root用户登录master,修改master的my.cnf文件
  vi /etc/my.cnf
    在[mysqld]的配置项中增加如下配置:
   

default-character-set=utf8
     log-bin=mysql-bin
    relay-log=relay-bin
relay-log-index=relay-bin-index
server-id=1
master-host=192.168.0.202
master-user=bgs
master-password=bgs
master-port=3306
master-connect-retry=30
binlog-do-db=bgs
replicate-do-db=bgs
#replicate-ignore-table=umsdb.boco_tb_menu
4、以root用户登录slave,修改slave的my.cnf文件
  vi /etc/my.cnf
在[mysqld]的配置项中增加如下配置:
default-character-set=utf8
     log-bin=mysql-bin
    relay-log=relay-bin
relay-log-index=relay-bin-index
server-id=2
master-host=192.168.0.201
master-user=bgs
master-password=bgs
master-port=3306
master-connect-retry=30
binlog-do-db=bgs
replicate-do-db=bgs
#replicate-ignore-table=umsdb.boco_tb_menu

5、手工执行数据库同步
  假设以msater为主服务器,在slave上重启mysql:
  service mysqld restart
  在slave上用root用户登录mysql,执行:
  Mysql> stop slave;
  Mysql> load data from master;
  Mysql> start slave;
  在master上重启mysql:
service mysqld restart





  查看数据库同步状态
  在mysql命令提示符下执行:
  Mysql> show slave status\G
 
三、安装ACTIVEMQ
(1)安装jdk6-u18以上
(2)拷贝MYSQL jdbc driver 到 lib文件夹
     ( 3 ) 修改 config/activemq.xml
    (4)启动active服务

你可能感兴趣的:(heartbeat)