1.Mysql集群的原理
![](https://i-blog.csdnimg.cn/blog_migrate/c8371559c3f35667badf4ae4b4a21fe0.png)
通过访问虚拟ip值,在主keepalived没有宕机的情况下访问主keepalived的值对应的mysql,主keepalived宕机的情况下访问从keepalived对应的mysql.两个服务器通过虚拟ip关联.
2.Linux上Mysql的安装
1、配置YUM源
1.yum源配置
查看安装yum源成功
yum repolist enabled | grep "mysql.*-community.*"
![](https://i-blog.csdnimg.cn/blog_migrate/91c1583726b7e2d40826888829cd1a36.png)
可以修改
vim /etc/yum.repos.d/mysql-community.repo
源,改变默认安装的mysql版本。比如要安装5.6版本,将5.7源的enabled=1改 成 enabled=0。然后再将5.6源的enabled=0改成enabled=1即可。改完之后的效果如下所示:
![](https://i-blog.csdnimg.cn/blog_migrate/265845f8b0f1c062334f386706779e74.png)
2、安装MySQL
shell> yum install mysql-community-server
3、启动MySQL服务
shell> systemctl start mysqld
查看MySQL的启动状态
shell> systemctl status mysqld● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled) Active: active (running) since 五 2016-06-24 04:37:37 CST; 35min ago Main PID: 2888 (mysqld) CGroup: /system.slice/mysqld.service └─2888 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid