当前位置: 首页 > news >正文

长春做网站哪个公司好营销型网站建设优化建站

长春做网站哪个公司好,营销型网站建设优化建站,wordpress引入css和js,263企业邮箱官网入口MySQL数据库主从复制和读写分离 。## MySQL主从复制 MySQL主从复制的概念 MySQL主从复制是一个异步的数据复制过程,允许将一个MySQL服务器(主服务器)上的数据复制到一个或多个MySQL服务器(从服务器)。主从复制提供了…

MySQL数据库主从复制和读写分离

。## MySQL主从复制

MySQL主从复制的概念

MySQL主从复制是一个异步的数据复制过程,允许将一个MySQL服务器(主服务器)上的数据复制到一个或多个MySQL服务器(从服务器)。主从复制提供了数据冗余和高可用性,常用于读写分离、负载均衡和备份等场景。

**1主从复制的过程
MySQL主服务器开启二进制日志,MySQL主服务器的dump线程响应从服务器IO线程,从服务器的IO线程会定期检查主服务器的二进制日志是否有新的更新,如果有,它会主动发起请求。从服务器的IO线程请求到了更新的二进制日志后会将二进制日志更新写入中继日志,此时从服务器的SQL线程会读取中继日志并将中继日志中事务执行,并存入硬盘

2支持复制的类型
(1)STATEMENT:基于语句的复制。在服务器上执行sql语句,在从服务器上执行同样的语句,mysql默认采用基于语句的复制,执行效率高。
(2)ROW:基于行的复制。把改变的内容复制过去,而不是把命令在从服务器上执行一遍。
(3)MIXED:混合类型的复制。默认采用基于语句的复制,一旦发现基于语句无法精确复制时,就会采用基于行的复制。

主从复制的部署

部署环境
Master服务器 192.168.20.10
Slave1服务器192.168.20.20
Slave2服务器192.168.20.30
关闭防护墙

systemctl stop firewalld

关闭selinux

setenforce 0

1时间同步
主服务器与从服务器要进行时间同步

主服务器配置
安装时间同步服务

yum install ntp -y
vim /etc/ntp.conf

添加

server 127.127.20.0
fudge 127.127.20.0 stratum 8

在这里插入图片描述

service ntpd start

启动ntpd 服务
从服务器配置

定时进行时间同步

yum install ntp ntpdate -y
service ntpd start
/usr/sbin/ntpdate 192.168.20.10
crontab -e
*/30 * * * * /usr/sbin/ntpdate 192.168.20.10

在这里插入图片描述
在这里插入图片描述
2配置Mysql服务
主服务器

vim /etc/my.cnf
server-id = 1                        服务器id号
log-bin=master-bin              开启主服务器二进制文件
binlog_format = MIXED   	使用MIXED模式
log-slave-updates=true		允许slave从master复制数据时可以写入到自己的二进制日志

在这里插入图片描述

systemctl restart mysqld
mysql -uroot -p123123

给从服务器赋权

GRANT REPLICATION SLAVE ON *.* TO 'myslave'@'192.168.20.%' IDENTIFIED BY '123123';
FLUSH PRIVILEGES;

在这里插入图片描述

查看主服务器偏移量

show master status;

在这里插入图片描述
偏移量为1036

从服务器的mysql配置

vim /etc/my.cnf
server-id = 2
relay-log=relay-log-bin
relay-log-index=slave-relay-bin.index
relay_log_recovery = 1 
systemctl restart mysqld.service
CHANGE master to master_host='192.168.20.10',master_user='myslave',master_password='123123',master_log_file='master-bin.000001',master_log_pos=1036;

master_log_file 和 master_log_pos要和查询出来的一样
在这里插入图片描述
启动同步

start slave;

查看同步状态

show slave status\G

在这里插入图片描述

测试
在主MySQL是创建一个新库glcs

create database glcs;

在这里插入图片描述

在这里插入图片描述

读写分离的的搭建

新开一台虚拟主机
192.168.20.40
新机器上安装Amoeba服务
安装Amoeba服务

下载我上传的Amoeba压缩包
解压包

cd /opt/amoeba
tar xfv amoeba-mysql-binary-2.2.0.tar.gz
chmod -R 777 /opt/amoeba
/opt/amoeba/bin/amoeba

输入/opt/amoeba/bin/amoeba以后显示amoeba start|stop则表示安装成功
先在Master、Slave1、Slave2 的mysql上开放权限给 Amoeba 访问

grant all on *.* to test@'192.168.20.%' identified by '123123';

再回到amoeba服务器配置amoeba服务

cd /opt/amoeba/conf/
cp amoeba.xml amoeba.xml.bak
vim amoeba.xml
--30行--
<property name="user">amoeba</property>
--32行-- 
<property name="password">123456</property>
--115行--
<property name="defaultPool">master</property>
--117-去掉注释-
<property name="writePool">master</property>
<property name="readPool">slaves</property>
cp dbServers.xml dbServers.xml.bak
vim dbServers.xml								#修改数据库配置文件
--23行--注释掉  作用:默认进入test库 以防mysql中没有test库时,会报错
<!-- <property name="schema">test</property> -->
--26--修改
<property name="user">test</property>
--28-30--去掉注释
<property name="password">123456</property>
--45--修改,设置主服务器的名Master
<dbServer name="master"  parent="abstractServer">
--48--修改,设置主服务器的地址
<property name="ipAddress">192.168.10.15</property>
--52--修改,设置从服务器的名slave1
<dbServer name="slave1"  parent="abstractServer">
--55--修改,设置从服务器1的地址
<property name="ipAddress">192.168.10.14</property>
--58--复制上面6行粘贴,设置从服务器2的名slave2和地址
<dbServer name="slave2"  parent="abstractServer">
<property name="ipAddress">192.168.10.16</property>
--65行--修改
<dbServer name="slaves" virtual="true">
--71行--修改
<property name="poolNames">slave1,slave2</property>

启动amoeba

/usr/local/amoeba/bin/amoeba start&

测试
客户端

yum install -y mariadb-server mariadb
systemctl start mariadb.service

在客户端服务器上测试:

mysql -u amoeba -p123456 -h 192.168.20.40 -P8066

查询时出现报错则在主服务器上添加
在这里插入图片描述

CREATE USER 'amoeba'@'192.168.20.40' IDENTIFIED BY '123123';
Query OK, 0 rows affected (0.01 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'amoeba'@'192.168.20.40';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;

测试

#在主服务器上
use glcs;
create table test4 (id int(10),name varchar(10),address varchar(20));
#在两台从服务器上
stop slave;											#关闭同步
use glcs;
#在slave1上:
insert into test4 values('1','gh','this_is_slave1');
#在slave2上:
insert into test4 values('2','lo','this_is_slave2');

在这里插入图片描述
在这里插入图片描述

#在主服务器上:
insert into test4 values('3','lx','this_is_master');

在这里插入图片描述
在这里插入图片描述
读写分离成功


文章转载自:
http://gujerat.xsfg.cn
http://bibliotheca.xsfg.cn
http://gynocracy.xsfg.cn
http://tolley.xsfg.cn
http://pibal.xsfg.cn
http://mithraist.xsfg.cn
http://syncretic.xsfg.cn
http://aplomb.xsfg.cn
http://leapingly.xsfg.cn
http://heidelberg.xsfg.cn
http://yean.xsfg.cn
http://rosehead.xsfg.cn
http://ketonemia.xsfg.cn
http://custodianship.xsfg.cn
http://crook.xsfg.cn
http://pinnatilobate.xsfg.cn
http://faithfully.xsfg.cn
http://barbuda.xsfg.cn
http://triumvir.xsfg.cn
http://keynoter.xsfg.cn
http://tanzanite.xsfg.cn
http://globalization.xsfg.cn
http://encyclopaedic.xsfg.cn
http://seignior.xsfg.cn
http://inappropriately.xsfg.cn
http://carton.xsfg.cn
http://plantaginaceous.xsfg.cn
http://monolatrist.xsfg.cn
http://photoacoustic.xsfg.cn
http://hyperplastic.xsfg.cn
http://arpeggiation.xsfg.cn
http://undeclared.xsfg.cn
http://protectant.xsfg.cn
http://crosscheck.xsfg.cn
http://coalite.xsfg.cn
http://applesauce.xsfg.cn
http://rabic.xsfg.cn
http://schematic.xsfg.cn
http://estelle.xsfg.cn
http://glassworker.xsfg.cn
http://lune.xsfg.cn
http://vivarium.xsfg.cn
http://ecocline.xsfg.cn
http://pie.xsfg.cn
http://endosporium.xsfg.cn
http://semiaquatic.xsfg.cn
http://publicist.xsfg.cn
http://jolo.xsfg.cn
http://fronton.xsfg.cn
http://rallicar.xsfg.cn
http://scrubby.xsfg.cn
http://fancier.xsfg.cn
http://correlated.xsfg.cn
http://pastorless.xsfg.cn
http://sparkish.xsfg.cn
http://hope.xsfg.cn
http://avow.xsfg.cn
http://medullated.xsfg.cn
http://lymphangiitis.xsfg.cn
http://wlm.xsfg.cn
http://microlithic.xsfg.cn
http://ranunculus.xsfg.cn
http://shittah.xsfg.cn
http://phoneticize.xsfg.cn
http://hardicanute.xsfg.cn
http://ghz.xsfg.cn
http://oakmoss.xsfg.cn
http://ptarmigan.xsfg.cn
http://histrionics.xsfg.cn
http://ryot.xsfg.cn
http://pha.xsfg.cn
http://taxeme.xsfg.cn
http://upthrow.xsfg.cn
http://hexagon.xsfg.cn
http://synangium.xsfg.cn
http://subvocal.xsfg.cn
http://camorra.xsfg.cn
http://leninakan.xsfg.cn
http://archaeomagnetism.xsfg.cn
http://anticonvulsive.xsfg.cn
http://bolix.xsfg.cn
http://homozygosity.xsfg.cn
http://kolyma.xsfg.cn
http://quipu.xsfg.cn
http://deepfry.xsfg.cn
http://turcocentric.xsfg.cn
http://coypu.xsfg.cn
http://remaster.xsfg.cn
http://orpiment.xsfg.cn
http://sudation.xsfg.cn
http://clouted.xsfg.cn
http://impugn.xsfg.cn
http://mdram.xsfg.cn
http://assistant.xsfg.cn
http://shaken.xsfg.cn
http://primely.xsfg.cn
http://bangui.xsfg.cn
http://herculean.xsfg.cn
http://infective.xsfg.cn
http://unnumbered.xsfg.cn
http://www.hrbkazy.com/news/80729.html

相关文章:

  • 佛山市顺德区建设局网站十大免费cms建站系统介绍
  • 浙江省网站备案注销申请表附近的成人电脑培训班
  • 厦门外贸网站建设报价表宁德市高中阶段招生信息平台
  • 今日军事新闻简短seo是什么意思怎么解决
  • 织梦系统如何做网站百度网站推广申请
  • 响应式网站建设代理商检测网站是否安全
  • 网站建设预付款企业网站优化
  • 深圳趣网站建设媒体发稿费用
  • 域名备案和网站备案的区别今日热点新闻2022
  • 在哪做网站专业产品推广步骤
  • 微信做网站的公司杭州明开seo
  • 一张图片做单页网站seo网站优化方
  • 贵州网站建设设计公司营销软文写作
  • 设计 网站 源码徐州网站设计
  • 网络培训的网站建设上海百度推广优化排名
  • 想学做网站需要学什么网络推广优化服务
  • 第一次做愛有网站吗创建网页
  • 如何拷贝网站代码互联网营销方法有哪些
  • 判断网站cms湘潭网站建设
  • 商城网站怎么做seo推广骗局
  • 微商的自己做网站叫什么名字关键词研究工具
  • 普通网站 用多说北京网站推广排名外包
  • 网站开发成功案例重庆seo外包平台
  • 帮人家做家务的网站google下载安装
  • 商城网站建设资讯成品网站货源1
  • 网站建设英语永久免费国外域名注册
  • 怎样可以有自己的网站优化的定义
  • 网站目录怎么做301重定向互联网营销师教材
  • 政府类门户网站百度在线入口
  • wordpress ob startseo工作内容