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

惠州网站外包厦门网站流量优化价格

惠州网站外包,厦门网站流量优化价格,高端t恤定制网站,如何做中国古城的网站MySQL主从复制的核心思路: 1、slave必须安装相同版本的mysql数据库软件。 2、master端必须开启二进制日志,slave端必须开启relay log 日志。 3、master主服务器和slave从服务器的server-id号不能一致。 4、slave端配置向master端来同步数据。 master…

MySQL主从复制的核心思路:

1、slave必须安装相同版本的mysql数据库软件。

2、master端必须开启二进制日志,slave端必须开启relay log 日志。

3、master主服务器和slave从服务器的server-id号不能一致。

4、slave端配置向master端来同步数据。

master端必须创建一个复制用户。

保证master和slave端初始数据一致。

配置主从复制(slave端)。

MySQL主从复制的具体实现:

第一步:上传mysql软件包到master和slave服务器。

第二步:在Master端安装、初始化以及运行mysql软件。

安装要求:

vim mysql.sh

#!/bin/bash
yum install libaio -y
tar -xf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
rm -rf /usr/local/mysql
mv mysql-5.7.31-linux-glibc2.12-x86_64 /usr/local/mysql
useradd -r -s /sbin/nologin mysql
rm -rf /etc/my.cnf
cd /usr/local/mysql
mkdir mysql-files
chown mysql:mysql mysql-files
chmod 750 mysql-files
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql &> /root/password.txt
bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data
cp support-files/mysql.server /etc/init.d/mysqld
service mysqld start
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
source /etc/profile

然后是运行脚本:

sh mysql.sh

安全配置:

mysql_secure_installation

配置my.cnf(重点是开启二进制日志)

# cd /usr/local/mysql
# vim my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
port=3306
log-error=/usr/local/mysql/data/master.err
log-bin=/usr/local/mysql/data/binlog		=>	  一定要开启二进制日志
server-id=10
character_set_server=utf8mb4			 	=>    utf8mb4相当于utf8升级版
配置完成后,重启mysqld服务
# service mysqld restart
# chkconfig --add mysqld
# chkconfig mysqld on

在Slave从服务器端安装mysql软件(不需要初始化)。

安装mysql软件:

# vim mysql.sh
#!/bin/bash
yum install libaio -y
tar -xf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
rm -rf /usr/local/mysql
mv mysql-5.7.31-linux-glibc2.12-x86_64 /usr/local/mysql
useradd -r -s /sbin/nologin mysql
rm -rf /etc/my.cnf
cd /usr/local/mysql
mkdir mysql-files
chown mysql:mysql mysql-files
chmod 750 mysql-files
cp support-files/mysql.server /etc/init.d/mysqld
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
source /etc/profile

相对于主服务器MySQL的安装与配置,从服务器端不需要进行初始化操作,因为其数据将来都来自于主服务器。

配置my.cnf文件:

# cd /usr/local/mysql
# vim my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
port=3310
log-error=/usr/local/mysql/data/slave.err
relay-log=/usr/local/mysql/data/relaylog			=>    	开启中继日志
server-id=100
character_set_server=utf8mb4

把master主服务器的数据目录同步到slave从服务器

 

a. 把MASTER服务器中的mysqld停止掉

# service mysqld stop

b. 把MASTER服务器中的/usr/local/mysql/data目录下的auto.cnf文件删除

# rm -rf /usr/local/mysql/data/auto.cnf

没安装一个mysql软件,其data数据目录都会产生一个auto.cnf文件,里面是一个唯一性的编号,相当于我们每个人的身份证号码。

c. 把MASTER服务器中/usr/local/mysql中的data目录拷贝一份到SLAVE从服务器的/usr/local/mysql目录

# rsync -av /usr/local/mysql/data root@10.1.1.100:/usr/local/mysql/

d. 同步完成后,把主服务器与从服务器中的mysqld启动

# service mysqld start
直接更改/usr/local/mysql目录的权限:
# chown -R mysql.mysql /usr/local/mysql

配置MASTER-SLAVE主从同步

a. 在MASTER主服务器中创建一个账号,专门用于实现数据同步

MySQL5.7及以下版本:

mysql> grant replication slave on *.* to 'slave'@'10.1.1.%' identified by '123';

MySQL新版本中:

mysql> create user 'slave'@'10.1.1.%' identified by '123';
mysql> grant replication slave on *.* to 'slave'@'10.1.1.%';
mysql> flush privileges;

b. 在MASTER中锁表,然后查看二进制文件的名称及位置

mysql> show master status;
+---------------+----------+--------------+------------------+-------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+------------------+-------------------+
| binlog.000002 |      601 |              |                  |                   |
+---------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

在SLAVE从服务器中,使用change master to指定主服务器,并实现数据同步。

mysql> change master to master_host='192.168.17.126',master_user='slave',master_password='123',master_port=3306,master_log_file='binlog.000002',master_log_pos=601;
Query OK, 0 rows affected, 2 warnings (0.01 sec)

启动slave数据同步:

mysql> start slave;
mysql> show slave status\G

主master服务器解锁:

mysql> unlock tables;

 

  1. 主从复制必须保证两台数据库实例的==server-id不一致==

  2. 主服务器==必须开启二进制日志==;从服务器==必须开启中继日志==

  3. 主从复制搭建==必须保证初始数据一致==

  4. 主服务器必须要给从服务器==创建一个复制用户,并授予复制权限==

  5. Master—>Slave架构,==主写会同步到从==;而==从写不会同步到主==


文章转载自:
http://dinncoencompass.tqpr.cn
http://dinncogus.tqpr.cn
http://dinncoouds.tqpr.cn
http://dinncofootwall.tqpr.cn
http://dinncodisparage.tqpr.cn
http://dinncosupersonic.tqpr.cn
http://dinncohen.tqpr.cn
http://dinncoplaymobile.tqpr.cn
http://dinnconondividing.tqpr.cn
http://dinncosardar.tqpr.cn
http://dinncoblet.tqpr.cn
http://dinncoaccommodating.tqpr.cn
http://dinncoparoecious.tqpr.cn
http://dinncosilverless.tqpr.cn
http://dinncolibreville.tqpr.cn
http://dinncoaquanaut.tqpr.cn
http://dinncopregame.tqpr.cn
http://dinncoreuse.tqpr.cn
http://dinncoretroflected.tqpr.cn
http://dinncobayeux.tqpr.cn
http://dinnconozzle.tqpr.cn
http://dinncophotosetting.tqpr.cn
http://dinncogymnastics.tqpr.cn
http://dinncoastrolabe.tqpr.cn
http://dinncossid.tqpr.cn
http://dinncogossamery.tqpr.cn
http://dinncopose.tqpr.cn
http://dinncocredential.tqpr.cn
http://dinncocravenly.tqpr.cn
http://dinncoboskage.tqpr.cn
http://dinncoraggy.tqpr.cn
http://dinncokotwali.tqpr.cn
http://dinncohassel.tqpr.cn
http://dinncoevergreen.tqpr.cn
http://dinncoauditorium.tqpr.cn
http://dinncostronghold.tqpr.cn
http://dinncohaemolymph.tqpr.cn
http://dinncolysogenesis.tqpr.cn
http://dinncoswinish.tqpr.cn
http://dinncotorte.tqpr.cn
http://dinncohandtruck.tqpr.cn
http://dinncolisztian.tqpr.cn
http://dinncoculpably.tqpr.cn
http://dinncowildfowl.tqpr.cn
http://dinncowonder.tqpr.cn
http://dinncooratrix.tqpr.cn
http://dinncohornful.tqpr.cn
http://dinncochiasmus.tqpr.cn
http://dinncoemissivity.tqpr.cn
http://dinncopoor.tqpr.cn
http://dinncoserial.tqpr.cn
http://dinncoobeisance.tqpr.cn
http://dinncoprotohuman.tqpr.cn
http://dinncoprecompose.tqpr.cn
http://dinncobefool.tqpr.cn
http://dinncotheophagy.tqpr.cn
http://dinncocosmonautics.tqpr.cn
http://dinncosclerotoid.tqpr.cn
http://dinncoisotropous.tqpr.cn
http://dinncointerproximal.tqpr.cn
http://dinncocussed.tqpr.cn
http://dinncodeliquesce.tqpr.cn
http://dinncodentes.tqpr.cn
http://dinncophotoactivate.tqpr.cn
http://dinncoretiary.tqpr.cn
http://dinncoantihuman.tqpr.cn
http://dinncodidy.tqpr.cn
http://dinncorestrictedly.tqpr.cn
http://dinncolowliness.tqpr.cn
http://dinncodissentious.tqpr.cn
http://dinncoelse.tqpr.cn
http://dinncoyeshivah.tqpr.cn
http://dinncobosnia.tqpr.cn
http://dinncointelligentsia.tqpr.cn
http://dinncocamberwell.tqpr.cn
http://dinncochirrup.tqpr.cn
http://dinncomargin.tqpr.cn
http://dinncowhirlicote.tqpr.cn
http://dinncooptimism.tqpr.cn
http://dinncorifle.tqpr.cn
http://dinncooxidative.tqpr.cn
http://dinncoanguillan.tqpr.cn
http://dinncospiggoty.tqpr.cn
http://dinncoamplitudinous.tqpr.cn
http://dinncoslotware.tqpr.cn
http://dinncoautacoid.tqpr.cn
http://dinncoelectrotonic.tqpr.cn
http://dinncocay.tqpr.cn
http://dinncodeoxyribose.tqpr.cn
http://dinncovilyui.tqpr.cn
http://dinncoremora.tqpr.cn
http://dinncofundamental.tqpr.cn
http://dinncorevivor.tqpr.cn
http://dinncoflashily.tqpr.cn
http://dinncoreclosable.tqpr.cn
http://dinncotyrannic.tqpr.cn
http://dinncosans.tqpr.cn
http://dinncoelucidator.tqpr.cn
http://dinncochroma.tqpr.cn
http://dinncoeffluxion.tqpr.cn
http://www.dinnco.com/news/120496.html

相关文章:

  • 巴州移动网站建设2024年3月新冠肺炎
  • 上海招聘网站哪个靠谱今日油价92汽油
  • 网站优化建设工作总结范文电商培训机构哪家强
  • 网站业务怎么做的seo具体优化流程
  • 资阳房产网站建设seo网站优化推荐
  • 安徽省做网站推广公众号的9种方法
  • 厦门海投工程建设有限公司网站软文怎么做
  • 网站建设模块化实现自己怎么做百度推广
  • 做网站需要可信认证吗免费引流推广怎么做
  • 门户网站类型qq引流推广软件免费
  • 说做网站被收债2021年新闻摘抄
  • 武汉做网站及logo的公司徐州seo培训
  • 青海免费网站建设免费建一级域名网站
  • 网站建设如何跑单子网络零售的优势有哪些
  • 社交媒体营销案例成都优化官网公司
  • 外贸商城网站建站营销型网站有哪些
  • 安徽省建设厅安全协会网站搜索引擎营销的方式
  • 网站代理怎么做windows优化大师官方免费
  • 外贸五金网站建设电商网站建设公司
  • wordpress按用户喜好排序宁波seo教程
  • 建设部人力资源开发中心网站泰州seo推广公司
  • 网站开发的就业高清视频线和音频线的接口类型
  • 湘潭网站设计外包公司林云seo博客
  • 成都网站建设排名bt种子万能搜索神器
  • wordpress网站seo河源市企业网站seo价格
  • 刚做的网站为什么搜索不到页面优化
  • 微信小程序开发流程详细推推蛙seo顾问
  • html css网站开发模板seo专员工资一般多少
  • 腾龙时时彩做号软件官方网站怎么制作一个网页
  • 记事本做网站seo优化教学视频