快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

澳门新葡萄app下载:Heartbeat2.0.3配置MySQL5.0.18集群(1)配置MySQL



测试情况为:rehdat linux 9.0

hostname eth0 eth1

mysql5 192.168.0.50/24 10.4.66.35/24

mysql6 192.168.0.60/24 10.4.66.36/24

heartbeat interface eth0, with crosscab

service ip 10.4.66.88/24, by eth1, default gateway 10.4.66.2

共享存储采纳NAS办事器,数据造访地址为10.4.66.251:/data

在办事器本地的挂在目录也是/data

1. 安装MySQL5.0,安装到默认目录

清除筹备安装MySQL的办事器上linux自带的mysql-server,

[root@c0101 bin]# rpm -e mysql-server

[root@c0101 bin]# rpm -qa|grep mysql

mysql-3.23.54a-11

[root@c0101 bin]# userdel mysql

[root@c0101 bin]# mv /etc/my.cnf /etc/my.cnf.bak

(1)首先在第一台办事器(HA系统的主节点办事器),

开始安装

1056 useradd mysql

1057 tar xzvf mysql-max-5.0.18-linux-i686-glibc23.tar.gz

1059 mv mysql-max-5.0.18-linux-i686-glibc23 /usr/local/mysql

1060 cd /usr/local/mysql

1088 chown -R root .

1089 chown -R mysql ./data/

1090 chgrp -R mysql .

设置数据路径,把数据库数据文件放在共享的NFS目录下(NAS办事器),

PID和innioDB文件要放到办事器本地目录上,才能正常启动、竣事办事:

1125 vi /etc/my.cnf

[mysqld]

#Where to install a database data

datadir=/data/mysqldata

#Where to install a innoDB engine

innodb_data_home_dir = /usr/local/mysql/data

innodb_log_group_home_dir= /usr/local/mysql/data

innodb_data_file_path=ibdata1:50M;ibdata2:50M:autoextend

1106 cp ./support-files/mysql.server /etc/rc.d/init.d/

vi /etc/rc.d/init.d/mysql.server

编译第222开始的相关的两行,把PID文件放在办事器本地目录上:

pid_file=/usr/local/mysql/data/mysqlmanager-`/bin/hostname`.pid

server_pid_file=/usr/local/mysql/data/`/bin/hostname`.pid

安装MySQL的基础数据库:

1123 mount 10.4.66.251:/data /data

1124 mkdir /data/mysqldata

1127 ./scripts/mysql_install_db --user=mysql

1145 chown -R mysql.mysql /data/mysqldata/

假如正常的话,可以看到mysql正常启动了;

1146 /etc/rc.d/init.d/mysql.server start

1146 /etc/rc.d/init.d/mysql.server stop

设置设置设备摆设摆设HA高可用,不要设置NFS挂载和mysql办事在启动办事器时自动运行;

(2)然后在第二台办事器(HA系统的备份节点办事器),

1090 tar xzvf mysql-max-5.0.18-linux-i686-glibc23.tar澳门新葡萄app下载.gz

1092 mv mysql-max-5.0.18-linux-i686-glibc23 /usr/local/mysql

1093 cd /usr/local/mysql/

1095 chown -R root .

1096 chown -R mysql ./data/

1097 chgrp -R mysql .

设置数据路径,把数据库数据文件放在共享的NFS目录下(NAS办事器),

PID和innioDB文件要放到办事器本地目录上,才能正常启动、竣事办事:

1125 vi /etc/my.cnf

[mysqld]

#Where to install a database data

dat澳门新葡萄app下载adir=/data/mysqldata

#Where to install a innoDB engine

1059 ls

1060 cd heartbeat-2.0.3

1061 ls

1062 ./ConfigureMe configure

1063 make

1064 make install

3. 编辑Heartbeat HA的三个设置设置设备摆设摆设文件,设置设置设备摆设摆设MySQL的HA办事

两台办事器设置设置设备摆设摆设措施相同:

1067 cd /etc/ha.d

1068 cp /root/heartbeat-2.0.3/doc/ha.cf .

1069 vi ha.cf

logfile /var/log/ha-log # Log file

keepalive 2 # Heartbeat interval

deadtime 30 # How long to say the server's death

warntime 10

udpport 694 # Heartbeat port

bcast eth0 # Linux Heartbeat interface

auto_failback on # How to do when the failure server comes back

node mysql5 # How many servers in the HA system

node mysql6

ping 10.4.66.2 #ping a robust server to ensure the server's health;

#here is the default gateway

respawn hacluster /usr/lib/heartbeat/ipfail

设置设置设备摆设摆设心跳的加密,本次测试由于采纳交叉电缆,以是采纳最简单的crc要领:

1076 cp /root/heartbeat-2.0.3/doc/authkeys .

1077 vi auth澳门新葡萄app下载keys

auth 1

1 crc

1078 chmod 600 authkeys

1073 cp /root/heartbeat-2.0.3/doc/haresources .

设置设置设备摆设摆设资本,本次测试mysql办事的迁移,设置设置设备摆设摆设资本文件是关键

1074 vi 澳门新葡萄app下载haresources

mysql5 IPaddr::10.4.66.88/24/eth1 Filesystem::10.4.66.251:/data::/data::nfs mysql.server

这一行设置设置设备摆设摆设了3个资本,第一个是IP地址,第二个是NFS共享数据,

第三个是mysql.server办事,文件在/etc/rc.澳门新葡萄app下载d/init.d/目录,

可以应用mysql.server start或stop来启动或竣事办事。

4.设置Heartbeat HA办事自动启动,

heartbeat会自动把/data目录挂载,会自动启动MySQL Server;

设置设置设备摆设摆设HA高可用,不要设置NFS挂载和mysql办事在启动办事器时自动运行,

也便是说,把与HA相关资本交给Heartbeat HA去自动治理,

cd /etc/rc.d/rc0.d ; ln -s ../init.d/heartbeat K05heartbeat

cd /etc/rc.d/rc3.d ; ln -s ../init.d/heartbeat S75heartbeat

cd /etc/rc.d/rc5.d ; ln -s ../init.d/heartbeat S75heartbeat

cd /etc/rc.d/rc6.d ; ln -s ../init.d/heartbeat K05heartbeat

可以拔掉落主节点办事器的网线,看看有什么环境发生,测试是否正常?

然后再把网线插回去,看看HA办事是否运行,MySQL办事能否自动切换回来?

您可能还会对下面的文章感兴趣: