Home Database Mysql Tutorial centos 6.5设置mysql主从同步过程记录

centos 6.5设置mysql主从同步过程记录

Jun 07, 2016 pm 04:40 PM
centos mysql Synchronize set up process

在centos 6.5上设置了mysql主从功能,记录一下。 服务器1(主) IP:192.168.1.201 系统版本:centos 6.5 mysql版本:mysql 5.5 服务器2(从) IP:192.168.1.202 系统版本:centos 6.5 mysql版本:mysql 5.5 这里两台服务器的系统版本和mysql版本均一致,这

在centos 6.5上设置了mysql主从功能,记录一下。

服务器1(主)
IP:192.168.1.201
系统版本:centos 6.5
mysql版本:mysql 5.5

服务器2(从)
IP:192.168.1.202
系统版本:centos 6.5
mysql版本:mysql 5.5

这里两台服务器的系统版本和mysql版本均一致,这也是官方推荐的做法。在开始设定之前,最好能确保主库和从库一致。

1、主库和从库创建同步用户

1

mysql> grant replication slave, replication client on *.* to repl@'192.168.1.%' identified by '密码';

Copy after login

这里讲主从同步限制在局域网内。

2、主库配置

编辑mysql配置文件/etc/my.cnf,设定如下配置:

1

2

3

log-bin=mysql-bin

binlog_format=mixed

server-id = 1

Copy after login

binlog_format这里选用混合模式,也是mysql 5.5安装包里的my.cnf默认的值。

3、从库配置

编辑mysql配置文件/etc/my.cnf,设定如下配置:

1

2

3

4

5

6

log-bin=mysql-bin

binlog_format=mixed

server-id = 2

relay_log = /var/lib/mysql/mysql-relay-bin

log_slave_updates = 1

read_only = 1

Copy after login

4、从库启动

1

2

3

4

5

mysql> change master to master_host='192.168.1.201',

master_user='repl',

master_password='100301',

master_log_file='mysql-bin.000001',

master_log_pos=0;

Copy after login

开启同步

1

mysql> start slave;

Copy after login

查看状态

1

mysql> show slave status\G

Copy after login
Copy after login

从库查看复制状态

从库查看复制状态

如果配置全都正确的话,那么主从就开始工作了。如果主从没有正常工作的话,可以通过mysql自带的命令进行调试。

出错调试

使用show slave status查看Last_IO_Error状态信息:

1

mysql> show slave status\G

Copy after login
Copy after login

主从设置连接出错

主从设置连接出错

上面这种情况表示无法正常连接到主库。因为无法连接主库,Slave_IO_State会一直显示Connecting to master。可以在从库上通过mysql客户端连接主库进行调试。

1

$ mysql -h 主库 -u repl -p

Copy after login

查看工作进程

主库上查看进程:

1

mysql> show processlist\G

Copy after login
Copy after login

查看主库线程

查看主库线程

从State信息可以看出主库已经发送完所有的binlog

从库上查看进程:

1

mysql> show processlist\G

Copy after login
Copy after login

查看从库线程

查看从库线程

其中一个是I/O线程,一个是SQL线程。

转载请注明:快乐编程 » centos 6.5设置mysql主从同步过程记录

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to optimize CentOS HDFS configuration How to optimize CentOS HDFS configuration Apr 14, 2025 pm 07:15 PM

Improve HDFS performance on CentOS: A comprehensive optimization guide to optimize HDFS (Hadoop distributed file system) on CentOS requires comprehensive consideration of hardware, system configuration and network settings. This article provides a series of optimization strategies to help you improve HDFS performance. 1. Hardware upgrade and selection resource expansion: Increase the CPU, memory and storage capacity of the server as much as possible. High-performance hardware: adopts high-performance network cards and switches to improve network throughput. 2. System configuration fine-tuning kernel parameter adjustment: Modify /etc/sysctl.conf file to optimize kernel parameters such as TCP connection number, file handle number and memory management. For example, adjust TCP connection status and buffer size

Centos stops maintenance 2024 Centos stops maintenance 2024 Apr 14, 2025 pm 08:39 PM

CentOS will be shut down in 2024 because its upstream distribution, RHEL 8, has been shut down. This shutdown will affect the CentOS 8 system, preventing it from continuing to receive updates. Users should plan for migration, and recommended options include CentOS Stream, AlmaLinux, and Rocky Linux to keep the system safe and stable.

Centos shutdown command line Centos shutdown command line Apr 14, 2025 pm 09:12 PM

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

How to check CentOS HDFS configuration How to check CentOS HDFS configuration Apr 14, 2025 pm 07:21 PM

Complete Guide to Checking HDFS Configuration in CentOS Systems This article will guide you how to effectively check the configuration and running status of HDFS on CentOS systems. The following steps will help you fully understand the setup and operation of HDFS. Verify Hadoop environment variable: First, make sure the Hadoop environment variable is set correctly. In the terminal, execute the following command to verify that Hadoop is installed and configured correctly: hadoopversion Check HDFS configuration file: The core configuration file of HDFS is located in the /etc/hadoop/conf/ directory, where core-site.xml and hdfs-site.xml are crucial. use

Centos install mysql Centos install mysql Apr 14, 2025 pm 08:09 PM

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.

Centos configuration IP address Centos configuration IP address Apr 14, 2025 pm 09:06 PM

Steps to configure IP address in CentOS: View the current network configuration: ip addr Edit the network configuration file: sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 Change IP address: Edit IPADDR= Line changes the subnet mask and gateway (optional): Edit NETMASK= and GATEWAY= Lines Restart the network service: sudo systemctl restart network verification IP address: ip addr

How to start mysql by docker How to start mysql by docker Apr 15, 2025 pm 12:09 PM

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

What are the common misunderstandings in CentOS HDFS configuration? What are the common misunderstandings in CentOS HDFS configuration? Apr 14, 2025 pm 07:12 PM

Common problems and solutions for Hadoop Distributed File System (HDFS) configuration under CentOS When building a HadoopHDFS cluster on CentOS, some common misconfigurations may lead to performance degradation, data loss and even the cluster cannot start. This article summarizes these common problems and their solutions to help you avoid these pitfalls and ensure the stability and efficient operation of your HDFS cluster. Rack-aware configuration error: Problem: Rack-aware information is not configured correctly, resulting in uneven distribution of data block replicas and increasing network load. Solution: Double check the rack-aware configuration in the hdfs-site.xml file and use hdfsdfsadmin-printTopo

See all articles