资源预览内容
第1页 / 共26页
第2页 / 共26页
第3页 / 共26页
第4页 / 共26页
第5页 / 共26页
第6页 / 共26页
第7页 / 共26页
第8页 / 共26页
第9页 / 共26页
第10页 / 共26页
亲,该文档总共26页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
MySQL MM+KeepAlived 高可用架构部署测试马飞2017-2-23一、环境准备一、环境准备1.11.1 操作系统信息操作系统信息安装三台 CentOS6.7 64 位操作系统。采用最小安装模式。sed -i s/=enforcing/=disabled/g /etc/selinux/configservice itpables stopchkconfig iptables off1.21.2 配置配置 NTPNTP 同步时间同步时间yum -y install ntp vi /etc/ntp.conf增加 3 个时间服务器 server s2d.time.edu.cn iburst #西南地区网络中心 server s2e.time.edu.cn iburst #西北地区网络中心 server s2f.time.edu.cn iburst #东北地区网络中心启动 ntp 服务 systemctl start ntpd systemctl enable ntpd 查看状态 ntpq -p1.31.3 配置角色信息配置角色信息主机名IP 地址描述Server idDb1192.168.8.100Master11Db2192.168.8.101Master22Db3192.168.8.102Slave131.41.4 服务角色及描述服务角色及描述IP 地址角色描述192.168.8.100ReadWrite r应用程序连接该 IP 对主库进写请求192.168.8.101ReadWrite r应用程序连接该 IP 对主库进写请求192.168.8.102Read Only应用程序连接到该 IP 处理读请求192.168.8.140ReadWrite r应用程序连接到该虚 IP 处理读写请求(不直 联 100,101) ,通过连接 140 实现高可用。1.51.5 配置配置/etc/hosts/etc/hosts在其中添加所有的主机信息:rootdb1 mysql# more /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 :1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.8.32 db1 192.168.8.33 db2 192.168.8.40b3二、安装二、安装 MySQLMySQL 2.12.1 卸载卸载 rpmrpm 包包roothadoop61 # rpm -qa | grep -i mysql mysql-5.1.73-5.el6_7.1.x86_64 mysql-server-5.1.73-5.el6_7.1.x86_64 perl-DBD-MySQL-4.013-3.el6.x86_64 mysql-devel-5.1.73-5.el6_7.1.x86_64 mysql-libs-5.1.73-5.el6_7.1.x86_64rpm -ev mysql-devel-5.1.73-5.el6_7.1.x86_64 rpm -ev mysql-server-5.1.73-5.el6_7.1.x86_64 rpm -ev perl-DBD-MySQL-4.013-3.el6.x86_64 rpm -ev mysql-5.1.73-5.el6_7.1.x86_64 roothadoop61 # rpm -e -nodeps mysql-libs-5.1.73-5.el6_7.1.x86_64 warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave http:/blog.csdn.net/fmwind/article/details/387975932.22.2 收集收集 mysqlmysql 对应的文件夹对应的文件夹roothadoop61 # find / -name mysql /var/lib/mysql /var/lib/mysql/mysql2.32.3 删除删除 mysqlmysql 对应的文件夹对应的文件夹rm -rf /var/lib/mysql2.42.4 下载下载 mysqlmysql 安装程序安装程序2.52.5 解压解压 mysqlmysql 安装程序安装程序tar -zxvf mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz -C /usr/local cd /usr/local mv mysql-5.6.31-linux-glibc2.5-x86_64 mysql5.62.62.6 添加用户和组添加用户和组groupadd mysql useradd -r -g mysql mysql2.72.7 安装数据库安装数据库进入安装 mysql 软件目录: cd /usr/local/mysql修改当前目录拥有者为 mysql 用户: chown -R mysql:mysql ./安装数据库: mkdir -p /data/mysql/data chown -R mysql.mysql /data/mysql#若是最小安装系统,还需要安装以下包: yum -y install perl perl-devel yum -y install libaio./scripts/mysql_install_db -basedir=/usr/local/mysql5.6 -datadir=/data/mysql/data - user=mysql修改配置文件: cp /usr/local/mysql5.6/my.cnf /etc/my.cnf# vi /etc/my.cnf mysqld basedir=/usr/local/mysql datadir=/data/mysql/data port=3306 sql_mode=NO_ENGINE_SUBSTITUTIO character-set-server=utf8 mysql default-character-set=utf8 client default-character-set=utf8启动脚本放到开机初始化目录 cp support-files/mysql.server /etc/init.d/mysql启动 mysql 服务: service mysql start查看 mysql 进程: ps -ef|grep mysql三、修改三、修改 MySQLMySQL 配置配置db1,db2,db3 三台主机上分别建立如下目录 mkdir /var/log/mysql #从 db1 上导出数据 mysqldump -master-data=2 -single-transaction -R -triggers -A all.sql#拷贝 all.sql 至 db2,db3 scp all.sql rootdb2:/usr/local/mysql5.6 scp all.sql rootdb3:/usr/local/mysql5.6(2)配置 db2#将 all.sql 导入 db2,db3 从库mysql -f -default-character-set=utf8 show slave statusG * 1. row *Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.1.212Master_User: replicationMaster_Port: 3306Connect_Retry: 10Master_Log_File: mysql-master-002-bin.000001Read_Master_Log_Pos: 120Relay_Log_File: mysql-master-001-bin.000004Relay_Log_Pos: 294 Relay_Master_Log_File: mysql-master-002-bin.000001Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB:Replicate_Ignore_DB: mysqlReplicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table:Last_Errno: 0Last_Error:Skip_Counter: 0Exec_Master_Log_Pos: 120Relay_Log_Space: 472Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids:Master_Server_Id: 2Master_UUID: 3d3b9f4f-f74f-11e5-9a30-005056b324c4Master_Info_File: /opt/mysql/data/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update itMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp:Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set:Executed_Gtid_Set:Auto_Position: 0 1 row in set (0.00 sec)注意注意: Slave_IO_Running: Yes Slave_SQL_Running: Yes4.24.2 配置配置 db1db1 作为主复制到作为主复制到 db3db3(1)配置 db3 指定 change master 为 db1,表示从 db1 复制到 db3#ssh 到 db3 服务器 mysql -u root -p #在 mysql 控制台录入 #这个是在 my.cnf 中没有使用 GTID(MySQL5.6 新特性)下的命令: CHANGE MASTER TO MASTER_HOST=192.168.8.33, MASTER_USER=repl, MASTER_PASSWORD=repl, MASTER_PORT=3306, MASTER_LOG_FILE=mysql-bin.000007, MASTER_LOG_POS=120, MASTER_CONNECT_RETRY=10;#
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号