데이터 베이스 MySQL 튜토리얼 MariaDB单机双实例主从复制

MariaDB单机双实例主从复制

Jun 07, 2016 pm 04:40 PM

MariaDB单机双实例主从复制,MariaDB其实和MySQL一样,非有啥不一样那就是名字不一样。

MariaDB单机双实例主从复制

MariaDB其实和MySQL一样,非有啥不一样那就是名字不一样。

开始~上篇实验是MariaDB的单机多实例安装 

双实例端口3307主库,,3308从库

3307主实例的mysqld配置

[mysqld2]
port=3307
socket=/tmp/mysql3307.sock
pid-file=/tmp/mysql3307.pid
max_allowed_packet=1M
net_buffer_length=2k
table_open_cache=4
sort_buffer_size=64k
thread_stack=128k
basedir=/usr/local/mysql
datadir=/data/mydata2
server-id=244
log-bin = master3307-bin
log-bin-index = master3307-bin.index
thread_concurrency=4
innodb_file_per_table = 1
#mysql_pwd='teleframe'

3308从实例的mysqld配置

[mysqld3]
port=3308
socket=/tmp/mysql3308.sock
pid-file=/tmp/mysql3308.pid
max_allowed_packet=1M
net_buffer_length=2k
table_open_cache=4
sort_buffer_size=64k
thread_stack=128k
basedir=/usr/local/mysql
datadir=/data/mydata3
innodb_file_per_table = 1
server-id=245
log-bin=mysql3308-bin
relay-log = relay-log
relay-log-index = relay-log-index
thread_concurrency=4
read-only = on

开始主从配置

步骤1、连接到主库上授权一个REPLICATION SLAVE 帐号,并且刷新授权表

[root@e3 mysql]# mysql -uroot -h127.0.0.1 -P3307 -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.0.15-MariaDB-log Source distribution
 
Copyright (c) 2000, 2014, Oracle, SkySQL Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]> show databases;
+--------------------+
| Database          |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test              |
| test1              |
+--------------------+
5 rows in set (0.00 sec)
 
MariaDB [(none)]> grant replication slave on *.* to 'repl'@'192.168.0.%' identified by 'repl';
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [(none)]> show master status;
+-----------------------+----------+--------------+------------------+
| File                  | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-----------------------+----------+--------------+------------------+
| master3307-bin.000005 |      632 |              |                  |
+-----------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
 
MariaDB [(none)]>

2、连接到从库上指定主库,启动slave

[root@e3 ~]# mysql -uroot -p'teleframe' -h127.0.0.1 -P3308
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.0.15-MariaDB-log Source distribution
 
Copyright (c) 2000, 2014, Oracle, SkySQL Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]> change master to master_host='192.168.0.244',master_user='repl',master_password='repl',master_port=3307,master_log_file='master3307-bin.000005',master_log_pos=632;
ERROR 1201 (HY000): Could not initialize master info structure for ''; more error messages can be found in the MariaDB error log #我这报错了,如果你跟我一样报错就执行下面的命令
MariaDB [(none)]> reset slave;
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [(none)]> change master to master_host='192.168.0.244',master_user='repl',master_password='repl',master_port=3307,;
Query OK, 0 rows affected (0.22 sec) #好了现在连接上了      master_log_file='master3307-bin.000005',master_log_pos=632  表示从主服务器那个二进制日志文件开始复制因为这是复制授权信息,所以没必要复制,在主服务器上可以查看show master status; 查看内容show binglog events in 'master-bin.000001';
MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
              Slave_IO_State:
                  Master_Host: 192.168.0.244
                  Master_User: repl
                  Master_Port: 3307
                Connect_Retry: 60
              Master_Log_File: master3307-bin.000005
          Read_Master_Log_Pos: 632
              Relay_Log_File: relay-log.000002
                Relay_Log_Pos: 4
        Relay_Master_Log_File: master3307-bin.000005
            Slave_IO_Running: No  #  从服务器有没有正常工作主要是看这个值是否YES
            Slave_SQL_Running: No  #
              Replicate_Do_DB:
          Replicate_Ignore_DB:
          Replicate_Do_Table:
      Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                  Last_Errno: 0
                  Last_Error:
                Skip_Counter: 0
          Exec_Master_Log_Pos: 632
              Relay_Log_Space: 248
              Until_Condition: None
              Until_Log_File:
                Until_Log_Pos: 0
          Master_SSL_Allowed: No
          Master_SSL_CA_File:
          Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
              Master_SSL_Key:
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
              Last_SQL_Errno: 0
              Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
            Master_Server_Id: 0
              Master_SSL_Crl:
          Master_SSL_Crlpath:
                  Using_Gtid: No
                  Gtid_IO_Pos:
1 row in set (0.00 sec)
MariaDB [(none)]> start slave;  #好启动slave
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
              Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.0.244
                  Master_User: repl
                  Master_Port: 3307
                Connect_Retry: 60
              Master_Log_File: master3307-bin.000005
          Read_Master_Log_Pos: 632
              Relay_Log_File: relay-log.000003
                Relay_Log_Pos: 540
        Relay_Master_Log_File: master3307-bin.000005
            Slave_IO_Running: Yes  #表示从服务器正常工作了
            Slave_SQL_Running: Yes  #
              Replicate_Do_DB:
          Replicate_Ignore_DB:
          Replicate_Do_Table:
      Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                  Last_Errno: 0
                  Last_Error:
                Skip_Counter: 0
          Exec_Master_Log_Pos: 632
              Relay_Log_Space: 831
              Until_Condition: None
              Until_Log_File:
                Until_Log_Pos: 0
          Master_SSL_Allowed: No
          Master_SSL_CA_File:
          Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
              Master_SSL_Key:
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
              Last_SQL_Errno: 0
              Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
            Master_Server_Id: 244
              Master_SSL_Crl:
          Master_SSL_Crlpath:
                  Using_Gtid: No
                  Gtid_IO_Pos:

来测试!

在主的上面创建一个库看从的是否可以复制到

主上创建

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

상위 10 개 글로벌 디지털 가상 통화 거래 플랫폼 순위 (2025 권위있는 순위) 상위 10 개 글로벌 디지털 가상 통화 거래 플랫폼 순위 (2025 권위있는 순위) Mar 06, 2025 pm 04:36 PM

2025 년에 Global Digital Virtual Currency Trading Platform은 2025 년에 트랜잭션 볼륨, 보안 및 사용자 경험과 같은 지표를 기반으로 전 세계 10 대 디지털 가상 통화 거래 플랫폼을 권위있게 발표합니다. OKX는 강력한 기술 강점과 글로벌 운영 전략으로 1 위를 차지했으며 Binance는 높은 유동성과 낮은 수수료와 밀접한 관련이 있습니다. Gate.io, Coinbase 및 Kraken과 같은 플랫폼은 각각의 장점과 함께 최전선에 있습니다. 이 목록에는 Huobi, Kucoin, Bitfinex, Crypto.com 및 Gemini와 같은 거래 플랫폼이 각각 고유 한 특성을 지니고 있지만 투자는 신중해야합니다. 플랫폼을 선택하려면 보안, 유동성, 수수료, 사용자 경험, 통화 선택 및 규제 준수와 같은 요소를 고려해야합니다.

숫자의 가장 큰 소인수를 찾는 C 프로그램 숫자의 가장 큰 소인수를 찾는 C 프로그램 Aug 27, 2023 am 10:09 AM

소인수−수론에서 양의 정수의 소인수는 정확히 소수로 나누어지는 소수입니다. 이 숫자를 찾는 과정을 정수 인수분해 또는 소인수분해라고 합니다. 예−288의 소인수는 다음과 같습니다: 288=2x2x2x2x2

상위 10 개 디지털 통화 거래 플랫폼 상위 10 개 디지털 통화 거래 플랫폼의 최신 목록 상위 10 개 디지털 통화 거래 플랫폼 상위 10 개 디지털 통화 거래 플랫폼의 최신 목록 Mar 17, 2025 pm 05:57 PM

상위 10 개 디지털 통화 거래 플랫폼 : 1. OKX, 2. BINANCE, 3. GATE.IO, 4. HUOBI GLOBAL, 5. KRAKEN, 6. COINBASE, 7. KUCOIN, 8. BITFINEX, 9. CRYPTO.COM, 10. GEMINI, 자체 특성을 보유하고 있으며,이 교환은 보안, 요소, 보안, 사용자를 기반으로하는 플랫폼을 선택할 수 있습니다.

2025 년 통화 서클의 10 대 교환 최신 디지털 통화 앱 순위 2025 년 통화 서클의 10 대 교환 최신 디지털 통화 앱 순위 Feb 27, 2025 pm 06:33 PM

상위 10 개의 가상 통화 거래 플랫폼 순위 (2025 년 최신) : BINANCE : 글로벌 리더, 높은 유동성 및 규제가 주목을 끌었습니다. OKX : 대규모 사용자 기반, 여러 통화를 지원하며 레버리지 거래를 제공합니다. Gate.io : 다양한 화폐 통화 지불 방법을 갖춘 선임 교환으로 다양한 거래 쌍 및 투자 제품을 제공합니다. BITGET : 파생 상품 교환, 높은 유동성, 낮은 수수료. HUOBI : 다양한 통화 및 거래 쌍을 지원하는 오래된 교환. 코인베이스 : 잘 알려진 미국 교환으로 엄격하게 규제되었습니다. Phemex 등.

디지털 통화 앱을위한 상위 10 개 트레이딩 플랫폼, 정기 통화 추측 플랫폼 앱 권장 사항 디지털 통화 앱을위한 상위 10 개 트레이딩 플랫폼, 정기 통화 추측 플랫폼 앱 권장 사항 Mar 07, 2025 pm 06:51 PM

이 기사는 10 개의 디지털 거래 앱을 권장한다. 플랫폼을 선택할 때 보안, 유동성, 거래 수수료, 통화 선택, 사용자 인터페이스, 고객 서비스 지원 및 규제 준수와 같은 요소를 고려하고 위험을 신중하게 평가하고 맹목적으로 추세를 따르지 않아야합니다.

세계 10 대 10 가상 통화 거래 플랫폼 앱 진짜 다운로드 및 설치 자습서 세계 10 대 10 가상 통화 거래 플랫폼 앱 진짜 다운로드 및 설치 자습서 Mar 12, 2025 pm 05:33 PM

이 기사는 Binance, Okx, Gate.io, Huobi Global, Coinbase, Kucoin, Kraken 및 Bitfinex와 같은 주류 디지털 통화 거래 플랫폼에 대한 Android 및 Apple Mobile 앱 다운로드 방법을 제공합니다. Android 사용자이든 Apple 사용자이든 상관없이 해당 플랫폼의 공식 앱 다운로드 링크를 쉽게 찾아 단계에 따라 설치를 완료 할 수 있습니다. 이 기사는 해당 공식 웹 사이트 또는 앱 스토어에서 검색 및 다운로드에 대한 자세한 지침을 제공하며 Android에 APK 파일을 설치하는 특별 단계에 대한 지침을 제공하여 사용자가 빠르고 쉽게 다운로드하여 사용할 수 있습니다.

신뢰할 수있는 디지털 통화 플랫폼은 무엇입니까? 신뢰할 수있는 디지털 통화 플랫폼은 무엇입니까? Mar 17, 2025 pm 05:45 PM

신뢰할 수있는 디지털 통화 플랫폼은 다음과 같습니다. 1. OKX, 2. BINANCE, 3. GATE.IO, 4. HUOBI GLOBAL, 5. COINBASE, 7. BITFINEX, 9. CRYPTO.com, GEMINI는 이들 교환을 기반으로하는 플랫폼을 선택할 수 있습니다.

상위 10 개 디지털 통화 앱 거래 플랫폼 Top10 가상 통화 앱 2025 순위 상위 10 개 디지털 통화 앱 거래 플랫폼 Top10 가상 통화 앱 2025 순위 Mar 13, 2025 pm 07:00 PM

상위 10 개는 다음과 같습니다. 순위는 플랫폼 유동성, 통화 선택, 보안, 사용자 경험, 수수료 및 규정 준수와 같은 포괄적 인 고려 사항을 기반으로하지만 투자는 신중하고 자신의 위험에 처해 있어야합니다.

See all articles