欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

docker實現(xiàn)MySQL數(shù)據(jù)同步的方法

 更新時間:2022年03月14日 10:44:57   作者:思誠代碼塊  
docker的一大好處是在本地可以很方便快速的搭建負(fù)載均衡,主從同步等需要多主機的環(huán)境,本文主要介紹了docker實現(xiàn)MySQL數(shù)據(jù)同步的方法,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

大家好,今天分享一下docker的一個實戰(zhàn)

我們使用docker 實現(xiàn)MySQL 的數(shù)據(jù)同步

搜索mysql 鏡像

[root@localhost ~]# docker search  mysql
NAME                             DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql                            MySQL is a widely used, open-source relation…   12222     [OK]       
mariadb                          MariaDB Server is a high performing open sou…   4691      [OK]       
mysql/mysql-server               Optimized MySQL Server Docker images. Create…   907                  [OK]
percona                          Percona Server is a fork of the MySQL relati…   571       [OK]       
phpmyadmin                       phpMyAdmin - A web interface for MySQL and M…   465       [OK]       
mysql/mysql-cluster              Experimental MySQL Cluster Docker images. Cr…   93                   
centos/mysql-57-centos7          MySQL 5.7 SQL database server                   92                   
bitnami/mysql                    Bitnami MySQL Docker Image                      64                   [OK]
databack/mysql-backup            Back up mysql databases to... anywhere!         56                   
circleci/mysql                   MySQL is a widely used, open-source relation…   25                   
ubuntu/mysql                     MySQL open source fast, stable, multi-thread…   24                   
mysql/mysql-router               MySQL Router provides transparent routing be…   23                   
centos/mysql-56-centos7          MySQL 5.6 SQL database server                   22                   
arey/mysql-client                Run a MySQL client from a docker container      20                   [OK]
google/mysql                     MySQL server for Google Compute Engine          19                   [OK]
mysqlboy/mydumper                mydumper for mysql logcial backups              3                    
mysqlboy/docker-mydumper         docker-mydumper containerizes MySQL logical …   3                    
bitnami/mysqld-exporter                                                          2                    
ibmcom/mysql-s390x               Docker image for mysql-s390x                    1                    
mirantis/mysql                                                                   0                    
mysql/mysql-operator             MySQL Operator for Kubernetes                   0                    
mysqlboy/elasticsearch                                                           0                    
mysqleatmydata/mysql-eatmydata                                                   0                    
cimg/mysql                                                                       0                    
ibmcom/tidb-ppc64le              TiDB is a distributed NewSQL database compat…   0                    
[root@localhost ~]# 

拉取mysql 鏡像 (我們在這里指定5.7這個版本)

[root@localhost ~]# docker pull mysql:5.7
5.7: Pulling from library/mysql
72a69066d2fe: Pull complete 
93619dbc5b36: Pull complete 
99da31dd6142: Pull complete 
626033c43d70: Pull complete 
37d5d7efb64e: Pull complete 
ac563158d721: Pull complete 
d2ba16033dad: Pull complete 
0ceb82207cd7: Pull complete 
37f2405cae96: Pull complete 
e2482e017e53: Pull complete 
70deed891d42: Pull complete 
Digest: sha256:f2ad209efe9c67104167fc609cca6973c8422939491c9345270175a300419f94
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7
[root@localhost ~]# 

查看本地鏡像

[root@localhost ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
tomcat04      1.0       12b32b1a124d   18 hours ago   685MB
nginx         latest    605c77e624dd   2 months ago   141MB
tomcat        9.0       b8e65a4d736d   2 months ago   680MB
tomcat        latest    fb5657adc892   2 months ago   680MB
mysql         5.7       c20987f18b13   2 months ago   448MB
hello-world   latest    feb5d9fea6a5   5 months ago   13.3kB
centos        latest    5d0da3dc9764   5 months ago   231MB
[root@localhost ~]# 

運行一下mysql 容器,做內(nèi)外網(wǎng)的端口映射,做容器與Linux 主機上的掛載 ,然后給它設(shè)密碼123456 ,后面加上操作的鏡像名

[root@localhost ~]# docker run -d -p 3310:3306 -v /home/mysql/conf:/etc/mysql/conf.d -v /home/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 --name mysql01 mysql:5.7 
f3248538d690f67fa057b0b9e00dd060b1ce40378171de0a9f3d9ebd478111d2
[root@localhost ~]# 

顯示mysql 容器正在運行中

[root@localhost ~]# docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS                                                  NAMES
f3248538d690   mysql:5.7      "docker-entrypoint.s…"   4 minutes ago   Up 4 minutes   33060/tcp, 0.0.0.0:3310->3306/tcp, :::3310->3306/tcp   mysql01
6d6fa6a4c6d7   5d0da3dc9764   "/bin/bash"              25 hours ago    Up 25 hours                                                           nice_panini
[root@localhost ~]# 

使用數(shù)據(jù)庫管理工具sql yog 連接我們的數(shù)據(jù)庫

在這里插入圖片描述

查看服務(wù)器ip地址

[root@localhost ~]# ifconfig  ens33
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.12  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::617f:ef93:80d4:e14e  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:87:af:a6  txqueuelen 1000  (Ethernet)
        RX packets 2460532  bytes 2826366757 (2.6 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1198876  bytes 243212283 (231.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]# 

這里,
命名為容器,
地址:192.168.1.12 (服務(wù)器IP地址)
密碼:123456 (我們剛才在docker mysql 容器當(dāng)中設(shè)置的密碼)
端口:3310 (這是我們剛才做的端口)

在這里插入圖片描述

連接成功:

在這里插入圖片描述

就是說,我們使用現(xiàn)在已經(jīng)可以通過使用數(shù)據(jù)庫管理工具sql yog 連接與使用我們的數(shù)據(jù)庫

這個效果和實際本質(zhì)與我們平時使用的數(shù)據(jù)庫是一樣的

在Linux主機上查看/home 下的文件 (注意,多了一個mysql)

[root@localhost ~]# cd /home/
[root@localhost home]# ls
456.txt  admin  ceshi  daqing  mysql  zhangsan
[root@localhost home]# 

映射的配置文件與數(shù)據(jù)文件

[root@localhost home]# cd mysql/
[root@localhost mysql]# ls
conf  data
[root@localhost mysql]# 

這就是我們的數(shù)據(jù)文件

[root@localhost mysql]# cd data/
[root@localhost data]# ls
auto.cnf    ca.pem           client-key.pem  ibdata1      ib_logfile1  mysql               private_key.pem  server-cert.pem  sys
ca-key.pem  client-cert.pem  ib_buffer_pool  ib_logfile0  ibtmp1       performance_schema  public_key.pem   server-key.pem
[root@localhost data]# 

正式連接數(shù)據(jù)庫 (192.168.1.12)

在這里插入圖片描述

在我們MySQL中加一個庫

在這里插入圖片描述

在Linux上 ,在映射目錄的數(shù)據(jù)文件多了一個帥哥

[root@localhost data]# ls
auto.cnf    ca.pem           client-key.pem  ibdata1      ib_logfile1  mysql               private_key.pem  server-cert.pem  shuaige
ca-key.pem  client-cert.pem  ib_buffer_pool  ib_logfile0  ibtmp1       performance_schema  public_key.pem   server-key.pem   sys
[root@localhost data]# 

刪除mysql這個容器

[root@localhost data]# docker rm -f mysql01 
mysql01
[root@localhost data]# 

映射的數(shù)據(jù)文件還在,

[root@localhost data]# ls
auto.cnf    ca.pem           client-key.pem  ibdata1      ib_logfile1  mysql               private_key.pem  server-cert.pem  shuaige
ca-key.pem  client-cert.pem  ib_buffer_pool  ib_logfile0  ibtmp1       performance_schema  public_key.pem   server-key.pem   sys
[root@localhost data]# 

即,在mysql容器刪除之后,數(shù)據(jù)沒有丟失,實現(xiàn)了持久化

這就是docker 容器數(shù)據(jù)卷的好處

到此這篇關(guān)于docker實現(xiàn)MySQL數(shù)據(jù)同步的方法的文章就介紹到這了,更多相關(guān)docker MySQL數(shù)據(jù)同步內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 如何通過Jenkins定期清理為None的鏡像詳解

    如何通過Jenkins定期清理為None的鏡像詳解

    這篇文章主要給大家介紹了關(guān)于如何通過Jenkins定期清理為None的鏡像的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-11-11
  • 使用docker部署django的詳細(xì)步驟

    使用docker部署django的詳細(xì)步驟

    當(dāng)用Django框架開發(fā)的網(wǎng)站項目完成后上線的話可以用物理主機、虛擬機來部署,也可以容器,下面這篇文章主要給大家介紹了關(guān)于使用docker部署django的詳細(xì)步驟,需要的朋友可以參考下
    2022-08-08
  • 如何查看docker容器運行進程信息

    如何查看docker容器運行進程信息

    這篇文章主要介紹了如何查看docker容器運行進程信息問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • python腳本在docker上運行的方法

    python腳本在docker上運行的方法

    在本篇文章里小編給各位分享的是關(guān)于python腳本在docker上運行的方法內(nèi)容,有需要的朋友們可以學(xué)習(xí)下。
    2020-03-03
  • 樹莓派系列之使用docker安裝青龍面板和改端口號的配置問題

    樹莓派系列之使用docker安裝青龍面板和改端口號的配置問題

    這篇文章主要介紹了樹莓派系列之使用docker安裝青龍面板和改端口號的問題,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-02-02
  • Docker創(chuàng)建MongoDB容器并添加root密碼驗證與更多用戶詳細(xì)步驟

    Docker創(chuàng)建MongoDB容器并添加root密碼驗證與更多用戶詳細(xì)步驟

    MongoDB是一個著名的面向文檔的數(shù)據(jù)庫,被許多現(xiàn)代Web應(yīng)用程序使用,下面這篇文章主要給大家介紹了關(guān)于Docker創(chuàng)建MongoDB容器并添加root密碼驗證與更多用戶的相關(guān)資料,需要的朋友可以參考下
    2023-01-01
  • 詳解Docker中容器的備份、恢復(fù)和遷移

    詳解Docker中容器的備份、恢復(fù)和遷移

    本篇文章主要介紹了詳解Docker中容器的備份、恢復(fù)和遷移 ,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-03-03
  • 使用docker compose安裝FastDfs文件服務(wù)器的實例詳解

    使用docker compose安裝FastDfs文件服務(wù)器的實例詳解

    這篇文章主要介紹了使用docker compose安裝FastDfs文件服務(wù)器的實例詳解,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-10-10
  • 關(guān)于Docker容器Dead狀態(tài)的分析

    關(guān)于Docker容器Dead狀態(tài)的分析

    這篇文章主要介紹了關(guān)于Docker容器Dead狀態(tài)的分析,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • 解析docker妙用SpringBoot構(gòu)建微服務(wù)實戰(zhàn)記錄

    解析docker妙用SpringBoot構(gòu)建微服務(wù)實戰(zhàn)記錄

    Spring Boot 是 Spring 開源組織的子項目,是 Spring 組件一站式解決方案,本文通過詳細(xì)案例給大家解析docker妙用SpringBoot構(gòu)建微服務(wù)實戰(zhàn)記錄,感興趣的朋友跟隨小編一起看看吧
    2021-11-11

最新評論