[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
1090 tar xzvf mysql-max-5.0.18-linux-i686-glibc23.tar.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
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
在NFS目录/data/下,已经有了基本数据库,所以只需要
设置一下,就可以启动了,
1123 mount 10.4.66.251:/data /data
1149 /etc/rc.d/init.d/mysql.server start
(1)安装libnet,这是编译Heartbeat HA需要的:
1046 tar xzvf libnet.tar.gz
1047 cd libnet
1048 ls
1049 ./configure
1051 make
1052 make install
(2)编译安装Heartbeat HA
1019 groupadd haclient
1020 useradd hacluster -g haclient
1058 tar xzvf heartbeat-2.0.3.tar.gz
1059 ls
1060 cd heartbeat-2.0.3
1061 ls
1062 ./ConfigureMe configure
1063 make
1064 make install
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