国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問(wèn)答1問(wèn)答10問(wèn)答100問(wèn)答1000問(wèn)答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問(wèn)答文章1 問(wèn)答文章501 問(wèn)答文章1001 問(wèn)答文章1501 問(wèn)答文章2001 問(wèn)答文章2501 問(wèn)答文章3001 問(wèn)答文章3501 問(wèn)答文章4001 問(wèn)答文章4501 問(wèn)答文章5001 問(wèn)答文章5501 問(wèn)答文章6001 問(wèn)答文章6501 問(wèn)答文章7001 問(wèn)答文章7501 問(wèn)答文章8001 問(wèn)答文章8501 問(wèn)答文章9001 問(wèn)答文章9501
當(dāng)前位置: 首頁(yè) - 科技 - 知識(shí)百科 - 正文

Master-MasterMySQL復(fù)制安裝配置試驗(yàn)_MySQL

來(lái)源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-09 19:42:47
文檔

Master-MasterMySQL復(fù)制安裝配置試驗(yàn)_MySQL

Master-MasterMySQL復(fù)制安裝配置試驗(yàn)_MySQL: 一、 架構(gòu) 二、 安裝Mysql server 下面以在DB1(192.168.0.10)的配置為例,DB2的配置基本一樣,只要修改my.cnf中的server_id =2 1. 安裝mysql-server db1# apt-get install mysql-server 注: 如果安裝有
推薦度:
導(dǎo)讀Master-MasterMySQL復(fù)制安裝配置試驗(yàn)_MySQL: 一、 架構(gòu) 二、 安裝Mysql server 下面以在DB1(192.168.0.10)的配置為例,DB2的配置基本一樣,只要修改my.cnf中的server_id =2 1. 安裝mysql-server db1# apt-get install mysql-server 注: 如果安裝有

一、 架構(gòu)

\

二、 安裝Mysql server

下面以在DB1(192.168.0.10)的配置為例,DB2的配置基本一樣,只要修改my.cnf中的server_id =2

1. 安裝mysql-server

db1# apt-get install mysql-server

注:

? 如果安裝有問(wèn)題,執(zhí)行apt-getupdate更新源后再重試

? 安裝過(guò)程中需要輸入root密碼,設(shè)置后記?。?23456)

2. 驗(yàn)證數(shù)據(jù)庫(kù)安裝

db1# mysql -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 42

Server version: 5.5.38-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

(db1)mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

+--------------------+

3 rows in set (0.00 sec)

(db1)mysql>

3. 創(chuàng)建測(cè)試數(shù)據(jù)庫(kù)

CREATE DATABASE /*!32312 IF NOT EXISTS*/`test` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `test`;

/*Table structure for table `user` */

DROP TABLE IF EXISTS `user`;

CREATE TABLE `user` (

`name` varchar(16) DEFAULT NULL,

`age` int(11) DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

此步驟略

4. my.cnf配置修改

以下紅色部分為修改的配置

The MySQL database server configuration file.

#

# You can copy this to one of:

# - "/etc/mysql/my.cnf" to set global options,

# - "~/.my.cnf" to set user-specific options.

#

# One can use all long options that the program supports.

# Run program with --help to get a list of available options and with

# --print-defaults to see which it would actually understand and use.

#

# For explanations see

# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients

# It has been reported that passwords should be enclosed with ticks/quotes

# escpecially if they contain "#" chars...

# Remember to edit /etc/mysql/debian.cnf when changing the socket location.

[client]

port = 3306

socket = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs

# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.

[mysqld_safe]

socket = /var/run/mysqld/mysqld.sock

nice = 0

[mysqld]

#

# * Basic Settings

#

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

skip-external-locking

#

# 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

bind-address =0.0.0.0

#

# * Fine Tuning

#

key_buffer = 16M

max_allowed_packet = 16M

thread_stack = 192K

thread_cache_size = 8

# This replaces the startup script and checks MyISAM tables if needed

# the first time they are touched

myisam-recover = BACKUP

#max_connections = 100

#table_cache = 64

#thread_concurrency = 10

#

# * Query Cache Configuration

#

query_cache_limit = 1M

query_cache_size = 16M

#

# * Logging and Replication

#

# Both location gets rotated by the cronjob.

# Be aware that this log type is a performance killer.

# As of 5.1 you can enable the log at runtime!

#general_log_file = /var/log/mysql/mysql.log

#general_log = 1

#

# Error log - should be very few entries.

#

log_error = /var/log/mysql/error.log

#

# Here you can see queries with especially long duration

#log_slow_queries = /var/log/mysql/mysql-slow.log

#long_query_time = 2

#log-queries-not-using-indexes

#

# The following can be used as easy to replay backup logs or for replication.

# note: if you are setting up a replication slave, see README.Debian about

# other settings you may need to change.

#server-id = 1

#log_bin = /var/log/mysql/mysql-bin.log

expire_logs_days = 10

max_binlog_size = 100M

#binlog_do_db = include_database_name

#binlog_ignore_db = include_database_name

#

# * InnoDB

#

# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.

# Read the manual for more InnoDB related options. There are many!

#

# * Security Features

#

# Read the manual, too, if you want chroot!

# chroot = /var/lib/mysql/

#

# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".

#

# ssl-ca=/etc/mysql/cacert.pem

# ssl-cert=/etc/mysql/server-cert.pem

# ssl-key=/etc/mysql/server-key.pem

server_id = 1

log_bin = /var/log/mysql/mysql-bin.log

log_bin_index = /var/log/mysql/mysql-bin.log.index

relay_log = /var/log/mysql/mysql-relay-bin

relay_log_index = /var/log/mysql/mysql-relay-bin.index

expire_logs_days = 10

max_binlog_size = 100M

log_slave_updates = 1

auto_increment_increment = 2

auto_increment_offset = 1

[mysqldump]

quick

quote-names

max_allowed_packet = 16M

[mysql]

#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]

key_buffer = 16M

#

# * 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/

5. 創(chuàng)建三種角色的用戶

表格 1

角色

功能

權(quán)限

monitor user

MMM(Multi-Master replication manager of MYSQL)監(jiān)控各主控的健康狀況

REPLICATION CLIENT

agent user

MMM代理用來(lái)設(shè)置只讀屬性,復(fù)制主控等

SUPER, REPLICATION CLIENT, PROCESS

replicate user

用來(lái)復(fù)制

REPLICATION SLAVE

表格 2

(db1)mysql> GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'115.29.198.150' IDENTIFIED BY '123456';

Query OK, 0 rows affected (0.00 sec)

(db1)mysql> GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'42.96.%.%' IDENTIFIED BY '123456';

Query OK, 0 rows affected (0.00 sec)

(db1)mysql> GRANT REPLICATION SLAVE ON *.* TO 'replication'@'42.96.%.%' IDENTIFIED BY '123456';

Query OK, 0 rows affected (0.00 sec)

三、 同步DB1和DB2數(shù)據(jù)庫(kù)

首先假設(shè)DB1包含正確的數(shù)據(jù)(即使是空數(shù)據(jù)庫(kù)),進(jìn)行DB1和DB2直接的數(shù)據(jù)同步。

1. 以下在DB1所在服務(wù)器上執(zhí)行數(shù)據(jù)導(dǎo)出

(db1)mysql> FLUSH TABLES WITH READ LOCK;

(db1)mysql> SHOW MASTER STATUS;

+------------------+----------+--------------+------------------+

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |

+------------------+----------+--------------+------------------+

| mysql-bin.000002 | 616 | | |

+------------------+----------+--------------+------------------+

1 row in set (0.00 sec)

(db1)mysql>

2. 另開(kāi)一個(gè)命令窗口導(dǎo)出數(shù)據(jù)

(db1)# mysqldump -u root -p --all-databases > /tmp/database-backup.sql

3. 解鎖第一個(gè)窗口

(db1)mysql> UNLOCK TABLES;

Query OK, 0 rows affected (0.00 sec)

(db1)mysql>

4. 將DB1導(dǎo)出的數(shù)據(jù)導(dǎo)入DB2

1) 拷貝到DB2

(db1)# scp database-backup.sql root@192.168.0.11:/tmp/

The authenticity of host '192.168.0.11 (192.168.0.11)' can't be established.

ECDSA key fingerprint is 55:84:03:9e:d9:74:cc:cd:03:59:23:3f:df:d9:77:a5.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.0.11' (ECDSA) to the list of known hosts.

root@192.168.0.11's password:

database-backup.sql 100% 528KB 527.9KB/s 00:00

(db1):/tmp#

2) 導(dǎo)入DB2

(db2)# mysql -u root -p < /tmp/database-backup.sql

Enter password:

(db2)#

3) 應(yīng)用權(quán)限

(db2)mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

4) 拷貝debian.cnf

將/etc/mysql/debian.cnf 從 DB1拷貝到DB2, 這個(gè)文件是用來(lái)啟動(dòng)和關(guān)閉mysql用的。

(db1)# scp debian.cnf root@192.168.0.11:/tmp/

在DB2上備份原來(lái)的debian.cnf,然后使用從DB1拷貝過(guò)來(lái)的debian.cnf

(db2)# mv /etc/mysql/debian.cnf /etc/mysql/debian.cnf.orign

(db2)# cp -f debian.cnf /etc/mysql/debian.cnf

上述步驟完成后準(zhǔn)備工作都做好了,可以開(kāi)始配置復(fù)制。

四、 復(fù)制配置

1. 在DB2上執(zhí)行:

(db2)mysql> CHANGE MASTER TO master_host='192.168.0.10', master_port=3306, master_user='replication', master_password='123456', master_log_file='mysql-bin.000002', master_log_pos=616;

Query OK, 0 rows affected (0.04 sec)

注:master_log_file='mysql-bin.000002', master_log_pos=616 信息來(lái)自于在DB1上執(zhí)行

mysql> show master status;

2. 在DB2上啟動(dòng)SLAVE

(db2)mysql> START SLAVE;

Query OK, 0 rows affected (0.00 sec)

3. DB2上檢查復(fù)制進(jìn)程

(db2)mysql> SHOW SLAVE STATUS\G

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.0.10

Master_User: replication

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000002

Read_Master_Log_Pos: 616

Relay_Log_File: mysql-relay-bin.000002

Relay_Log_Pos: 253

Relay_Master_Log_File: mysql-bin.000002

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: 616

Relay_Log_Space: 409

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: 1

1 row in set (0.00 sec)

4. 配置從DB2復(fù)制到DB1

1) DB2狀態(tài)

(db2)mysql> SHOW MASTER STATUS;

+------------------+----------+--------------+------------------+

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |

+------------------+----------+--------------+------------------+

| mysql-bin.000002 | 107 | | |

+------------------+----------+--------------+------------------+

1 row in set (0.01 sec)

mysql>

2) DB1復(fù)制的配置、啟動(dòng)和檢查

(db1)mysql> CHANGE MASTER TO master_host = '192.168.0.11', master_port=3306, master_user='replication',

-> master_password='123456', master_log_file='mysql-bin.000002', master_log_pos=107;

Query OK, 0 rows affected (0.05 sec)

mysql> START SLAVE;

Query OK, 0 rows affected (0.00 sec)

mysql> SHOW SLAVE STATUS\G

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.0.11

Master_User: replication

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000002

Read_Master_Log_Pos: 107

Relay_Log_File: mysql-relay-bin.000002

Relay_Log_Pos: 253

Relay_Master_Log_File: mysql-bin.000002

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: 107

Relay_Log_Space: 409

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: 2

1 row in set (0.00 sec)

mysql>

上述步驟完成MASTER-MASTER的復(fù)制配置,下面進(jìn)行測(cè)試。

五、 復(fù)制驗(yàn)證

1. 在DB1上插入一條數(shù)據(jù)

(db1)mysql> select * from user;

Empty set (0.00 sec)

(db1)mysql> insert into user(name,age) values('user1',20);

Query OK, 1 row affected (0.03 sec)

(db1)mysql>

2. 在DB2上檢查

(db2)mysql> select * from user;

Empty set (0.00 sec)

(db2)mysql> select * from user;

+-------+------+

| name | age |

+-------+------+

| user1 | 20 |

+-------+------+

1 row in set (0.00 sec)

(db2)mysql>

表面在DB1插入的(user1,20)這條記錄已經(jīng)被復(fù)制到DB2中。

3. 在DB2上插入一條數(shù)據(jù)

(db2)mysql> insert into user(name,age) values('user2',30);

Query OK, 1 row affected (0.02 sec

4. 在DB1上進(jìn)行檢查

(db1)mysql> select * from user;

+-------+------+

| name | age |

+-------+------+

| user1 | 20 |

| user2 | 30 |

+-------+------+

2 rows in set (0.00 sec)

表面在DB2插入的(user2,30)這條記錄已經(jīng)被復(fù)制到DB1中。

上述測(cè)試表面,DB1<----->DB2的MM配置完全成功。

聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

Master-MasterMySQL復(fù)制安裝配置試驗(yàn)_MySQL

Master-MasterMySQL復(fù)制安裝配置試驗(yàn)_MySQL: 一、 架構(gòu) 二、 安裝Mysql server 下面以在DB1(192.168.0.10)的配置為例,DB2的配置基本一樣,只要修改my.cnf中的server_id =2 1. 安裝mysql-server db1# apt-get install mysql-server 注: 如果安裝有
推薦度:
標(biāo)簽: 復(fù)制 安裝 配置
  • 熱門(mén)焦點(diǎn)

最新推薦

猜你喜歡

熱門(mén)推薦

專題
Top
主站蜘蛛池模板: 国产一区在线播放 | 欧美福利网 | 欧美福利一区二区三区 | 国产99久久九九精品免费 | 国产网站免费在线观看 | 91麻豆国产香蕉久久精品 | 国产精品高清一区二区 | 在线免费国产视频 | 美女视频黄a视频全免费网站色 | 99热成人精品免费久久 | 久久999 | 欧美成人精品一区二区三区 | 欧美国产日韩在线播放 | 欧美日本在线 | 国产精品久久久久一区二区 | 99这里都是精品 | 国产精品国产三级国产a | 国产一区二区不卡 | 亚洲欧美日韩高清中文在线 | 久久91精品国产一区二区 | 在线观看亚洲视频 | 日本欧美国产精品第一页久久 | 高清国产美女一级a毛片 | 97精品国产97久久久久久 | 欧美综合一区 | 亚洲国产精品综合久久网络 | 国产精品久久久久久久久久久久 | 久久久久久久久久久9精品视频 | 久久www免费人成精品香蕉 | 97精品国产91久久久久久 | 国产一区二区三区免费视频 | 国产视频一区二区三区四区 | 日韩欧美在线综合网高清 | 亚洲日韩欧美一区二区在线 | 欧美成人精品高清在线播放 | xx欧美| 国产精品亚洲精品日韩动图 | 99精品国产成人一区二区 | 91免费高清视频 | 91原创国产 | 精品国产91久久久久久久 |