概述
一.依赖环境安装
yum install gcc-c++ gcc ncurses-devel
tar zxvf cmake-2.8.9.tar.gz
cd cmake-2.8.9
./configure
make;make install
二.mysql安装与配置
groupadd mysql
useradd -g mysql mysql
tar zxvf mysql-5.5.27.tar.gz
cd mysql-5.5.27
cmake .
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.27
-DMYSQL_DATADIR=/data/mysql
-DMYSQL_UNIX_ADDR=/data/mysql/mysqld.sock
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS=gbk,gb2312,utf8,ascii
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_MEMORY_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DENABLED_LOCAL_INFILE=1
-DMYSQL_USER=mysql
-DMYSQL_TCP_PORT=3306
-DWITH_DEBUG=0
make
make install
=======================mysql配置=================================
cd /usr/local/mysql-5.5.27/
cp ./support-files/my-huge.cnf /etc/my.cnf
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 700 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
mkdir -p /data/mysql
mkdir -p /data/mysql/3306/logs/binlog/
chown -R mysql:mysql /data/mysql
/usr/local/mysql-5.5.27/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.5.27 --datadir=/data/mysql/3306/data
mv /etc/my.cnf /data/mysql/3306/
ln -s /data/mysql/3306/my.cnf /etc/my.cnf
service mysqld start
cp -rf /usr/local/mysql-5.5.27/bin/* /usr/bin/
mysqladmin -u root password 'pinla2012'
======================主从配置============================
【master1】
====主数据库设置====
vim /etc/my.cnf
在mysqld中追加
#********master1*********
server-id=1
log-bin=mysql-bin
read-only=0
innodb_flush_log_at_trx_commit=1
sync_binlog=1
#binlog-do-db=pinladb
binlog_ignore_db=mysql
binlog_ignore_db=test
binlog_ignore_db=information_schema
replicate-ignore-db=test
replicate-ignore-db=mysql
replicate-ignore-db=information_schema
log-slave-updates
slave-skip-errors=all
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=1
service mysqld restart
mysql -uroot -p
GRANT FILE,REPLICATION SLAVE,REPLICATION CLIENT,SUPER,RELOAD ON *.* TO pl_backup@'%'IDENTIFIED by 'pinla2012';
==pinla_backup账号测试==
mysql -h192.168.10.240 -upinla_backup -p
change master to master_host='192.168.10.245',master_user='pl_backup',master_password='pinla2012', master_log_file='mysql-bin.000005';
flush privileges;
slave start;
show slave statusG
【master2】
#********master2*********
server-id=2
log-bin=mysql-bin
read-only=0
innodb_flush_log_at_trx_commit=1
sync_binlog=1
#binlog-do-db=pinladb
binlog_ignore_db=mysql
binlog_ignore_db=test
binlog_ignore_db=information_schema
replicate-ignore-db=test
replicate-ignore-db=mysql
replicate-ignore-db=information_schema
log-slave-updates
slave-skip-errors=all
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=2
service mysqld restart
mysql -uroot -p
GRANT FILE,REPLICATION SLAVE,REPLICATION CLIENT,SUPER,RELOAD ON *.* TO pl_backup@'%'IDENTIFIED by 'pinla2012';
==pinla_backup账号测试==
mysql -h192.168.10.245 -upinla_backup -p
change master to master_host='192.168.10.240',master_user='pl_backup',master_password='pinla2012', master_log_file='mysql-bin.000008';
flush privileges;
slave start;
show slave statusG
show processlist G;
【slave】
===从数据库设置====
#****slave******
server-id=10
log-bin=mysql-bin
binlog_format=mixed
replicate-ignore-db=test
replicate-ignore-db=mysql
replicate-ignore-db=information_schema
relay-log=db-server-2-relay-bin
log-slave-updates
===设置备份点===
mysql -uroot -p
slave stop;
change master to master_host='192.168.10.240',master_user='pl_backup',master_password='pinla2012', master_log_file='mysql-bin.000008';
slave start;
show slave statusG
==================heartbeat配置===========================
vip:192.168.10.244
master1-eth3:192.168.10.240
master1-eth2:10.10.10.100
master2-eth0:10.10.10.200
master2-eth1:192.168.10.245
1.双master服务器网卡设置
使用网线直接连接两个master,并且配置两个服务器的IP
2.安装HA与HA依赖包
yum install libnet heartbeat* heartbeat-devel heartbeat-pils heartbeat-stonith heartbeat-ldirectord ipvsadm
cp /usr/share/doc/heartbeat-2.1.3/authkeys /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.3/haresources /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.3/ha.cf /etc/ha.d/
==配置心跳加密方式:authkeys==
vim /etc/ha.d/authkeys
auth 1
1 crc
chmod 600 /etc/ha.d/authkeys
==配置心跳的监控:haresources==
vim /etc/ha.d/haresources
追加
PL100 IPaddr::192.168.10.245 ipvsadm mysqld
#PL100 为主主机名(可以使用uname -n获得) ipvsadm mysqld为启动心跳同时启动该服务。
#IPaddr:: 为VIP
mkdir -p /var/log/ha_log
chmod 777 /var/log/ha_log
==配置心跳的配置文件:ha.cf==
vi /etc/ha.d/ha.cf
#ha的日志文件记录位置
logfile /var/log/ha_log/ha-log.log
#使用eth3做心跳监测
bcast eth3
#设定心跳(监测)时间时间为2秒
keepalive 2
warntime 10
deadtime 30
initdead 120
hopfudge 1
#使用udp端口694进行心跳监测
udpport 694
auto_failback on
#节点1,必须要与 uname -n 指令得到的结果一致。
node PL100
#节点2
node PL102
ping 192.168.10.1 #通过ping网关来监测心跳是否正常
#respawn hacluster /usr/lib/heartbeat/ipfail
#apiauth ipfail gid=root uid=root
debugfile /var/log/ha_log/ha-debug.log
#创建日志文件
touch /var/log/ha_log/ha-log.log
==设置ipvsadm的巡回监测==
ipvsadm -A -t 192.168.10.244:3306 -s rr
ipvsadm -a -t 192.168.10.244:3306 -r 10.10.10.100:3306 -m
ipvsadm -a -t 192.168.10.244:3306 -r 10.10.10.200:3306 -m
执行后则开始进行监测
ipvsadm --list
service heartbeat start
chkconfig --add heartbeat
==防火墙设置==
iptables -I INPUT -p udp --dport 694 -j ACCEPT
=======到此为止以上为mysql+hearbeat配置========
最后
以上就是欢呼小懒虫为你收集整理的mysql heartbeat_mysql+heartbeat的全部内容,希望文章能够帮你解决mysql heartbeat_mysql+heartbeat所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复