MYSQL主备复制结构搭建_MySQL
1 选择两个服务器,分别作为主备数据库
2 登陆到服务器,
yum install mysql ;
yum install mysql-server;
3 启动服务器
service mysqld start
4 分别root登陆mysql 执行如下命令,增加复制用户并授权(主备都在192.168.119.*网段,为了方便主备切换,两边都建立)
GRANT REPLICATION SLAVE,REPLICATION CLIENT on *.* to repl@'192.168.119.%' identified by '1234';
5 配置/etc/my.cnf
第一服务器(主)
log_bin=mysql_bin
server_id=1
第二个服务器(备)
log_bin=mysql_bin
server_id=2
read_only=1
6 登陆主(root)执行
show master status\G;
显示
File: mysql-bin.000001
Position: 106
登陆备(root) 执行
测试 mysql -urepl -h192.168.119.128 -p1234 是否能连接到主库,不能需要检查防火墙或者/etc/my.cnf是否有访问限制,修改配置
mysql -uroot登陆本地库执行:
CHANGE MASTER TO
MASTER_HOST='192.168.119.128',
MASTER_USER='repl',
MASTER_PASSWORD='1234',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=106;
start slave;
show slave status\G;
7,主库上创建表,备库上查看,可以看到
备库上repl创建表,显示The MySQL server is running with the --read-only option so it cannot execute this statement
因为配置了备库为read_only

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

Lambda expression is an anonymous function without a name, and its syntax is: (parameter_list)->expression. They feature anonymity, diversity, currying, and closure. In practical applications, Lambda expressions can be used to define functions concisely, such as the summation function sum_lambda=lambdax,y:x+y, and apply the map() function to the list to perform the summation operation.

The MySQL.proc table is a system table that stores stored procedure and function information in the MySQL database. By in-depth understanding of its structure and purpose, you can better understand the operating mechanism of stored procedures and functions in MySQL, and perform related management and optimization. The structure and purpose of the MySQL.proc table will be analyzed in detail below, and specific code examples will be provided. 1. The structure of the MySQL.proc table. The MySQL.proc table is a system table that stores the definitions and related information of all stored procedures and functions.

The basic structure and technology of the internet originated from ARPANET. ARPANET is a milestone in the development of computer network technology. Its research results have played an important role in promoting the development of network technology and laid the foundation for the formation of the Internet. Arpanet (Arpanet) was the world's first operational packet switching network developed by the U.S. Defense Advanced Research Projects Agency. It is the ancestor of the global Internet.

How to design the mall's evaluation table structure in MySQL? In a shopping mall system, evaluation is one of the most important functions. Evaluations can not only provide reference for other users, but also help merchants understand users’ feedback and opinions on products. Designing a reasonable evaluation form structure is crucial to the operation of the mall system and user experience. This article will introduce how to design the mall's evaluation table structure in MySQL and provide specific code examples. First, we need to create two basic tables: product table and user table. product list (product

How to use HTML and CSS to implement a layout with a fixed navigation menu. In modern web design, fixed navigation menus are one of the common layouts. It can keep the navigation menu always at the top or side of the page, allowing users to browse web content conveniently. This article will introduce how to use HTML and CSS to implement a layout with a fixed navigation menu, and provide specific code examples. First, you need to create an HTML structure to present the content of the web page and the navigation menu. Here is a simple example

There are four common flow control structures in Python, namely sequential structure, conditional structure, loop structure and jump structure. The following will introduce them one by one and provide corresponding code examples. Sequential structure: A sequential structure is a structure in which the program is executed in a predetermined order from top to bottom, without specific keywords or syntax. Sample code: print("This is the sequence structure example 1")print("This is the sequence structure example 2")print("This is the sequence structure example 2")

Title: Exploring the Internal Structure of the Linux File System The Linux operating system is famous for its stability and flexibility, and the file system, as one of its cores, plays a key role. An in-depth understanding of the internal structure of the Linux file system not only helps us understand the working principle of the operating system, but also helps us better manage and optimize the system. This article will explore the internal structure of the Linux file system with detailed code examples and explanations. 1. Introduction to file systems File systems are used by computers to organize and store files and to

Analysis of the basic structure of the Linux file system The Linux operating system uses the concept of a file system to manage data and resources. The file system is a system software in the operating system that is used to manage file organization and access on storage devices. In the Linux system, the file system is a hierarchical structure composed of several levels of directories. Files are organized through directories to achieve file management and access. This article will introduce the basic structure of the Linux file system and further analyze it through specific code examples. 1.Linux
