安装
[root@msr01 ~]# yum install mysql-server
Installed:
mysql-server.x86_64 0:5.1.73-3.el6_5

Dependency Installed:
mysql.x86_64 0:5.1.73-3.el6_5
perl-DBD-MySQL.x86_64 0:4.013-3.el6
perl-DBI.x86_64 0:1.609-4.el6

启动并修改密码
[root@msr01 ~]# service mysqld start

Please report any problems with the /usr/bin/mysqlbug script!

[ OK ]
Starting mysqld: [ OK ]
[root@msr01 ~]# /usr/bin/mysqladmin -u root password ‘mysqlpass’
[root@msr01 ~]#
查看默认的my.cnf配置
[root@msr01 ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@msr01 ~]#

修改主服务器my.cnf配置
[root@msr01 ~]# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

server-id=1
log-bin=mysql-bin
binlog-ignore-db=mysql

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
在主数据库中增加复制用户并授权
mysql> grant replication slave on *.* to ‘msrslave’@’192.168.197.86’ identified by ‘slavepasswd’;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> show master status;
+——————+———-+————–+——————+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+——————+———-+————–+——————+
| mysql-bin.000001 | 106 | | mysql |
+——————+———-+————–+——————+
1 row in set (0.00 sec)

mysql> exit

修改从服务器my.cnf配置文件
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

server-id=2
log-bin=mysql-bin
replicate-ignore-db=mysql

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
停止slave线程并配置连接master
mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> change master to master_host=’192.168.197.85′,master_user=’msrslave’,master_password=’slavepasswd’;
Query OK, 0 rows affected (0.16 sec)

mysql>

在主服务器上开启3306端口
[root@msr01 ~]# iptables -I INPUT -p tcp –dport 3306 -j ACCEPT
[root@msr01 ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
[root@msr01 ~]#

重新启动slave服务器
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

查看slave运行状态
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Connecting to master
Master_Host: 192.168.197.85
Master_User: msrslave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File:
Read_Master_Log_Pos: 4
Relay_Log_File: mysqld-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File:
Slave_IO_Running: No
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB: mysql
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: 0
Relay_Log_Space: 106
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: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 2013
Last_IO_Error: error connecting to master ‘msrslave@192.168.197.85:3306′ – retry-time: 60 retries: 86400
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)

ERROR:
No query specified

mysql>
在主服务器上建立新数据库并导入数据
mysql> create database linuxcache;
Query OK, 1 row affected (0.00 sec)

mysql> grant all on linuxcache.* to linuxcache;
Query OK, 0 rows affected (0.02 sec)

mysql> grant all on linuxcache.* to linuxcache@’%’;
Query OK, 0 rows affected (0.01 sec)

mysql> set password for linuxcache@’%’=password(‘lcpasswd’);
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
[root@msr01 ~]# mysql -u root -pmysqlpass linuxcache < linuxcache.05_06_14.sql

在从服务器上查看复制生成的数据库
[root@msr02 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.1.73-log Source distribution

Copyright (c) 2000, 2013, 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 |
| linucache |
| test |
+——————–+
4 rows in set (0.00 sec)

mysql>

原文地址:http://www.linuxcache.com/archives/2663

转载请注明原文地址

【转载】MySQL Replication 环境安装与配置的更多相关文章

  1. Anaconda+Tensorflow环境安装与配置(转载)

    Anaconda+Tensorflow环境安装与配置 转载请注明出处:http://www.cnblogs.com/willnote/p/6746499.html Anaconda安装 在清华大学 T ...

  2. MySQL集群安装与配置

    MySQL集群安装与配置   文章目录 [隐藏] 一.mysql集群安装 二.节点配置 三.首次启动节点 四.测试服务是否正常 五.安全关闭和重启 MySQL Cluster 是 MySQL 适合于分 ...

  3. mysql.zip免安装版配置

    MYSQL ZIP免安装版配置 1. 下载MySQL 选择自己想要的.本次安装.我使用的是mysql-5.6.17-winx64  地址:http://dev.mysql.com/downloads/ ...

  4. C# 制作Java +Mysql+Tomcat 环境安装程序,一键式安装

    原文:C# 制作Java +Mysql+Tomcat 环境安装程序,一键式安装 要求: JDK.Mysql.Tomcat三者制作成一个安装包, 不能单独安装,安装过程不显示三者的界面, 安装完成要配置 ...

  5. linux学习之centos(三):mysql数据库的安装和配置

    前言:mysql简介 说到数据库,我们大多想到的是关系型数据库,比如mysql.oracle.sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库, ...

  6. mysql proxy代理安装和配置

    mysql proxy代理安装和配置 服务器说明: 192.168.1.219   mysql主库(主从复制) 192.168.1.177   mysql从库(主从复制) 192.168.1.202 ...

  7. linux应用之mysql数据库的安装及配置(centos)

    CentOS下Mysql数据库的安装与配置   如果要在Linux上做j2ee开发,首先得搭建好j2ee的开发环境,包括了jdk.tomcat.eclipse的安装(这个在之前的一篇随笔中已经有详细讲 ...

  8. MySQL数据库的安装与配置(windows)

    MySQL是目前最为流行的开放源码的数据库,是完全网络化的跨平台的关系型数据库系统,它是由瑞典MySQLAB公司开发,目前属于Oracle公司.任何人都能从Internet下载MySQL软件,而无需支 ...

  9. Django-DRF组件学习-环境安装与配置与序列化器学习

    1.DRF环境安装与配置 DRF需要以下依赖: Python (2.7, 3.2, 3.3, 3.4, 3.5, 3.6) Django (1.10, 1.11, 2.0) DRF是以Django扩展 ...

随机推荐

  1. 前端js实现打印excel表格

    产品原型: 图片.png 功能需求:点击导出考勤表格按钮,会自动下载成Excel格式 图片.png 图片.png jsp页面代码: <div class="tools"> ...

  2. 【84.62%】【codeforces 552A】Vanya and Table

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. 关于pptpd log日志文件的配置

    如何开启pptpd默认日志记录功能. 修改/etc/ppp/options.pptpd中的nologfd,默认没有开,把nologfd注释掉,然后添加 logfile /var/log/pptpd.l ...

  4. RAC sysdate

    rac的sysdate可能不一致,这个需要注意.

  5. 路由(Routing)

    RabbitMQ系列教程之四:路由(Routing) (使用Net客户端) 在上一个教程中,我们构建了一个简单的日志系统,我们能够向许多消息接受者广播发送日志消息. 在本教程中,我们将为其添加一项功能 ...

  6. poj1995 Raising Modulo Numbers【高速幂】

    Raising Modulo Numbers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5500   Accepted: ...

  7. 【Python 安装】安装第三方库时 PermissionError: [WinError 5] Access is denied

    对于 windows 用户,在开始菜单中输入 cmd,右键以 run as administrator(以管理员身份运行). Python - PIP install trouble shooting ...

  8. vijos1070 新年趣事之游戏 - 次小生成树

    传送门 题目大意: 求原图的最小生成树,和次小生成树. 题目分析: kruskals求mst(\(O(mlogm)\)) 考虑次小生成树暴力的做法,因为次小生成树总是由最小生成树删掉一条边并添加一条边 ...

  9. Zygote总结

    Zygote是由init进程通过解析 init.zygote.rc 文件而创建的,zygote所对应的可执行程序 app_process,所对应的源文件是App_main.cpp,进程名为zygote ...

  10. 【noip模拟】Fancy Signal Translate (暴力 + 哈希)

    题目描述 FST是一名可怜的 OIer,他很强,但是经常 fst,所以 rating 一直低迷. 但是重点在于,他真的很强!他发明了一种奇特的加密方式,这种加密方式只有OIer才能破解. 这种加密方式 ...