当前位置:网站首页>单机多实例MYSQL主从复制
单机多实例MYSQL主从复制
2022-06-28 23:58:00 【polarcoder】
实验环境
RHEL6.5
172.24.0.130 3306
172.24.0.130 3307
01、本次采用的MYSQL二进制快速安装
下载地址:
https://dev.mysql.com/downloads/mysql/
http://pan.baidu.com/s/1qYI0ybq
http://pan.baidu.com/s/1pLHM2TH 密码: pg5t
#截图操作

#根据需求选择对应的版本

02、解压并建立数据目录

tar zxf xxx.tar.gz -C /tmp
mkdir -p {data_3306,data3307} #存放数据
mkdir conf #放my.cnf
03、修改配置文件my.cnf
#3306my.cnf
[client] default-character-set=utf8 #客户端连接编码 [mysql] auto-rehash #客户端tab补全 default-character-set=utf8 #编码 [mysqld] user=mysql #运行账户 port=3306 #定义端口 log-bin=mysql-bin #开启二进制日志 server-id=001 #定义服务ID max_allowed_packet=50M ###最大 wait_timeout=3600 ###等待超时默认s interactive_timeout=3600 ###活动超时 innodb_buffer_pool_size = 128M join_buffer_size = 128M sort_buffer_size = 2M read_rnd_buffer_size = 2M basedir=/tmp/mysql_mulit #MYSQL根目录 datadir=/tmp/mysql_mulit/data_3306 #MYSQL数据存放目录 socket=/tmp/3306_mysql.sock #套接字 init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 #定义数据库默认字符 server\collation collation-server=utf8_unicode_ci skip-character-set-client-handshake symbolic-links=0 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES lower_case_table_names = 0 #对表的大小写不敏感 [mysqld_safe] log-error=/tmp/3306_err.log #错误日志 pid-file=/tmp/mysql_mulit/data_3306/mysqld.pid #pid,多协议通信 tcp/sock
3307my.cnf
[client] default-character-set=utf8 #客户端连接编码 [mysql] auto-rehash #客户端tab补全 default-character-set=utf8 #编码 [mysqld] user=mysql port=3307 #定义端口 log-bin=mysql-bin #开启二进制日志 server-id=011 #定义服务ID max_allowed_packet=50M ###最大 wait_timeout=3600 ###等待超时默认s interactive_timeout=3600 ###活动超时 innodb_buffer_pool_size = 128M join_buffer_size = 128M sort_buffer_size = 2M read_rnd_buffer_size = 2M basedir=/tmp/mysql_mulit #MYSQL根目录 datadir=/tmp/mysql_mulit/data_3307 #MYSQL数据存放目录 socket=/tmp/3307_mysql.sock #套接字 init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 #定义数据库默认字符 server\collation collation-server=utf8_unicode_ci skip-character-set-client-handshake symbolic-links=0 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES lower_case_table_names = 0 #对表的大小写不敏感 [mysqld_safe] log-error=/tmp/3307_err.log #错误日志 pid-file=/tmp/mysql_mulit/data_3307/mysqld.pid #pid,多协议通信 tcp/sock
04、初始化数据库
./scripts/mysql_install_db --defaults-file=conf/3306my.cnf
./scripts/mysql_install_db --defaults-file=conf/3306my.cnf
05、启动数据库
./bin/mysqld_safe --defaults-file=conf/3306my.cnf &
./bin/mysqld_safe --defaults-file=conf/3307my.cnf &
06、初始化root密码
./bin/mysqladmin -P 3306 -u root password '123123'
./bin/mysqladmin -P 3307 -u root password '123123'
07、master主机设置(3306)
建立从复制账号
grant replication slave on *.* to 'mysync'@'%' identified by '123456'; #所有IP
grant replication slave on *.* to 'mysync'@'localhost' identified by '123456'; #127.0.0.1
grant replication slave on *.* to 'mysync'@'zabibx' identified by '123456'; #172.24.0.130, zabbix是主机名
查看Master信息
mysql> show master status; #目的跟slave对上口径
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000003 | 541 | | | |
+------------------+----------+--------------+------------------+-------------------+
08、Slave从主机设置(3307)
进入mysql与master主机建立连接
change master to master_host='172.24.0.130',master_port=3306,master_user='mysync',master_password='123456', master_log_file='mysql-bin.000003',master_log_pos=541;
show slave status\G;
start slave; #启动从主机 stop slave;停止从主机
#截图中两个yes说明从机已经连接到主机

边栏推荐
- 【LeetCode】21. 合并两个有序链表 - Go 语言题解
- stm32F407-------GPIO输入实验
- Typescript -- Section 1: basic types
- Notes: three ways to define setters and Getters
- 11.目标分割
- stm32F407-------LCD
- 【C Primer Plus第二章课后编程题】
- urllib.parse 解析url连接中的参数
- MapReduce案例
- The company has a new Post-00 test paper king. The old oilman said that he could not do it. He has been
猜你喜欢

剑指 Offer 12. 矩阵中的路径

stm32F407-------时钟系统(SystemInit时钟初始化、Systick滴答定时器)

What are some tips to improve your interview success rate?

TypeScript --第三节:接口

Notes: three ways to define setters and Getters

Stm32f407-------- NVIC interrupt priority management

转载:VTK笔记-裁剪分割-不规则闭合圈选裁剪-vtkSelectPolyData类(黑山老妖)

Trois questions PWN

10、YOLO系列

Stm32f407 ------- RTC real time clock
随机推荐
一条update语句到底加了多少锁?带你深入理解底层原理
12. Détection d'objets Mask rcnn
请问指南针股票软件可靠吗?在上面交易股票安全吗?
PHP利用CURL实现登录网站后下载Excel文件
Summary of software testing cognition
Analysis of CSRF Cross Site Request Forgery vulnerability
【LeetCode】21. 合并两个有序链表 - Go 语言题解
mysql 高可用双主同步
stm32F407-------GPIO输入实验
What are some tips to improve your interview success rate?
Typescript -- Section 3: Interface
Trois questions PWN
入行数字IC验证后会做些什么?
TypeScript--第五节:类
Don't ask me how to do UI automation test again
Baidu knows the crawler, and obtains the dialogue below the comment according to the question Id, clue ID and comment ID
PHP uses endroid/qrcode QR code to generate, and Gd library generates sharing posters
转载:VTK笔记-裁剪分割-三维曲线或几何切割体数据(黑山老妖)
stm32F407-------寄存器地址名称映射分析
Association line exploration, how to connect the two nodes of the flow chart
