In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you how MySQL to achieve high availability + shared storage NFS, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
a planning chart
1. First of all, analyze the resources.
1) Vip
2) Mysqld
3) Nfs
Sort out the startup sequence between them: nfs must be started before mysqld starts
2. Configuration of nfs
The partition mounted on the NFS shared directory is best made into lvm to achieve automatic expansion.
2.1 installation
# yum-y install nfs-utils
2.2 configuration
# mkdir / share
# vim / etc/exports
172.16.98.3:/share 172.16.98.1 (rw,no_root_squash) 172.16.98.2 (rw,no_root_squash)
# service nfs start
# groupadd-g 186 mysql
# useradd-u 186-g mysql-s / sbin/nologin-M mysql
# chown mysql:mysql / share
3. Mount the nfs partition on mysql1 for mysql installation test
3.1Mount nfs
# mkdir / data
# chown mysql:mysql / data
# mount 172.16.98.3:/share / data
3.2 install using mysql's unzipped package
# groupadd-g 186 mysql
# useradd-u 186-g mysql-s / sbin/nologin-M mysql
On the three machines, the mysql group created should be consistent with the user's uid and gid
# tar-zxvf mysql-5.5.24-linux2.6-i686.tar.gz-C / usr/local
# cd / usr/local
# ln-s mysql-5.5.24-linux2.6-i686 mysql
# cd mysql
# chown-R mysql:mysql.
# scripts/mysql_install_db-user=mysql-datadir=/data
# chowm-R root.
# cp support-files/my-large.cnf / etc/my.cnf
# cp support-files/mysql.server / etc/rc.d/init.d/mysqld
# chmod + x / etc/rc.d/init.d/mysqld
# vim / etc/profile
PATH=$PATH:/usr/local/mysql/bin
# export PATH=$PATH:/usr/local/mysql/bin
3.3 Edit the configuration file and start the service
# vim / etc/my.cnf
[mysqld]
Thread_concurrency = 2
Datadir=/data
# service mysqld start
3.4 installation on mysql2
Referring to the previous steps, what needs to be explained is the installation of MySQL. There is no need to initialize mysql here.
# tar-zxvf mysql-5.5.24-linux2.6-i686.tar.gz-C / usr/local
# cd / usr/local
# ln-s mysql-5.5.24-linux2.6-i686 mysql
# cd mysql
# chowm-R root.
# cp support-files/my-large.cnf / etc/my.cnf
# cp support-files/mysql.server / etc/rc.d/init.d/mysqld
# chmod + x / etc/rc.d/init.d/mysqld
# vim / etc/profile
PATH=$PATH:/usr/local/mysql/bin
# export PATH=$PATH:/usr/local/mysql/bin
# service mysqld start
# cd / data
3.5 stop all resources
1) shut down the mysql service
# service mysqld stop
2) Uninstall the nfs shared directory
# umount / data
4. Installation of Corosync
Preparation in advance
1) ssh computers trust each other, which is easy to configure.
2) keep the time consistent
3) / etc/hosts, set hostname, resolve each other
4.1 install corosync on mysql1, mysql2
# yum install-y cluster-glue-1.0.6-1.6.el5.i386.rpm cluster-glue-libs-1.0.6-1.6.el5.i386.rpm corosynclib-1.2.7-1.1.el5.i386.rpm corosync-1.2.7-1.1.el5.i386.rpm heartbeat-3.0.3-2.3.el5.i386.rpm heartbeat-libs-3.0.3-2.3.el5.i386.rpm libesmtp-1.0 .4-5.el5.i386.rpm pacemaker-cts-1.1.5-1.1.el5.i386.rpm pacemaker-libs-1.1.5-1.1.el5.i386.rpm pacemaker-1.1.5-1.1.el5.i386.rpm perl-TimeDate-1.16-5.el5.noarch.rpm resource-agents-1.0.4-1.1.el5.i386.rpm
4.2 configuration of corosync
1) mysql1
# cd / etc/corosync
# cp corosync.conf.example corosync.conf
# vim corosync.conf
Compatibility: whitetank
Totem {
Version: 2
Secauth:on enables authentication
Threads: 0
Interface {
Ringnumber: 0
Bindnetaddr: 172.16.0.0
Mcastaddr: 226.94.1.1
Mcastport: 5405
}
}
Logging {
Fileline: off
To_stderr: on
To_logfile: yes
# to_syslog: yes
Logfile: / var/log/cluster/corosync.log
Debug: off
Timestamp: on
Logger_subsys {
Subsys: AMF
Debug: off
}
}
Amf {
Mode: disabled
}
Service {
Ver:0
Name:pacemaker
}
# corosync-keygen create authkeys
# scp authkeys corosync.conf node2:/etc/corosync
Create directories for logs on the two mysql
# mkdir / var/log/cluster
4.3 enable corosync via mysql1 to configure resources
1) enable
# service corosync start
# ssh node2 'service corosync start'
# crm_mon
=
Last updated: Thu Aug 9 22:12:22 2012
Stack: openais
Current DC: node1.linuxidc.com-partition with quorum
Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f
2 Nodes configured, 2 expected votes
0 Resources configured.
=
Online: [node2.linuxidc.com node1.linuxidc.com]
2) allocation of resources
# crm
Crm (live) # configure
Crm (live) configure# primitive vip ocf:heartbeat:IPaddr params ip=172.16.99.1
Crm (live) configure# primitive mysqld lsb:mysqld
Crm (live) configure# primitive nfs ocf:heartbeat:Filesystem params device=172.16.98.3:/share directory=/data fstype=nfs op start timeout=60 op stop timeout=60
/ / define nfs resources. The default timeout is 20s, which is less than the recommended time of 60s, so configure it manually.
Crm (live) configure# colocation vip_mysqld_nfs inf: mysqld nfs vip
Crm (live) configure# order mysqld_after_nfs inf: nfs mysqld
Crm (live) configure# property stonith-enabled=false
Crm (live) configure# property no-quorum-policy=ignore
Crm (live) configure# verify
Crm (live) configure# commit
3) Detection
# crm_mon
Last updated: Thu Aug 9 22:34:52 2012
Stack: openais
Current DC: node1.linuxidc.com-partition with quorum
Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f
2 Nodes configured, 2 expected votes
3 Resources configured.
=
Online: [node2.linuxidc.com node1.linuxidc.com]
Nfs (ocf::heartbeat:Filesystem): Started node1.linuxidc.com
Vip (ocf::heartbeat:IPaddr): Started node1.linuxidc.com
Mysqld (lsb:mysqld): Started node1.linuxidc.com
# crm node standy
# crm_mon
=
Last updated: Thu Aug 9 22:36:18 2012
Stack: openais
Current DC: node1.linuxidc.com-partition with quorum
Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f
2 Nodes configured, 2 expected votes
3 Resources configured.
=
Node node1.linuxidc.com: standby
Online: [node2.linuxidc.com]
Nfs (ocf::heartbeat:Filesystem): Started node2.linuxidc.com
Vip (ocf::heartbeat:IPaddr): Started node2.linuxidc.com
Mysqld (lsb:mysqld): Started node2.linuxidc.com
These are all the contents of the article "how to achieve High availability + shared Storage NFS in MySQL". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.