最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Docker mysql 主從配置詳解及實(shí)例

 更新時(shí)間:2016年11月23日 10:09:15   作者:來(lái)自地球的外星人  
這篇文章主要介紹了Docker mysql 主從配置詳解及實(shí)例的相關(guān)資料,需要的朋友可以參考下

Docker mysql 主從配置

1、首先創(chuàng)建兩個(gè)文件my-m.cnf(主庫(kù)配置) 、my-s.cnf(從庫(kù)配置)

my-m.cnf 內(nèi)容如下

# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#
# The MySQL Community Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[client]
port    = 3306
socket   = /var/run/mysqld/mysqld.sock

[mysqld_safe]
pid-file  = /var/run/mysqld/mysqld.pid
socket   = /var/run/mysqld/mysqld.sock
nice    = 0

[mysqld]
user    = mysql
pid-file  = /var/run/mysqld/mysqld.pid
socket   = /var/run/mysqld/mysqld.sock
port    = 3306
basedir   = /usr
datadir   = /var/lib/mysql
tmpdir   = /tmp
lc-messages-dir = /usr/share/mysql
explicit_defaults_for_timestamp

log-bin = mysql-bin 
server-id = 1 

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address  = 127.0.0.1

#log-error = /var/log/mysql/error.log

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# * IMPORTANT: Additional settings that can override those from this file!
#  The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/

主要是這兩行,只需要在原來(lái)的配置里面加上就行

log-bin = mysql-bin
server-id = 1

my-s.cnf 內(nèi)容如下

# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#
# The MySQL Community Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[client]
port    = 3306
socket   = /var/run/mysqld/mysqld.sock

[mysqld_safe]
pid-file  = /var/run/mysqld/mysqld.pid
socket   = /var/run/mysqld/mysqld.sock
nice    = 0

[mysqld]
user    = mysql
pid-file  = /var/run/mysqld/mysqld.pid
socket   = /var/run/mysqld/mysqld.sock
port    = 3306
basedir   = /usr
datadir   = /var/lib/mysql
tmpdir   = /tmp
lc-messages-dir = /usr/share/mysql
explicit_defaults_for_timestamp

log-bin = mysql-bin 
server-id = 2

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address  = 127.0.0.1

#log-error = /var/log/mysql/error.log

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# * IMPORTANT: Additional settings that can override those from this file!
#  The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/

同樣,主要的是這兩行

log-bin = mysql-bin
server-id = 2

2、OK,有了配置文件,就可以啟動(dòng)MySQL了,先啟動(dòng)主庫(kù)

$ docker run -d -e MYSQL_ROOT_PASSWORD=admin --name mysql-master -v /soft/my-m.cnf:/etc/mysql/my.cnf -p 3307:3306 mysql

3、啟動(dòng)從庫(kù)

$ docker run -d -e MYSQL_ROOT_PASSWORD=admin --name mysql-slave -v /soft/my-s.cnf:/etc/mysql/my.cnf -p 3308:3306 mysql

4、連接主庫(kù),并運(yùn)行以下命令,創(chuàng)建一個(gè)用戶用來(lái)同步數(shù)據(jù)

$ GRANT REPLICATION SLAVE ON *.* to 'backup'@'%' identified by '123456';

5、查看主庫(kù)狀態(tài)

$ show master status;

記住File、Position的值,如果沒(méi)查到數(shù)據(jù),請(qǐng)檢查第一、第二步,配置問(wèn)題。
我查出來(lái)的是mysql-bin.000004、312

6、連接到從庫(kù),運(yùn)行以下命令,設(shè)置主庫(kù)鏈接

$ change master to master_host='121.32.32.54',master_user='backup',master_password='123456',
master_log_file='mysql-bin.000004',master_log_pos=312,master_port=3307;

7、啟動(dòng)同步

$ start slave;

8、查看同步狀態(tài)

$ show slave status

如果看到Waiting for master send event.. 什么的就成功了,你現(xiàn)在在主庫(kù)上的修改,都會(huì)同步到從庫(kù)上

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

  • Ubuntu10下如何搭建MySQL Proxy讀寫(xiě)分離探討

    Ubuntu10下如何搭建MySQL Proxy讀寫(xiě)分離探討

    MySQL Proxy是一個(gè)處于你的Client端和MySQL server端之間的簡(jiǎn)單程序,它可以監(jiān)測(cè)、分析或改變它們的通信
    2012-11-11
  • MySQL數(shù)據(jù)庫(kù)如何查看表占用空間大小

    MySQL數(shù)據(jù)庫(kù)如何查看表占用空間大小

    由于數(shù)據(jù)太大了,所以MYSQL需要瘦身,那前提就是需要知道每個(gè)表占用的空間大小,這篇文章主要給大家介紹了關(guān)于MySQL數(shù)據(jù)庫(kù)如何查看表占用空間大小的相關(guān)資料,需要的朋友可以參考下
    2022-06-06
  • 詳解如何對(duì)MySQL數(shù)據(jù)庫(kù)進(jìn)行授權(quán)管理

    詳解如何對(duì)MySQL數(shù)據(jù)庫(kù)進(jìn)行授權(quán)管理

    MySQL數(shù)據(jù)授權(quán)是指數(shù)據(jù)庫(kù)管理員通過(guò)設(shè)置權(quán)限,控制用戶對(duì)數(shù)據(jù)庫(kù)中的數(shù)據(jù)的訪問(wèn)和操作能力,在MySQL中,每個(gè)用戶賬戶都有特定的權(quán)限,本文給大家介紹了如何對(duì)MySQL數(shù)據(jù)庫(kù)進(jìn)行授權(quán)管理,需要的朋友可以參考下
    2024-11-11
  • Win10安裝MySQL8壓縮包版的教程

    Win10安裝MySQL8壓縮包版的教程

    這篇文章主要介紹了Win10安裝MySQL8壓縮包版的教程,本文通過(guò)圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-04-04
  • 詳談mysql order by in 的字符順序(推薦)

    詳談mysql order by in 的字符順序(推薦)

    下面小編就為大家?guī)?lái)一篇詳談mysql order by in 的字符順序(推薦)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-04-04
  • mysql初始化命令mysqld?--initialize參數(shù)說(shuō)明小結(jié)

    mysql初始化命令mysqld?--initialize參數(shù)說(shuō)明小結(jié)

    本文主要介紹了mysql初始化命令mysqld?--initialize參數(shù)說(shuō)明小結(jié),文中通過(guò)圖表代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2024-08-08
  • MySQL命令無(wú)法輸入中文問(wèn)題的解決方式

    MySQL命令無(wú)法輸入中文問(wèn)題的解決方式

    這篇文章主要給大家介紹了關(guān)于MySQL命令無(wú)法輸入中文問(wèn)題的解決方式,文中給出了詳細(xì)的解決方案,對(duì)遇到這個(gè)問(wèn)題的同學(xué)有很大的幫助,需要的朋友可以參考下
    2021-08-08
  • Mysql5.7并發(fā)插入死鎖問(wèn)題解決

    Mysql5.7并發(fā)插入死鎖問(wèn)題解決

    死鎖是數(shù)據(jù)庫(kù)并發(fā)控制中的一種現(xiàn)象,它涉及多個(gè)事務(wù)在執(zhí)行過(guò)程中相互等待對(duì)方占有的資源,導(dǎo)致無(wú)法繼續(xù)執(zhí)行,本文就來(lái)介紹一下Mysql5.7并發(fā)插入死鎖問(wèn)題解決,感興趣的可以了解一下
    2024-09-09
  • 關(guān)于mysql innodb count(*)速度慢的解決辦法

    關(guān)于mysql innodb count(*)速度慢的解決辦法

    innodb引擎在統(tǒng)計(jì)方面和myisam是不同的,Myisam內(nèi)置了一個(gè)計(jì)數(shù)器,所以在使用 select count(*) from table 的時(shí)候,直接可以從計(jì)數(shù)器中取出數(shù)據(jù)。而innodb必須全表掃描一次方能得到總的數(shù)量
    2012-12-12
  • MAC下Mysql5.7.10版本修改root密碼的方法

    MAC下Mysql5.7.10版本修改root密碼的方法

    這篇文章主要介紹了MAC下Mysql5.7.10版本修改root密碼的方法,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2017-03-03

最新評(píng)論

沭阳县| 云和县| 福海县| 江城| 会理县| 广饶县| 台北市| 淮滨县| 张掖市| 星子县| 昌宁县| 漠河县| 福州市| 礼泉县| 鲜城| 海城市| 汤阴县| 周口市| 巴南区| 梧州市| 灵山县| 古蔺县| 盐亭县| 从化市| 洪泽县| 增城市| 洛宁县| 东港市| 新营市| 开阳县| 汉寿县| 卢湾区| 甘孜| 林周县| 宁化县| 阿拉尔市| 舒兰市| 固原市| 莲花县| 陆川县| 班戈县|