一、安装MySQL
这里就详解,请度娘。
二、配置MySQL主服务器(10.241.226.110)
mysql -uroot -p #进入MySQL控制台
create database testdb; #建立数据库testdb
#授权用户mysqlcopy只能从10.241.226.111这个IP访问主服务器10.241.226.110上面的数据库,并且只具有数据库备份的权限
grant replication slave on *.* to 'mysqlcopy'@'10.241.226.111' identified by '123456' with grant option;
三、把MySQL主服务器10.241.226.110中的数据库testdb导入到MySQL从服务器10.241.226.111中
1、导出数据库testdb
mysqldump -u root -p testdb> /home/testdbbak.sql
备注:在导出之前可以先进入MySQL控制台执行下面命令
flush tables with read lock; #数据库只读锁定命令,防止导出数据库的时候有数据写入
unlock tables; #解除锁定
2、导入数据库到MySQL从服务器
mysql -u root -p #进入从服务器MySQL控制台
create databasetestdb; #创建数据库
usetestdb #进入数据库
source /home/testdbbak.sql #导入备份文件到数据库
mysql -u mysqlcopy-h10.241.226.110 -p #测试在从服务器上登录到主服务器
四、配置MySQL主服务器的my.cnf文件
1、vim /etc/my.cnf #编辑配置文件,在[mysqld]部分添加下面内容
log_bin=mysql-bin #启动MySQ二进制日志系统,注意:如果原来的配置文件中已经有这一行,就不用再添加了。 binlog-do-db=testdb #需要同步的数据库名,如果有多个数据库,可重复此参数,每个数据库一行 binlog-ignore-db=mysql #不同步mysql系统数据库 server_id = 1 #设置服务器id,为1表示主服务器,注意:如果原来的配置文件中已经有这一行,就不用再添加了。 socket =/var/lib/mysql/mysql.sock character-set-server=utf8
2、service mysqld restart #重启MySQL
3、mysql -u root -p #进入mysql控制台
4、show master status; 查看主服务器,出现以下类似信息
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 120 | testdb | mysql |
+------------------+----------+--------------+------------------+
注意:这里记住File的值:mysql-bin.000001和Position的值:120,后面会用到。
五、配置MySQL从服务器的my.cnf文件
1、vi /etc/my.cnf #编辑配置文件,在[mysqld]部分添加下面内容
log_bin=mysql-bin #启动MySQ二进制日志系统,注意:如果原来的配置文件中已经有这一行,就不用再添加了。 replicate-do-db=testdb replicate-ignore-db=mysql read_only=1 server_id = 2 #配置文件中已经有一行server-id=1,修改其值为2,表示为从数据库 socket = /var/lib/mysql/mysql.sock character-set-server=utf8
2、service mysqld restart #重启MySQL
3、mysql -u root -p #进入MySQL控制台
4、slave stop; #停止slave同步进程
5、change master to master_host='10.241.226.110',master_user='mysqlcopy',master_password='123456',master_log_file='mysql-bin.000001,master_log_pos=120; #执行同步语句
6、slave start; #开启slave同步进程
7、SHOW SLAVE STATUS\G #查看slave同步信息,部分内容如下:
*************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 10.241.226.111 Master_User: mysqlcopy Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 377 Relay_Log_File: localhost-relay-bin.000003 Relay_Log_Pos: 540 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: DB_CLOUDCORE 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: 377 Relay_Log_Space: 717 Until_Condition: None Until_Log_File:
注意查看:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
以上这两个参数的值为Yes,即说明配置成功!
六、测试MySQL主从服务器双机热备是否成功
1、进入MySQL主服务器
mysql -u root -p #进入主服务器MySQL控制台
use testdb; #进入数据库
CREATE TABLE test ( id int not null); #创建test表
2、进入MySQL从服务器
mysql -u root -p #进入MySQL控制台
usetestdb; #进入数据库
show tables;
会看到有一个新建的表test,表示数据库同步成功
问题:
1、ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'
解:由于mysql 默认的mysql.sock 是在/var/lib/mysql/mysql.sock,但linux系统总是去/tmp/mysql.sock查找,所以会报错
为mysql.sock增加软连接(相当于windows中的快捷方式)。
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

DHCP是“动态主机配置协议DynamicHostConfigurationProtocol”的首字母缩写词,它是一种网络协议,可自动为计算机网络中的客户端系统分配IP地址。它从DHCP池或在其配置中指定的IP地址范围分配客户端。虽然你可以手动为客户端系统分配静态IP,但DHCP服务器简化了这一过程,并为网络上的客户端系统动态分配IP地址。在本文中,我们将演示如何在RHEL9/RockyLinux9上安装和配置DHCP服务器。先决条件预装RHEL9或RockyLinux9具有sudo管理权限的普

一、安装nginx容器为了让nginx支持文件上传,需要下载并运行带有nginx-upload-module模块的容器:sudopodmanpulldocker.io/dimka2014/nginx-upload-with-progress-modules:latestsudopodman-d--namenginx-p83:80docker.io/dimka2014/nginx-upload-with-progress-modules该容器同时带有nginx-upload-module模块和ng

vue3项目打包发布到服务器后访问页面显示空白1、处理vue.config.js文件中的publicPath处理如下:const{defineConfig}=require('@vue/cli-service')module.exports=defineConfig({publicPath:process.env.NODE_ENV==='production'?'./':'/&

1,将java项目打成jar包这里我用到的是maven工具这里有两个项目,打包完成后一个为demo.jar,另一个为jst.jar2.准备工具1.服务器2.域名(注:经过备案)3.xshell用于连接服务器4.winscp(注:视图工具,用于传输jar)3.将jar包传入服务器直接拖动即可3.使用xshell运行jar包注:(服务器的java环境以及maven环境,各位请自行配置,这里不做描述。)cd到jar包路径下执行:nohupjava-jardemo.jar>temp.txt&

TCP客户端一个使用TCP协议实现可连续对话的客户端示例代码:importsocket#客户端配置HOST='localhost'PORT=12345#创建TCP套接字并连接服务器client_socket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)client_socket.connect((HOST,PORT))whileTrue:#获取用户输入message=input("请输入要发送的消息:&

scp是securecopy的简写,是linux系统下基于ssh登陆进行安全的远程文件拷贝命令。scp是加密的,rcp是不加密的,scp是rcp的加强版。因为scp传输是加密的,可能会稍微影响一下速度。另外,scp还非常不占资源,不会提高多少系统负荷,在这一点上,rsync就远远不及它了。虽然rsync比scp会快一点,但当小文件众多的情况下,rsync会导致硬盘I/O非常高,而scp基本不影响系统正常使用。场景:假设我现在有两台服务器(这里的公网ip和内网ip相互传都可以,当然用内网ip相互传

psutil是一个跨平台的Python库,它允许你获取有关系统进程和系统资源使用情况的信息。它支持Windows、Linux、OSX、FreeBSD、OpenBSD和NetBSD等操作系统,并提供了一些非常有用的功能,如:获取系统CPU使用率、内存使用率、磁盘使用率等信息。获取进程列表、进程状态、进程CPU使用率、进程内存使用率、进程IO信息等。杀死进程、发送信号给进程、挂起进程、恢复进程等操作。使用psutil,可以很方便地监控系统的运行状况,诊断问题和优化性能。以下是一个简单的示例,演示如何

一、安装前的准备工作在进行MySQL多实例的安装前,需要进行以下准备工作:准备多个MySQL的安装包,可以从MySQL官网下载适合自己环境的版本进行下载:https://dev.mysql.com/downloads/准备多个MySQL数据目录,可以通过创建不同的目录来支持不同的MySQL实例,例如:/data/mysql1、/data/mysql2等。针对每个MySQL实例,配置一个独立的MySQL用户,该用户拥有对应的MySQL安装路径和数据目录的权限。二、基于二进制包安装多个MySQL实例


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

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

WebStorm Mac version
Useful JavaScript development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Atom editor mac version download
The most popular open source editor