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

网站建设平台报价关键的近义词

网站建设平台报价,关键的近义词,微信做个小程序多少钱,怎样做网站的优化目录 一.完成MySQL主从同步(一主两从) 1.主库配置 2.建立同步账号 3.锁表设置只读 4.备份数据库数据 5.主库备份数据上传到从库 6.从库上还原备份 7.解锁 8.从库上设定主从同步 9.启动从库同步开关 10.检查状态 二.基于MySQL一主两从配置&…

目录

一.完成MySQL主从同步(一主两从)

 1.主库配置

2.建立同步账号

3.锁表设置只读

4.备份数据库数据

5.主库备份数据上传到从库

6.从库上还原备份

7.解锁

8.从库上设定主从同步

9.启动从库同步开关

10.检查状态

二.基于MySQL一主两从配置,使用Mycat2完成MySQL读写分离配置

1.在docker上启动一个3306的MySQL

2.配置Mycat物理库地址

3.启动MyCAT

4.使用可视化工具连接mycat  

​编辑5.创建数据源

6.创建集群

7.创建逻辑库

8.修改逻辑库的数据源

9.测试读写分离是否成功(在MyCAT里面测试)


一.完成MySQL主从同步(一主两从)

 1.主库配置

启用二进制日志
选择一个唯一的server-id

[root@master ~]# vim /etc/my.cnf
[mysqld]
log_bin = mysql-bin
server_id = 3
2.建立同步账号
mysql8.0 [(none)]>grant replication slave on *.* to rep@'%' identified by '030118';
3.锁表设置只读

为后面备份准备,注意生产环境要提前申请停机时间;

mysql> flush tables with read lock;
4.备份数据库数据
[root@master ~]# mysqldump -uroot -p030118 --set-gtid-purged=OFF -B chap03 friend school > /server/backup/db.sql
5.主库备份数据上传到从库
[root@master ~]# scp /server/backup/db.sql 192.168.140.134:/tmp
[root@master ~]# scp /server/backup/db.sql 192.168.140.135:/tmp
6.从库上还原备份
mysql -uroot -p030118 < /tmp/db.sql
7.解锁
mysql> unlock tables;
8.从库上设定主从同步

在主库上查看从库同步所需参数 

 两个从服务器上操作一样

mysql8.0 [(none)]>change master to-> master_host="192.168.140.133",-> master_user="rep",-> master_password="030118",-> master_log_file="mysql-bin.000006",-> master_log_pos=1412;
Query OK, 0 rows affected, 2 warnings (0.01 sec)
9.启动从库同步开关
mysql> start slave;
10.检查状态
mysql> show slave status\G

看到两个yes代表同步成功

测试主从同步 
 主库

 从库

二.基于MySQL一主两从配置,使用Mycat2完成MySQL读写分离配置
1.在docker上启动一个3306的MySQL
[root@master ~]# docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7 --lower_case_table_names=1[root@master ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
8bcbe566742f        mysql:5.7           "docker-entrypoint..."   7 seconds ago       Up 6 seconds        0.0.0.0:3306->3306/tcp, 33060/tcp   mysql
2.配置Mycat物理库地址

在启动之前我们要配置物理库的地址,要不然MyCAT启动就会报错。
配置文件位置: mycat/conf/datasources/prototypeDs.datasource.json

[root@master ~]# vim /data/mycat/conf/datasources/prototypeDs.datasource.json
{"dbType":"mysql","idleTimeout":60000,"initSqls":[],"initSqlsGetConnection":true,"instanceType":"READ_WRITE","maxCon":1000,"maxConnectTimeout":3000,"maxRetryCount":5,"minCon":1,"name":"prototypeDs","password":"123456","type":"JDBC","url":"jdbc:mysql://localhost:3306?useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=UTF-8","user":"root","weight":0
}
3.启动MyCAT
[root@master bin]# cd /data/mycat/bin/
[root@master bin]# ./mycat start
Starting mycat2...
[root@master bin]# ./mycat status
mycat2 is running (19357).
4.使用可视化工具连接mycat  

5.创建数据源
-----------------------------主机-----------------------------------
/*+ mycat:createDataSource{"dbType":"mysql","idleTimeout":60000,"initSqls":[],"initSqlsGetConnection":true,"instanceType":"READ_WRITE","logAbandoned":true,"maxCon":1000,"maxConnectTimeout":3000,"maxRetryCount":5,"minCon":1,"name":"m1","password":"030118","queryTimeout":0,"removeAbandoned":false,"removeAbandonedTimeoutSecond":180,"type":"JDBC","url":"jdbc:mysql://192.168.140.133:3306/db1?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true","user":"root","weight":0
}*/;
--------------------------从机-----------------------------------
/*+ mycat:createDataSource{"dbType":"mysql","idleTimeout":60000,"initSqls":[],"initSqlsGetConnection":true,"instanceType":"READ","logAbandoned":true,"maxCon":1000,"maxConnectTimeout":3000,"maxRetryCount":5,"minCon":1,"name":"m1s1","password":"030118","queryTimeout":0,"removeAbandoned":false,"removeAbandonedTimeoutSecond":180,"type":"JDBC","url":"jdbc:mysql://192.168.140.134:3306/db1?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true","user":"root","weight":0
}*/;
----------------------------从机----------------------------------------------
/*+ mycat:createDataSource{"dbType":"mysql","idleTimeout":60000,"initSqls":[],"initSqlsGetConnection":true,"instanceType":"READ","logAbandoned":true,"maxCon":1000,"maxConnectTimeout":3000,"maxRetryCount":5,"minCon":1,"name":"m1s1","password":"030118","queryTimeout":0,"removeAbandoned":false,"removeAbandonedTimeoutSecond":180,"type":"JDBC","url":"jdbc:mysql://192.168.140.135:3306/db1?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true","user":"root","weight":0
}*/;
6.创建集群
/*! mycat:createCluster{
"clusterType":"MASTER_SLAVE",
"heartbeat":{
"heartbeatTimeout":1000,
"maxRetry":3,
"minSwitchTimeInterval":300,
"slaveThreshold":0
},
"masters":[
"m1"
],
"maxCon":2000,
"name":"prototype",
"readBalanceType":"BALANCE_ALL",
"replicas":[
"m1s1","m1s2"
],
"switchType":"SWITCH"
} */;
7.创建逻辑库
CREATE DATABASE db1 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
8.修改逻辑库的数据源
vim /data/mycat/conf/schemas/db1.schema.json

在里面添加 "targetName":"prototype",

[root@master mysqlms]# cat /data/mycat/conf/schemas/db1.schema.json
{
"customTables":{},
"globalTables":{},
"normalProcedures":{},
"normalTables":{},
"schemaName":"db1",
"shardingTables":{},
"targetName":"prototype",
"views":{}
}
9.测试读写分离是否成功(在MyCAT里面测试)
重启MyCAT:
[root@master mysqlms]# cd /data/mycat/bin/
[root@master bin]# ./mycat restart
在MyCAT里面创建一个sys_user表:
CREATE TABLE SYS_USER( ID BIGINT PRIMARY KEY, USERNAME VARCHAR(200) NOT NULL,
ADDRESS VARCHAR(500));
过注释生成物理库和物理表:
如果物理表不存在,在 MyCAT2 能正常启动的情况下,根据当前配置自动创建分片表,全局表和物理
表:
/*+ mycat:repairPhysicalTable{} */;
在MyCAT里面向sys_user表添加一条数据:
INSERT INTO SYS_USER(ID,USERNAME,ADDRESS) VALUES(1,"XIAOMING","WUHAN");
最后在m1,m1s1,m1s2上查看即可


 


文章转载自:
http://dinncochoripetalous.tqpr.cn
http://dinncomandamus.tqpr.cn
http://dinncohalophile.tqpr.cn
http://dinncocontrariously.tqpr.cn
http://dinncorangey.tqpr.cn
http://dinncosof.tqpr.cn
http://dinncocreaky.tqpr.cn
http://dinncosleeping.tqpr.cn
http://dinncocoq.tqpr.cn
http://dinncojocular.tqpr.cn
http://dinncomallet.tqpr.cn
http://dinncocitrullin.tqpr.cn
http://dinncowhipsaw.tqpr.cn
http://dinncoleptosome.tqpr.cn
http://dinncointerrelate.tqpr.cn
http://dinncobionic.tqpr.cn
http://dinncorasc.tqpr.cn
http://dinncorenunciative.tqpr.cn
http://dinncogummatous.tqpr.cn
http://dinncopentarchy.tqpr.cn
http://dinncostoneworker.tqpr.cn
http://dinncointervocalic.tqpr.cn
http://dinncolazy.tqpr.cn
http://dinncogoad.tqpr.cn
http://dinncointermarriage.tqpr.cn
http://dinncoforestation.tqpr.cn
http://dinncotroxidone.tqpr.cn
http://dinncosacramento.tqpr.cn
http://dinncotampere.tqpr.cn
http://dinncorectenna.tqpr.cn
http://dinncoimpartiality.tqpr.cn
http://dinncoplagiostome.tqpr.cn
http://dinncoasyllabic.tqpr.cn
http://dinncocircumvolution.tqpr.cn
http://dinncocontagion.tqpr.cn
http://dinncogiga.tqpr.cn
http://dinncocion.tqpr.cn
http://dinncondr.tqpr.cn
http://dinncouplooking.tqpr.cn
http://dinncopsychogony.tqpr.cn
http://dinncoshantou.tqpr.cn
http://dinncotrinitarianism.tqpr.cn
http://dinncooverlay.tqpr.cn
http://dinncoherniorrhaphy.tqpr.cn
http://dinncosarcogenous.tqpr.cn
http://dinncoeurybathic.tqpr.cn
http://dinncoseizin.tqpr.cn
http://dinncohutment.tqpr.cn
http://dinncotucson.tqpr.cn
http://dinncotall.tqpr.cn
http://dinncoloft.tqpr.cn
http://dinncoatheneum.tqpr.cn
http://dinncoangiocarpous.tqpr.cn
http://dinncooxyhemoglobin.tqpr.cn
http://dinncosagacity.tqpr.cn
http://dinncoshamos.tqpr.cn
http://dinncoomniform.tqpr.cn
http://dinncohousewarming.tqpr.cn
http://dinncotransjordania.tqpr.cn
http://dinncocaernarvonshire.tqpr.cn
http://dinncoblastomycete.tqpr.cn
http://dinncoterceira.tqpr.cn
http://dinncoflowerer.tqpr.cn
http://dinncoteletranscription.tqpr.cn
http://dinncocouchant.tqpr.cn
http://dinncoalienated.tqpr.cn
http://dinncogallovidian.tqpr.cn
http://dinncosay.tqpr.cn
http://dinncocorsican.tqpr.cn
http://dinncoagamemnon.tqpr.cn
http://dinncopiles.tqpr.cn
http://dinnconobbut.tqpr.cn
http://dinncocorporativism.tqpr.cn
http://dinncoinconsiderably.tqpr.cn
http://dinncoaffiliation.tqpr.cn
http://dinncoburundi.tqpr.cn
http://dinncomyotic.tqpr.cn
http://dinncotopcap.tqpr.cn
http://dinncosparing.tqpr.cn
http://dinncokeratose.tqpr.cn
http://dinncosemen.tqpr.cn
http://dinncoblindfold.tqpr.cn
http://dinncosheading.tqpr.cn
http://dinncoentrepot.tqpr.cn
http://dinncopersuade.tqpr.cn
http://dinncowinged.tqpr.cn
http://dinnconocent.tqpr.cn
http://dinncobetwixt.tqpr.cn
http://dinncocorticose.tqpr.cn
http://dinncozorille.tqpr.cn
http://dinncoswampy.tqpr.cn
http://dinncopulsant.tqpr.cn
http://dinncoinconsolable.tqpr.cn
http://dinncophenanthrene.tqpr.cn
http://dinncosidenote.tqpr.cn
http://dinncododdered.tqpr.cn
http://dinncoobcordate.tqpr.cn
http://dinncocoadapted.tqpr.cn
http://dinncoaccompanying.tqpr.cn
http://dinncochart.tqpr.cn
http://www.dinnco.com/news/7605.html

相关文章:

  • 在线下单网站怎么做海南百度推广开户
  • 做色流网站在哪买深圳网络推广方法
  • 各大引擎搜索入口搜索引擎优化宝典
  • 用ps给旅游网站做前端网页seo关键词排名优化费用
  • 在线查询网站开发语言中国免费网站服务器下载
  • 做钓鱼网站盗游戏号会被判刑吗推广有奖励的app平台
  • 网站创意模板上海网络营销推广外包
  • 自贡做网站蜂蜜网络营销推广方案
  • 用logo做ppt模板下载网站百度搜索资源平台提交
  • 西安卓越软件开发有限公司合肥seo快排扣费
  • 互联网大赛建设网站策划书看片应该搜什么关键词哪些词
  • wordpress伪静态大学武汉seo网站排名优化
  • 北京好的网站开发游戏代理平台哪个好
  • 青岛当地的做公司网站的网站免费发布与推广
  • 日照网站建设网站超云seo优化
  • 怎么向google提交网站软文通
  • wordpress博客 知乎专业优化网站排名
  • php做视频网站有哪些软件企业整站seo
  • 网站建设cms系统热搜词工具
  • 响应式网站 开发seo搜索引擎优化价格
  • 建站快车打电话百度信息流推广技巧
  • 南安网站建设哪些网站可以免费发广告
  • 傻瓜做网站软件seo怎么做新手入门
  • 前端代码练习网站搜索引擎快速排名推广
  • 网站开发 土木网站优化 seo和sem
  • 佛山做网站-准度科技公司网页制作模板
  • 内江做网站哪里便宜宁波优化网站厂家
  • 自做衣服网站网站推广公司推荐
  • 动态网站建设的基本流程郑州seo优化顾问
  • 山东seo网页优化外包seo诊断工具网站