MySQL + KeepAlived 实现 双主复制热备 及HA方案

来源:互联网 发布:mac无法解压zip 编辑:程序博客网 时间:2024/05/19 03:44

1、安装MySQL 5.6 server

yum list installed | grep mysql
yum -y remove mysql-libs.x86_64
wget --no-check-certificate https://repo.mysql.com//mysql-community-release-el6-5.noarch.rpm
yum localinstall mysql-community-release-el6-5.noarch.rpm
yum repolist all | grep mysql
yum-config-manager --disable mysql55-community
yum-config-manager --enable mysql56-community
yum repolist enabled | grep mysql
yum install mysql-community-server
service mysqld start


注意:

安装完MySQL后发现crontab被删除,需要重新安装!

yum -y install crontabs

chkconfig crond on


5.6版本配置

新安装的5.6版本,root的默认密码为空,在第一次启动时会做一些初始化动作。

启动后执行 mysql_secure_installation设置新的密码等其他信息。

chkconfig mysqld on
chkconfig --list | grep mysqld


5.7版本配置

chkconfig mysqld on
chkconfig --list | grep mysqld

vi /etc/my.cnf

[mysqld]节点下增加

skip-grant-tables

同时加上charactor_set_server=utf8

重启MySQL, 通过mysql -uroot 直接登录,执行

update mysql.user set authentication_string=password('123456') where user='root' ;

5.7中password->authentication_string

之后执行 flush privileges;

之后推出,将skip-grant-tables 注释,重启Mysql,再次进入mysql 首次执行语句之前必须修改密码:

set global validate_password_policy=0;
set global validate_password_length=1;
ALTER USER USER() IDENTIFIED BY '12345678';flush privileges;

事实上,可以通过在/var/log/mysql中找到密码

http://www.cnblogs.com/ivictor/p/5142809.html

执行

grep "password" /var/log/mysqld.log

出来的第一行中就有:

2016-11-25T00:12:50.248598Z 1 [Note] A temporary password is generated for root@localhost: d+dfnu*Dk4<p

//////5.7版本配置结束


2、配置MySQL双主复制

http://www.linuxidc.com/Linux/2014-10/108699.htm

http://dev.mysql.com/doc/refman/5.7/en/replication.html


3、安装并配置KeepAlived,实现HA

http://www.linuxidc.com/Linux/2014-11/109033.htm





0 0
原创粉丝点击