- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章如何快速使用mysqlreplicate搭建MySQL主从由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
简介 。
mysql-utilities工具集是一个集中了多种工具的合集,可以理解为是DBA的工具箱,本文介绍利用其中的mysqlreplicate工具来快速搭建MySQL主从环境.
HE1:192.168.1.248 slave 。
HE3:192.168.1.250 master 。
实战 。
Part1:安装mysql-utilities 。
1
2
3
4
5
6
7
|
[root@HE1 ~]# tar xvf mysql-utilities-1.5.4.tar.gz
[root@HE1 ~]# cd mysql-utilities-1.5.4
[root@HE1 mysql-utilities-1.5.4]# python setup.py build
[root@HE1 mysql-utilities-1.5.4]# python setup.py install
|
Part2:基本使用方式 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
[root@HE1 ~]# mysqlreplicate
--help
MySQL Utilities mysqlreplicate version 1.5.4
License type: GPLv2
Usage: mysqlreplicate
--master=root@localhost:3306 --slave=root@localhost:3310 --rpl-user=rpl:passwd
mysqlreplicate - establish replication
with
a master
Options:
--version show program's version number and exit
--help display a help message and exit
--license display program's license and exit
--master=MASTER connection information for master server in the form:
<
user
>[:<
password
>]@<host>[:<port>][:<socket>]
or
<login-path>[:<port>][:<socket>]
or
<config-
path>[<[
group
]>].
--slave=SLAVE connection information for slave server in the form:
<
user
>[:<
password
>]@<host>[:<port>][:<socket>]
or
<login-path>[:<port>][:<socket>]
or
<config-
path>[<[
group
]>].
--rpl-user=RPL_USER the user and password for the replication user
requirement,
in
the form: <
user
>[:<
password
>]
or
<login-path>. E.g. rpl:passwd
-p,
--pedantic fail if storage engines differ among master and slave.
--test-db=TEST_DB database name to use in testing replication setup
(optional)
--master-log-file=MASTER_LOG_FILE
use this master log file
to
initiate the slave.
--master-log-pos=MASTER_LOG_POS
use this position
in
the master log file
to
initiate
the slave.
-b,
--start-from-beginning
start replication
from
the
first
event recorded
in
the
binary
logging
of
the master.
Not
valid
with
--master-
log-file
or
--master-log-pos.
--ssl-ca=SSL_CA The path to a file that contains a list of trusted SSL
CAs.
--ssl-cert=SSL_CERT The name of the SSL certificate file to use for
establishing a secure
connection
.
--ssl-key=SSL_KEY The name of the SSL key file to use for establishing a
secure
connection
.
--ssl=SSL Specifies if the server connection requires use of
SSL. If an encrypted
connection
cannot be established,
the
connection
attempt fails.
By
default
0 (SSL
not
required).
-v,
--verbose control how much information is displayed. e.g., -v =
verbose, -vv = more verbose, -vvv = debug
-q,
--quiet turn off all messages for quiet execution.
|
Part3:主库准备 。
主库创建复制用户 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@HE3 ~]# mysql -uroot -p
Enter
password
:
Welcome
to
the MySQL monitor. Commands
end
with
;
or
\g.
Your MySQL
connection
id
is
23329
Server version: 5.7.16-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle
and
/
or
its affiliates.
All
rights reserved.
Oracle
is
a registered trademark
of
Oracle Corporation
and
/
or
its
affiliates. Other names may be trademarks
of
their respective
owners.
Type
'help;'
or
'\h'
for
help. Type
'\c'
to
clear the
current
input statement.
mysql>
grant
replication client,replication slave
on
*.*
to
'mysync'
@
'%'
identified
by
'MANAGER'
;
Query OK, 0
rows
affected, 1 warning (0.01 sec)
mysql> flush
privileges
;
Query OK, 0
rows
affected (0.01 sec)
|
Part4:一键配置 。
1
2
3
4
5
6
7
8
|
从库进行配置主从执行如下命令
[root@HE1 ~]# mysqlreplicate
--master=sys_admin:MANAGER@192.168.1.250:3306 --slave=sys_admin:MANAGER@192.168.1.248:3306 --rpl-user=mysync:MANAGER -b
WARNING: Using a
password
on
the command line interface can be insecure.
# master
on
192.168.1.250: ... connected.
# slave
on
192.168.1.248: ... connected.
# Checking
for
binary
logging
on
master...
# Setting up replication...
# ...done.
|
检查 。
Part1:mysqlrplcheck检查 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
[root@HE1 ~]# mysqlrplcheck
--master=sys_admin:MANAGER@192.168.1.250:3306 --slave=sys_admin:MANAGER@192.168.1.248:3306 -s
WARNING: Using a
password
on
the command line interface can be insecure.
# master
on
192.168.1.250: ... connected.
# slave
on
192.168.1.248: ... connected.
Test Description Status
---------------------------------------------------------------------------
Checking
for
binary
logging
on
master [pass]
Are there binlog exceptions? [pass]
Replication
user
exists? [pass]
Checking server_id
values
[pass]
Checking server_uuid
values
[pass]
Is
slave connected
to
master? [pass]
Check
master information file [pass]
Checking InnoDB compatibility [pass]
Checking storage engines compatibility [pass]
Checking lower_case_table_names settings [pass]
Checking slave delay (seconds behind master) [pass]
#
# Slave status:
#
Slave_IO_State : Waiting
for
master
to
send event
Master_Host : 192.168.1.250
Master_User : mysync
Master_Port : 3306
Connect_Retry : 60
Master_Log_File : mysql-bin.000003
Read_Master_Log_Pos : 384741
Relay_Log_File : HE1-relay-bin.000004
Relay_Log_Pos : 384954
Relay_Master_Log_File : mysql-bin.000003
Slave_IO_Running : Yes
Slave_SQL_Running : Yes
Replicate_Do_DB :
Replicate_Ignore_DB :
Replicate_Do_Table :
Replicate_Ignore_Table :
Replicate_Wild_Do_Table :
Replicate_Wild_Ignore_Table :
Last_Errno : 0
Last_Error :
Skip_Counter : 0
Exec_Master_Log_Pos : 384741
Relay_Log_Space : 1743112
Until_Condition : None
Until_Log_File :
Until_Log_Pos : 0
Master_SSL_Allowed :
No
Master_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 :
No
Last_IO_Errno : 0
Last_IO_Error :
Last_SQL_Errno : 0
Last_SQL_Error :
Replicate_Ignore_Server_Ids :
Master_Server_Id : 1250
Master_UUID : 1b1daad8-b501-11e6-aa21-000c29c6361d
Master_Info_File : /data/mysql/master.info
SQL_Delay : 0
SQL_Remaining_Delay : None
Slave_SQL_Running_State : Slave has
read
all
relay log; waiting
for
more updates
Master_Retry_Count : 86400
Master_Bind :
Last_IO_Error_Timestamp :
Last_SQL_Error_Timestamp :
Master_SSL_Crl :
Master_SSL_Crlpath :
Retrieved_Gtid_Set :
Executed_Gtid_Set :
Auto_Position : 0
Replicate_Rewrite_DB :
Channel_Name :
Master_TLS_Version :
# ...done.
|
其他常用工具 。
Part1:mysqldiskusage检查数据库空间大小 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@HE1 ~]# mysqldiskusage
--server=sys_admin:MANAGER@localhost
WARNING: Using a
password
on
the command line interface can be insecure.
# Source
on
localhost: ... connected.
#
Database
totals:
+
---------------------+--------------+
| db_name | total |
+
---------------------+--------------+
| maxscale_schema | 14,906 |
| mysql | 14,250,013 |
| performance_schema | 818,071 |
| sys | 500,802 |
| wms | 925,929,868 |
+
---------------------+--------------+
Total
database
disk usage = 941,513,660 bytes
or
897.90 MB
#...done.
|
Part2:mysqlindexcheck检查冗余索引 。
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@HE1 ~]# mysqlindexcheck
--server=sys_admin:MANAGER@localhost wms
WARNING: Using a
password
on
the command line interface can be insecure.
# Source
on
localhost: ... connected.
# The following
index
is
a duplicate
or
redundant
for
table
wms.auth_user:
#
CREATE
UNIQUE
INDEX
`index_user_name`
ON
`wms`.`auth_user` (`user_name`) USING BTREE
# may be redundant
or
duplicate
of
:
CREATE
INDEX
`user_name`
ON
`wms`.`auth_user` (`user_name`, `state`) USING BTREE
# The following
index
is
a duplicate
or
redundant
for
table
wms.basic_storeage_sapce:
#
CREATE
INDEX
`idx_store_district_space_no`
ON
`wms`.`basic_storeage_sapce` (`store_id`, `district_id`, `store_space_no`) USING BTREE
# may be redundant
or
duplicate
of
:
CREATE
UNIQUE
INDEX
`idx_store_district_space_no_un`
ON
`wms`.`basic_storeage_sapce` (`store_id`, `district_id`, `store_space_no`) USING BTREE
|
——总结—— 。
可以看到利用mysql-utilities工具集中的mysqlreplicate来配置MySQL主从非常简单,mysqlreplicate也提供了各类参数,本文中的-b是指使复制从主二进制日志中的第一个事件开始。mysqlrplcheck 中的-s是指输出show slave status\G的内容。由于笔者的水平有限,编写时间也很仓促,文中难免会出现一些错误或者不准确的地方,不妥之处恳请读者批评指正.
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我.
原文链接:https://blog.51cto.com/suifu/1878443 。
最后此篇关于如何快速使用mysqlreplicate搭建MySQL主从的文章就讲到这里了,如果你想了解更多关于如何快速使用mysqlreplicate搭建MySQL主从的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
为了构建 CentOS 6.5 OSM 切片服务器,我正在寻找一些文档和/或教程。 我试过this one正如我在我的 previous post 中所说的那样但它适用于 Ubuntu 14.04,而
我正在寻找可用于集成任何源代码控制管理系统的通用 git 桥(如 git-svn、git-p4、git-tfs)模板。 如果没有这样的模板,至少有一些关于如何在 git 端集成基本操作的说明(对于其他
1、前言 redis在我们企业级开发中是很常见的,但是单个redis不能保证我们的稳定使用,所以我们要建立一个集群。 redis有两种高可用的方案: High availabilit
简介 前提条件: 确保本机已经安装 VS Code。 确保本机已安装 SSH client, 并且确保远程主机已安装 SSH server。 VSCode 已经安装了插件 C/
为什么要用ELK ELK实际上是三个工具,Elastricsearch + Logstash + Kibana,通过ELK,用来收集日志还有进行日志分析,最后通过可视化UI进行展示。一开始业务量比
在日常办公当中,经常会需要一个共享文件夹来存放一些大家共享的资料,为了保证文件数据的安全,最佳的方式是公司内部服务器搭建FTP服务器,然后分配多个用户给相应的人员。今天给大家分享FileZilla搭
最近由于业务需要,开始进行 Flutter 的研究,由于 Flutter 的环境搭建在官网上有些细节不是很清楚,笔者重新整理输出 1. 配置镜像 由于在国内访问 Flutter
目录 1. 安装go软件包 2. 配置系统变量 3. 安装git 4. 设置go代理 5. 下载gin框架 6. 创建项目 7.
Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任
上篇文章给大家介绍了使用docker compose安装FastDfs文件服务器的实例详解 今天给大家介绍如何使用 docker compose 搭建 fastDFS文件服务器,内容详情如下所示:
目录 1.创建Maven 2.Maven目录和porm.xml配置 3.配置Tomcat服务器 1.创建Maven
laravel 官方提供 homestead 和 valet 作为本地开发环境,homestead 是一个官方预封装的 vagrant box,也就是一个虚拟机,但是跟 docker 比,它占用体积
这个tutorial显示了 Razor Pages 在 Asp.Net Core 2 中的实现。但是,当我运行 CLI 命令时: dotnet aspnet-codegenerator razorp
我创建了一个单独的类库项目来存储数据库上下文和模型类。在同一解决方案中,我创建了一个 ASP.NET MVC 项目并引用了类库项目,并在项目的 Web.config 文件中包含了数据库上下文的连接字符
关于代码托管,公司是基于Gitlab自建的,它功能全而强大,但是也比较重,我个人偏向于开源、小巧、轻便、实用,所以就排除了Github,在Gogs和Gitea中选者。Gogs在Github有38
目录 1、高可用简介 1.1 高可用整体架构 1.2 基于 QJM 的共享存储系统的数据同步机制分析 1.3 NameNode 主
Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,它已经在该站点运行超过两年半了。Igor 将源代码以类BSD许可证的形式发布。 在高并发连接的情况
对于我们的 ASP.NET Core 项目,我们使用包管理器控制台中的 Scaffold-DbContext 搭建现有数据库。 每次我们做脚手架时,上下文类与所有实体一起生成,它包含调用 option
我正在使用 .net 核心 2.0。我已经安装了以下 nuget 包:1: Microsoft.AspNetCore.All2: Microsoft.EntityFrameworkCore.Tools
我正在使用 NetBeans 及其 RAD 开发功能开发 JEE6 JSF 应用程序。我想使用脚手架来节省更新 Controller 和模型 View 的时间。 OneToMany 关联在 View
我是一名优秀的程序员,十分优秀!