在Linux系统中做MySQL数据库主从服务器
在Linux系统中做MySQL数据库主从服务器 1.网络配置服务器A:[root@CentOS mysql-5.0.40]# ifconfig eth0 eth0 Link encap:E
在Linux系统中做MySQL数据库主从服务器
1.网络配置
服务器A:
[root@CentOS mysql-5.0.40]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 08:00:27:56:AA:AA
inet addr:2.2.2.135 Bcast:2.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::a00:27ff:fe56:aaaa/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:104974 errors:0 dropped:0 overruns:0 frame:0
TX packets:54283 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:66204315 (63.1 MiB) TX bytes:4929056 (4.7 MiB)
[root@centos mysql-5.0.40]# hostname
centos
[root@centos mysql-5.0.40]# vim /etc/hosts
2.2.2.145 centos1
2.2.2.135 centos
服务器B:
[root@centos1 ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 08:00:27:56:AA:AA
inet addr:2.2.2.145 Bcast:2.2.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe56:aaaa/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:96078 errors:0 dropped:0 overruns:0 frame:0
TX packets:52141 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:60024368 (57.2 MiB) TX bytes:34512758 (32.9 MiB)
[root@centos1 ~]# hostname
centos1
[root@centos1 ~]# vim /etc/hosts
2.2.2.135 centos
2.2.2.145 centos1
[root@centos1 ~]# ping -c 2 2.2.2.135
PING 2.2.2.135 (2.2.2.135) 56(84) bytes of data.
64 bytes from 2.2.2.135: icmp_seq=1 ttl=64 time=0.763 ms
64 bytes from 2.2.2.135: icmp_seq=2 ttl=64 time=0.758 ms
--- 2.2.2.135 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1003ms
rtt min/avg/max/mdev = 0.758/0.760/0.763/0.027 ms
[root@centos1 ~]#
2.安装mysql软件
服务器A:
[root@centos mysql-5.0.40]# yum install mysql mysql-server -y --安装mysql
[root@centos mysql-5.0.40]# /etc/init.d/mysqld restart --启动mysql
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root@centos mysql-5.0.40]# netstat -an |grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
[root@centos mysql-5.0.40]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.66 Source distribution
Copyright (c) 2000, 2012, 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.
mysql> create database tong; --创建要共享的数据库
Query OK, 1 row affected (0.01 sec)
mysql> grant all privileges on *.* to abc@'*' identified by 'system'; --给数据库授权
Query OK, 0 rows affected (0.01 sec)
mysql>
[root@centos mysql-5.0.40]# vim /etc/my.cnf --在mysqld下添加以下
server_id=1
binlog-do-db=tong
binlog-ignore-db=mysql
bin-log=mysql-log
[root@centos mysql-5.0.40]# /etc/init.d/mysqld restart --启动成功
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root@centos mysql-5.0.40]#
服务器B:
[root@centos1 ~]# yum install mysql mysql-server
[root@centos1 ~]# /etc/init.d/mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root@centos1 ~]# netstat -an |grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
[root@centos1 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.66 Source distribution
Copyright (c) 2000, 2012, 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.
mysql> create database tong;
Query OK, 1 row affected (0.00 sec)
mysql> quit
[root@centos1 ~]# vim /etc/my.cnf
server_id=2
master_host=2.2.2.135
master_user=abc
master_password=system
master-port=3306
replicate_do_db=tong
master_connect_retry=10
log-bin=mysql1-log
[root@centos1 ~]# /etc/init.d/mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root@centos1 ~]#
推荐阅读:
Ubuntu下Nginx做负载实现高性能WEB服务器5---MySQL主主同步
生产环境MySQL主主同步主键冲突处理
MySQL主从失败 错误Got fatal error 1236
MySQL主从复制,,单台服务器上实施

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

資料備份與故障復原:MySQL主從複製在叢集模式下的重要性探討引言:近年來,隨著資料規模和複雜性的不斷增長,資料庫的備份和故障復原變得尤為重要。在分散式系統中,MySQL主從複製在叢集模式下被廣泛應用,以提供高可用性和容錯性。本文將探討MySQL主從複製在叢集模式下的重要性,並給出一些程式碼範例。一、MySQL主從複製的基本原理及優勢MySQL主從複製是一種通

優化資料庫效能:MySQL主從複製在叢集技術中的最佳使用方法摘要:隨著互聯網的快速發展,資料庫的效能問題成為了各個企業和組織關注的焦點。 MySQL主從複製技術在解決資料庫效能瓶頸方面發揮重要作用。本文將介紹MySQL主從複製的概念及原理,以及在叢集技術中的最佳使用方法,幫助讀者最佳化資料庫效能。一、引言隨著資料量不斷增加,資料庫的效能問題日益突出。如何優化數

解密MySQL主從複製:揭秘其叢集模式下的關鍵實作機制引言:在現代資料庫系統中,資料的高可用性和靈活性是非常重要的。 MySQL作為一款開源的關聯式資料庫管理系統,在滿足使用者需求方面具有廣泛的應用性。而MySQL的主從複製是MySQL資料庫架構中非常關鍵的一部分,用於實現資料的備份和高可用性。本文將聚焦在MySQL主從複製的關鍵實作機制,特別是其在叢集模式下

從容應對高並發:MySQL主從複製作為叢集技術的效能優勢分析隨著網路的快速發展,使用者對於網站和應用程式的訪問量呈現出爆炸性成長的趨勢。在這種高並發的情況下,如何確保系統的穩定性和效能成為了每個開發人員和系統管理員的重要任務。在資料庫中,MySQL主從複製技術被廣泛應用,成為了應對高並發的有效解決方案之一。本文將探討MySQL主從複製作為叢集技術的效能優勢。首先

MySQL主從複製屬於叢集技術還是負載平衡技術?解析和區別摘要:MySQL主從複製是一種資料庫複製技術,用於在多個伺服器上同步資料庫的資料。本文將從技術原理、應用場景和功能特性等方面來解析和區分MySQL主從複製與叢集技術以及負載平衡技術的差異。引言:在現代互聯網應用中,資料庫的高可用性和擴展性是至關重要的。 MySQL主從複製是一種常見的解決方案之一,但是,

詳解MySQL主從複製在叢集技術中發揮的功能和優勢引言MySQL是一款功能強大的關聯式資料庫管理系統,廣泛應用於各種大型網站和應用程式。隨著資料量的增加和存取請求的增加,單一MySQL伺服器的壓力也逐漸增大,為了提高資料庫的效能和可靠性,人們開始採用叢集技術,其中MySQL主從複製就是其中一種常用的技術手段。 MySQL主從複製原理MySQL主從複製是指將一

挖掘MySQL主從複製的叢集技術潛力:開源方案與商業解決方案比較評估隨著互聯網業務的不斷發展和資料量的不斷增加,對於資料庫叢集方案的需求也日益強大。 MySQL主從複製技術正好滿足了這個需求,它能夠將資料庫的讀寫操作在多個節點上分別處理,提高了資料庫的讀取效能和可用性。本文將對MySQL主從複製的叢集技術潛力進行挖掘,並對開源方案和商業解決方案進行比較評估

隨著網路的快速發展,應用系統的資料量越來越大,對資料庫的效能和可靠性要求也越來越高。 MySQL作為最常用的開源關係型資料庫之一,具有較高的效能和穩定性,被廣泛應用於各種企業級應用中。而MySQL主從複製作為常用的資料複製方案,能夠提高資料的可靠性和讀寫效能,並且被廣泛應用在大規模資料應用中。 MySQL主從複製的叢集特性指的是透過複製機制將主資料庫的資料同步
