当前位置:网站首页>Linux(Centos7)服务器中配置Mysql主从数据库,以及数据库的安装,防火墙操作
Linux(Centos7)服务器中配置Mysql主从数据库,以及数据库的安装,防火墙操作
2022-08-10 01:00:00 【借东西的小人儿】
一、Linux中mysql的安装方法
步骤一:
使用finallshell上传mysql的压缩包,版本如下:
步骤二:
使用linux命令解压mysql压缩包到指定文件夹,命令如下:
// -C后面为解压到的路径
tar -zxvf mysql-5.7.25-1.el7.x86_64.rpm-bundle.tar.gz -C /usr/local
步骤三:
进入到/usr/local/mysql文件夹,进行mysql的解压安装,解压顺序:
mysql文件夹下的内容:
解压顺序:
二、mysql的一些其他设置:
1.查看临时密码
2.修改临时密码
3.设置mysql的开机自启动
4.如果想要window或其他服务器可以连接mysql,则还需要关闭防火墙,或者让防火墙开放3306端口。
三、为了使虚拟机的ip地址固定,最好设置成静态
如何设置如下:
四、数据库安装完毕,开始配置主从库
4.1、配置主库
步骤一:
修改mysql的配置文件/etc/my.cnf(可以先用 yum install vim安装一下工具)
vi /etc/my.cnf
步骤二:
增加如下变量:
log-bin=mysql-bin #[必须]启用二进制日志
server-id=100 #[必须]服务器唯一ID(唯一即可)
如图
步骤三:
重启mysqld服务
systemctl restart mysqld
步骤四:
创建数据同步的用户并授权,就是说之后这个被授予了复制权利的slave用户才可以从master上进行复制
//登录master数据库
mysql -uroot -p
//创建用户并授权,这是mysql命令需在mysql命令行中使用
GRANT REPLICATION SLAVE ON *.* to 'xiaoming'@'%' identified by 'Root@123456';
步骤五:
查看master的状态,并且不再进行任何操作,防止位置改变
show master status
如图:
4.2配置从库
步骤一:
修改mysql的配置文件/etc/my.cnf
步骤二:
增加如下变量,从库不需要开启日志:
server-id=101 #[必须]服务器唯一ID(唯一即可)
如图:
步骤三:
重启mysqld服务:
systemctl restart mysqld
步骤四:
登录mysql:
//登录slave数据库
mysql -uroot -p
//设置主库位置以及同步位置,就是上面我圈的红圈
change master to master_host='192.168.200.200',master_user='xiaoming',master_password='Root@123456',master_log_file='mysql-bin.000006',master_log_pos=194;
步骤五:
查看slave的状态
show slave status
显示出两个yes表示成功:
五、遇到的NO的情况,以及如果slave服务器是从master克隆出来的解决办法
情况:Slave_IO_Running:NO
情况二:Slave_SQL_Running:NO
情况三:克隆问题
可能是UUID相同,需要更改或者直接删除
找到auto.cnf文件,删除或者修改,再重启mysql
边栏推荐
- 【kali-密码攻击】(5.1.2)密码在线破解:Medusa
- 基于SSM实现手机销售商城系统
- Chip Information|Semiconductor revenue growth expected to slow to 7%, Bluetooth chip demand still growing steadily
- 防勒索病毒现状分析
- 破产企业的职工退休怎么办?
- 惊掉你下巴,程序员编码竟然可以被 996 指数化
- hint: Updates were rejected because the tip of your current branch is behind hint: its remote counte
- 使用 apxs 构建和安装 Apache 扩展共享对象模块
- 分析 20 个 veToken 生态系统协议 这种代币模型为何受欢迎?
- C# 四舍五入 MidpointRounding.AwayFromZero
猜你喜欢

商业模式及其 SubDAO 深入研究

GBJ1510-ASEMI机器人电源整流桥GBJ1510

C language pointer practice questions

ABAP 里文件操作涉及到中文字符集的问题和解决方案

OpenSSF的开源软件风险评估工具:Scorecards

Pagoda measurement - building LightPicture open source map bed system
![[Turn] Typora_Markdown_ picture title (caption)](/img/67/589eed8de86bff9fc017ae7c409410.png)
[Turn] Typora_Markdown_ picture title (caption)

Chip Information|Semiconductor revenue growth expected to slow to 7%, Bluetooth chip demand still growing steadily

DALL·E-2是如何工作的以及部署自己的DALL·E模型

Initial attempt at UI traversal
随机推荐
Not, even the volume of the king to write code in the company are copying and pasting it reasonable?
shell指定参数名传参
OSS-访问oss生成的url无法访问,直接下载问题
-Pickling peanuts-
C language pointer practice questions
XSS详解及复现gallerycms字符长度限制短域名绕过
空间复杂度为O(1)的归并排序
Unity image is blurry after using long image
【Grpc】简介
el-input保留一位小数点
3438. 数制转换
hint: Updates were rejected because the tip of your current branch is behind hint: its remote counte
Problems and solutions related to Chinese character set in file operations in ABAP
-Chess game-
Data storage - the C language
unity编辑器扩展界面使用 List
color socks problem
OpenSSF的开源软件风险评估工具:Scorecards
R语言使用glm函数构建逻辑回归模型(logistic)、使用subgroupAnalysis函数进行亚组分析并可视化森林图
什么是持续测试?