mysql5.5 master-slave(Replication)配置方法_MySQL
bitsCN.com
一主一从:
Master:
OS:centos release 5.6 DB:mysql 5.5.8 IP:192.168.1.2
Slave:
OS:centos release 5.6 DB:mysql 5.5.8 IP:192.168.1.3
修改主机Master配置文件 (/etc/my.cnf)
[mysqld]
//至少要有server-id、与log-bin两项
server-id=1
log-bin=/var/lib/mysql/mysql-bin
datadir=/var/lib/mysql
//为了使用事务的InnoDB在复制中最大的持久性和一致性,你应该指定innodb_flush_log_at_trx_commit=1,sync_binlog=1选项
innodb_flush_log_at_trx_commit=1
sync_binlog=1
在主机Master创建一个有复制权限的用户
mysql>create user repl_user@192.168.1.3;
mysql>grant replication slave on *.* to repl_user@192.168.1.3 identified by '123456';
锁住主机,记录二进制日志的位置(后面设置从机的时候会用到)
mysql>flush tables with read lock;
mysal>show master status;
File:mysql-bin.000013 Position:7863951
复制主机数据库(test)到从机
shell>/usr/bin/mysqldump test -uroot -padmin --opt | mysql test -uroot -padmin -h 192.168.1.3
重新打开主机Master写操作功能
mysql>unlock tables;
修改从机Slave配置文件(/etc/my.cnf)
[mysqld]
server-id=2 //必须是1到2的32次方之间的一个整数,且必须和主机Master的server-id不一样
relay-log-index=slave-relay-bin.index
relay-log=slave-relay-bin
replicate-do-db=test //指定复制数据库
datadir=/var/lib/mysql
从机Slave初始化复制
mysql>slave stop;
mysql>change master to master_host='192.168.1.2',
->master_user='repl_user',
->master_password='123456',
->master_log_file='mysql-bin.000013',
->master_log_pos=7863951;
开启复制
mysql>start slave;
查看复制状态
mysql>show slave status/G
测试复制:
在主机master中对test数据库进行sql操作,再查看从机test数据库是否产生同步。
Slave SQL错误导致同步卡住的一种处理方法
mysql>slave stop;
mysql>set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
mysql>slave start;
bitsCN.com

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



If you bought your laptop from a mobile operator, you most likely had the option to activate an eSIM and use your cellular network to connect your computer to the Internet. With eSIM, you don't need to insert another physical SIM card into your laptop because it's already built-in. It is very useful when your device cannot connect to the network. How to check if my Windows 11 device is eSIM compatible? Click the Start button and go to Network & Internet > Cellular > Settings. If you don't see the "Cellular" option, your device doesn't have eSIM capabilities and you should check another option, such as using your mobile device to connect your laptop to a hotspot. In order to activate and

The relationship between the host's domain name and the host's IP address is: one IP address corresponds to multiple domain names. The IP address uses a digital form to identify the host in the computer network, and the domain name uses a character form to identify the host in the computer network. In the Internet, one domain name can correspond to one IP address, but one IP address can be corresponding to multiple domain names.

According to news from this site on July 23, Lenovo’s YOGA Portal high-performance desktop computer, which has been exposed for a long time, is now confirmed to be officially released at ChinaJoy in Shanghai on July 27. It is claimed to be a mini host designed for professional AI creation. It is a performance master and an expert in AI creation of 3D digital people. The AI virtual background is based on the on-site pictures provided by our friend @yuP in Shanghai. The volume of this small host is only 3.7L. It is made of anodized aluminum and is equipped with Intel Core. i7-14700 processor, equipped with 32GBDDR5 memory and 1TB solid state drive. YOGA Portal is both a host and an all-in-one AI creation machine. The high-performance host is combined with an algorithm-optimized camera to form an integrated solution. Just stand in front of the camera i.e.

According to news from this site on June 5, MSI participated in the 2024 Taipei International Computer Show and showcased a new flagship gaming computer called MEGVisionXAI. This game console is an extension of the existing Vision series and uses a very eye-catching surround glass design, with internal components clearly visible. The most attractive part is that the front of the host is equipped with an oversized touch screen. MSI staff said that it can synchronize MSI’s exclusive AI applications to further enhance various AI functions. The relevant pictures attached to this site are as follows: MSI has not yet explained more details. From the pictures shared, you can see that a local AI chatbot is running on the screen. Users can interact with it and ask it to complete AI tasks and locate locally stored documents. wait. Source of the above picture:

Why should we write the fixed file of the configuration file? We can directly write it as a .py file, such as settings.py or config.py. The advantage of this is that we can directly import parts of it through import in the same project; but if we need to use it in other When sharing configuration files on non-Python platforms, writing a single .py is not a good choice. At this time we should choose a common configuration file type to store these fixed parts. Currently, the commonly used and popular configuration file format types mainly include ini, json, toml, yaml, xml, etc. We can access these types of configuration files through standard libraries or third-party libraries.

Setting up a wireless network is common, but choosing or changing the network type can be confusing, especially if you don't know the consequences. If you're looking for advice on how to change the network type from public to private or vice versa in Windows 11, read on for some helpful information. What are the different network profiles in Windows 11? Windows 11 comes with a number of network profiles, which are essentially sets of settings that can be used to configure various network connections. This is useful if you have multiple connections at home or office so you don't have to set it all up every time you connect to a new network. Private and public network profiles are two common types in Windows 11, but generally

Recently, many Win10 system users want to change the user profile, but they don’t know how to do it. This article will show you how to set the user profile in Win10 system! How to set up user profile in Win10 1. First, press the "Win+I" keys to open the settings interface, and click to enter the "System" settings. 2. Then, in the opened interface, click "About" on the left, then find and click "Advanced System Settings". 3. Then, in the pop-up window, switch to the "" option bar and click "User Configuration" below.

The mysql host name refers to the name or IP address used to identify and access the mysql database server. When building and maintaining the mysql server, in order to remotely access the database on the server, the user needs to know the host name of the mysql server and ensure that the server has been correctly Configuration and firewall settings, using the correct connection string can connect and access the mysql server in the programming language.
