.安装mysql源(centos7中默认是不包含mysql源)
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-.noarch.rpm
yum install mysql-server .配置mysql-master
在my.cnf中添加:
prot=
log-bin=master-bin
log-bin-index=master-bin.index
server-id= .重启mysql后新增复制用户
create user repl_user;
grant replication slave on *.* to repl_user identified by 'xyzzy'; .配置备机mysql
在my.cnf中添加下面几行
relay-log=slave-bin
relay-log-index=slave-bin.index
server-id= .发现备机无法连接到master服务器
nmap -v materIP 发现没有打开ssh的22端口
故打开:
firewall-cmd --zone=public --add-port=/tcp --permanent .slave数据库报错
有报错信息: mysql> CHANGE MASTER TO MASTER_HOST='192.168.52.129', -> MASTER_USER='repl', -> MASTER_PASSWORD='repl_1234', -> MASTER_LOG_FILE='mysql-bin.000141', -> MASTER_LOG_POS=; ERROR (HY000): Slave is not configuredor failed to initialize properl
y. You must at least set --server-id to enableeither a master or a slave.
Additional error messages can be found in the MySQLerror log. mysql>SHOW VARIABLES LIKE 'server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id | |
+---------------+-------+
row in set (0.00 sec) id没有生效
配置里面有[mysqld]和[mysqld_safe],新增的配置文件放的位置不一样,将新增配置
放到mysqld下试试,ok成功。 mysql> show variables like 'server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id | |
+---------------+-------+
row in set (0.00 sec) mysql> change master to
-> master_host='192.168.122.1'
-> ,master_port=,
-> master_user='repl_user',
-> master_password='xyzzy';
Query OK, rows affected, warnings (0.05 sec) mysql> start slave;
Query OK, rows affected (0.01 sec)
测试复制是否成功:
在master上创建一个数据库:
mysql> create database cydb;
Query OK, row affected (0.00 sec)
在slave上查看是否有此数据库:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cydb |
| mysql |
| performance_schema |
+--------------------+
rows in set (0.00 sec)
至此,简单的复制环境搭配成功。

错误:在用mysqldump 备份master以及在slave导入时均报权限不足,信息如下:

[root@localhost ~]# mysqldump --all-databases  >/tmp/backup.sqlmysqldump: Got error: : Access denied for user 'root'@'localhost' (using password: NO) when trying to connect

[root@localhost mysql]# mysql --host=192.168.122.59 </tmp/backup.sql
ERROR (): Access denied for user 'root'@'192.168.122.59' (using password: NO)

原因:root用户的host不是localhost,用如下语句查询:

select * from mysql.user where host!='127.0.0.1' and host!='localhost';

因此将root用户的host改为localhost(本地连接) 或者"%"(表示所有ip均可连接),重置密码后可以正确备份和导入了。

mysql简单复制服务搭建的更多相关文章

  1. Mysql之复制服务

    Replication[复制]使得数据可以从一个Master服务器上复制到一个或多个Slave上,默认是异步复制,不需要与Master建立永久连接:基于配置,可以作用于所有库,指定的库或库中的某些表. ...

  2. rabbitmq简单收发服务搭建

    消息发送.接收简单代码示例 mq.xml //rabbitmq config spring.rabbitmq.host=ip:host spring.rabbitmq.username= spring ...

  3. php+mysql+nginx+liunx 服务搭建

    安装php7相应的yum源   CentOS 7.x:   # rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7 ...

  4. MySQL 5.7.17 Group Relication(组复制)搭建手册【转】

    本博文介绍了Group Replication的两种工作模式的架构.并详细介绍了Single-Master Mode的部署过程,以及如何切换到Multi-Master Mode.当然,文末给出了Gro ...

  5. 搭建简单Django服务并通过HttpRequester实现GET/POST http请求提交表单

    调试Django框架写的服务时,需要模拟客户端发送POST请求,然而浏览器只能模拟简单的GET请求(将参数写在url内),网上搜索得到了HttpRequester这一firefox插件,完美的实现了模 ...

  6. php 和mysql httpd 简单网页的搭建

    使用两台服务器 Centos 7 做 php和httpd和php-sql 服务的安装  CentOS 5 做php 和 mysql 的安装 1.搭建本地yum源 两台服务器  都是 2.关闭防火墙和s ...

  7. 用nodejs搭建一个简单的服务监听程序

    作为一个从业三年左右的,并且从事过半年左右PHP开发工作的前端,对于后台,尤其是对以js语言进行开发的nodejs,那是比较有兴趣的,虽然本身并没有接触过相关的工作,只是自己私下做的一下小实验,但是还 ...

  8. MySQL半同步复制的搭建和配置原理

    半同步复制: 什么是半同步复制?我们知道在默认情况下,MySQL的复制是异步的,这意味着主服务器及其从服务器是独立的.异步复制可以提供最佳的性能,因为主服务器在将更新的数据写入它的二进制日志(Binl ...

  9. SpringBoot + Dubbo + zookeeper 搭建简单分布式服务

    SpringBoot + Dubbo + zookeeper 搭建简单分布式服务 详细操作及源码见: https://github.com/BillyYangOne/dubbo-springboot

随机推荐

  1. Composer Player 属性设置

    /// <summary> /// 设置选中名称 /// </summary> /// <param name="name"></para ...

  2. ZKUI中文编码以及以docker方式运行的问题

    *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...

  3. JS时间戳格式化日期时间

    由于mysql数据库里面存储时间存的是时间戳,取出来之后,JS要格式化一下显示.(李昌辉) 用的次数比较多,所以写了一个简单方法来转换: //时间戳转时间 function RiQi(sj) { va ...

  4. 【grunt第三弹】grunt在前端实际项目中的应用

    前言 [grunt第二弹]30分钟学会使用grunt打包前端代码(02) [grunt第一弹]30分钟学会使用grunt打包前端代码 经过前两次的学习,我们了解了grunt打包的一些基础知识,对于压缩 ...

  5. [python]数据整理,将取得的众多的沪深龙虎榜数据整一整

    将昨日取得的众多的沪深龙虎榜数据整一整 提取文件夹内所有抓取下来的沪深龙虎榜数据,整理出沪深两市(含中小创)涨幅榜股票及前5大买入卖出资金净值,保存到csv文件 再手动使用数据透视表进行统计 原始数据 ...

  6. input checkbox 扩大点击范围

    <div style="width:100%;height:100px;"><input type="checkbox" onclick=&q ...

  7. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(十一)路径导航模块

    config.xml文件的配置如下: <widget label="路径导航" icon="assets/images/lujingdaohang.png" ...

  8. Android Activity launchMode研究

    Android Activity launchMode研究 Activity的Launch mode一共有四种: standard, singleTop, singleTask, singleInst ...

  9. Retrofit 入门学习

    Retrofit 入门学习官方RetrofitAPI 官方的一个例子 public interface GitHubService { @GET("users/{user}/repos&qu ...

  10. 添加 All Exceptions 断点后, 每次运行都会在 main.m 中断的一种解决方法

    在本人项目添加导入和使用新的字体过程中,遇到一个很奇怪的问题: 项目开启了全局断点,但是每次启动都会运行在mian.m中断,点击下一步程序继续正常运行. 不知道是什么原因,于是google百度寻找答案 ...