领导突然让做主从服务器,mysq让用5.5版本的,以前搭建过5.1,本来感觉很easy,哪知道却有很大区别调试了好长时间,终于弄好了!

mysql5.5安装起来也和以前的大不一样,以前的configure已经习惯了,现在突然来了个cmake。。。。

环境介绍:

centos 5.5系统,mysql版本为mysql-5.5.27

192.168.1.6  主服务器

192.168.1.4  从服务器

首先开始主服务器上的操作

标红位置为修改区域

[root@localhost ~]# grep -v ^# /etc/my.cnf |grep -v ^$

[client]

port            = 3306

socket          = /tmp/mysql.sock

[mysqld]

port            = 3306

socket          = /tmp/mysql.sock

skip-external-locking

key_buffer_size = 256M

max_allowed_packet = 1M

table_open_cache = 256

sort_buffer_size = 1M

read_buffer_size = 1M

read_rnd_buffer_size = 4M

myisam_sort_buffer_size = 64M

thread_cache_size = 8

query_cache_size= 16M

thread_concurrency = 8

binlog-do-db=beifen

binlog-do-db=bucuo

binlog-ignore-db=bubeifen

log-bin=mysql-bin

binlog_format=mixed

server-id       = 1

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

[myisamchk]

key_buffer_size = 128M

sort_buffer_size = 128M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

然后创建一个可以远程登陆到服务器上的一个数据库帐号,赋予权限

mysql> grant replication slave,reload,super on *.* to 'tiger'@'%' identified by '123456';

Query OK, 0 rows affected (0.05 sec)

修改完配置文件后的必要操作,重启服务

[root@localhost ~]# service mysqld restart

Shutting down MySQL.[确定]

Starting MySQL..[确定]

[root@localhost ~]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.27-log Source distribution

Copyright (c) 2000, 2011, 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> show master status;

+------------------+----------+--------------+------------------+

| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |

+------------------+----------+--------------+------------------+

| mysql-bin.000004 |      107 | beifen,bucuo | bubeifen         |

+------------------+----------+--------------+------------------+

1 row in set (0.01 sec)

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| beifen             |

| bucuo              |

| bufeifen           |

| mysql              |

| performance_schema |

| test               |

+--------------------+

7 rows in set (0.08 sec)

主服务器已经配置好了,下面开始从服务器的配置

[root@localhost ~]# grep -v ^# /etc/my.cnf |grep -v ^$

[client]

port            = 3306

socket          = /tmp/mysql.sock

[mysqld]

port            = 3306

socket          = /tmp/mysql.sock

skip-external-locking

key_buffer_size = 256M

max_allowed_packet = 1M

table_open_cache = 256

sort_buffer_size = 1M

read_buffer_size = 1M

read_rnd_buffer_size = 4M

myisam_sort_buffer_size = 64M

thread_cache_size = 8

query_cache_size= 16M

thread_concurrency = 8

replicate-do-db=beifen

replicate-do-db=bucuo

log-bin=mysql-bin

binlog_format=mixed

server-id       = 2

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

[myisamchk]

key_buffer_size = 128M

sort_buffer_size = 128M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

重启服务mysql

[root@localhost ~]# service mysqld restart

Shutting down MySQL...[确定]

Starting MySQL......[确定]

[root@localhost ~]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.27-log Source distribution

Copyright (c) 2000, 2011, 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> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+--------------------+

6 rows in set (0.03 sec)

mysql> change master to master_host='192.168.1.6',master_user='tiger',master_password='123456';

Query OK, 0 rows affected (0.06 sec)

mysql> slave start;

Query OK, 0 rows affected (0.03 sec)

mysql> show slave status \G

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.1.6

Master_User: tiger

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000004

Read_Master_Log_Pos: 107

Relay_Log_File: localhost-relay-bin.000005

Relay_Log_Pos: 253

Relay_Master_Log_File: mysql-bin.000004

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Replicate_Do_DB: beifen,bucuo

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: 107

Relay_Log_Space: 978

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: 1

1 row in set (0.00 sec)

发现主服务器上的beifen,bucuo这两个数据库已经同步过来

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| beifen             |

| bucuo              |

| mysql              |

| performance_schema |

| test               |

+--------------------+

6 rows in set (0.03 sec)

mysql> show processlist \G

*************************** 1. row ***************************

Id: 2

User: system user

Host:

db: NULL

Command: Connect

Time: 577

State: Waiting for master to send event

Info: NULL

*************************** 2. row ***************************

Id: 3

User: system user

Host:

db: NULL

Command: Connect

Time: 2239

State: Slave has read all relay log; waiting for the slave I/O thread to update it

Info: NULL

*************************** 3. row ***************************

Id: 4

User: root

Host: localhost

db: NULL

Command: Query

Time: 0

State: NULL

Info: show processlist

3 rows in set (0.02 sec)

//然后在主服务器上的beifen数据库中创建一个user表,发现从服务器上的beifen数据库也有了user表,OK,主从服务器搭建成功!

mysql 5.5 主从_Mysql 5.5主从搭建相关推荐

  1. mysql在同一台机器上实现主从_MySQL 5.7主从搭建(同一台机器)

    主从复制原理:复制是 MySQL 的一项功能,允许服务器将更改从一个实例复制到另一个实例.1)主服务器将所有数据和结构更改记录到二进制日志中.2)从属服务器从主服务器请求该二进制日志并在本地应用其内容 ...

  2. mysql设置数据库同步_MySQL数据库配置主从同步

    1.环境说明:DB master: 172.16.1.55 DB slave:172.16.1.56 2.Server-id 配置(/etc/my.cnf): 主库配置server-id要比从库的ID ...

  3. mysql 主从复制 有数据库_mysql 数据库一对一主从(master-slave)复制

    提要:网上查了资料说主从数据库要版本一致,我这里由于之前的安装原因数据库版本并不一致,而且主服务器(master)安装在windows,从服务器(slave)安装在Linux 数据库版本: 主:10. ...

  4. mysql5.7.17主从_MySQL 5.7主从不停机添加新从库

    MySQL 主从复制,不停机添加新从节点: 1.主库创建账号: 修改主库repl密码: show master status; alter user repl@'%' identified by '1 ...

  5. mysql cluster 设置单向复制_mysql单向主从配置

    1.环境要求 操作系统:centOS6.5或以上 Mysql版本:mysql5.5 主机配置:4核CPU.4G内存 2.主从复制的方式 mysql5.6开始主从复制有两种方式:基于日志(binlog) ...

  6. mysql 5.6 互为主从_mysql5.6主从同步,互为主从配置

    由于业务需要,需要做主从同步,互为主从等的mysql设置.主从设置主要涉及主从同步时使用的账号密码配置,my.cnf的配置,进入数据库进行master,slave配置.主要是这四个配置. 1,账号密码 ...

  7. MySQL主从配置和gtid主从配置

    文章目录 1.为什么需要主从复制? 2.什么是mysql的主从复制? 3.GTID的工作原理: 4.GTID与传统主从复制的区别是什么 5.mysql主从 5. 1mysql主从配置 5.1.1 确保 ...

  8. MySQL数据库进阶系统学习6(MySQL高级-视图-事务-索引-账户管理-主从)

    第六部分: MySQL高级 详细资料参考html文件17 9.1 视图 问题 对于复杂的查询,往往是有多个数据表进行关联查询而得到,如果数据库因为需求等原因发生了改变, 为了保证查询出来的数据与之前相 ...

  9. mysql 四大基础操作_mysql数据库的基本操作

    mysql数据库的基本操作 首先我们要把mysql装好 mkdir chen/ mount.cifs //192.168.100.23/LNMP chen/ [root@localhost ~]# y ...

最新文章

  1. CSP 202006-2 稀疏向量 python实现(非满分)(待更新)
  2. win7硬件要求_电脑硬件运行游戏测评
  3. thymeleaf+layui加载页面渲染时,TemplateProcessingException: Could not parse as expression:
  4. 关于单元测试脚手架的几点思考
  5. 网易架构师深入讲解Java开发!BAT等大厂必问技术面试题
  6. Jmeter连接Mysql
  7. 【JAVA 第四章 流程控制语句】课后习题 判断两个圆是否相交 圆和直线的位置关系
  8. python标准库模块教程_Python标准库之Sys模块使用详解
  9. mysql gman do_使用MySQL UDFs来调用gearman分布式任务分发系统
  10. android pc游戏模拟器哪个好用,哪个电脑手游模拟器好用 安卓手游模拟器测试对比排行榜...
  11. 求最大公约数与最小公倍数算法——Java
  12. 极速办公(Excel)如何方框内打勾
  13. 软件工程的未来发展趋势
  14. Java使用opencv调用微信扫描二维码引擎,附带windows和linux需要的动态库文件
  15. 晨星、银河基金业绩排行榜数据转换工具
  16. 书评|《小岛经济学》
  17. 5.1 OpenStack
  18. WIN7 iTunes无法识别iPhone,重装系统解决
  19. P7560-[JOISC 2021 Day1]フードコート【吉司机线段树】
  20. 动态规划之子序列以及子数组类型的问题

热门文章

  1. <el-upload>组件拖曳无法上传问题
  2. SID # 和NID #(系统识别码和网络识别码)
  3. 你的苹果Mac键盘锁住了要怎么办呢
  4. 【逻辑】500桶酒,其中1桶是毒酒,找毒酒
  5. 改进YOLOv7-Tiny系列:首发改进结合BiFPN结构的特征融合网络,网络融合更多有效特征,高效涨点
  6. Window线程安全与线程控制函数
  7. 用户画像(profile v.s. persona)
  8. Android 根据屏幕尺寸适配控件大小(按比例缩放)
  9. 电路之网孔电流法和回路电流总结
  10. [作业]习题2-2 韩信点兵(hanxin)