HanG321 Blog
Be Shine, Be Smile, Be Wild
  • Home
  • Blog
    • 好文閱讀 readings
    • 生活記事 diary
    • 時事評論 commentary
    • 科技資訊 technology
    • 電腦編程 programming
    • 金融財經 finance
    • 音樂電影 music/movie
  • About

假期

February 26, 2007|生活記事

有2 天的假期……因為….. 拗柴了…
應該問 dr 要多幾天的假……好好咁休息下ma ~

很久沒有拗得這麼嚴重…對上一次已經係F.4 之時…
個次係左腳……估唔到一踏入豬年就連隻右腳不敗之神話亦要告吹了 ~~
左右腳 同右手都出過事 ….. 左手細個個時拗過….
唉也 …. 原來我已經係四肢不全啦…..

lum, Q, 天宇 係港安陪我, 一眾人又幫我找taxi  ~ 謝謝你們

係診所第一次坐了輪椅….俾人推既滋味其實唔係咁爽….
如Q 所講….好似好冇用咁~~

MySQL Master Master replication

February 23, 2007|Cluster, MySQL|科技資訊

A. background

OS: CentOS 4.4
MySQL package: 4.1.20-1.RHEL4.1
node1: 192.168.0.131   (Master 1/Slave 2)
node2: 192.168.0.132   (Master 2/Slave 1)
mysql path: /var/lib/mysql
mysql config file: /etc/my.cnf

reference:
http://www.howtoforge.com/mysql_master_master_replication
http://cha.homeip.net/blog/archives/2004/12/replication_in.html

B. procedure

 

1.
On Master 1, make changes in my.cnf

#vim /etc/my.cnf

Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
 
#replication
log-bin
binlog-do-db=horde
binlog-ignore-db=mysql
binlog-ignore-db=test
 
server-id=1
 
[mysql.server]
user=mysql
basedir=/var/lib
 
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

2.

On master 1, create a replication slave account in mysql.

#mysql -u root -p
mysql> grant replication slave on *.* to ‘replication’@192.168.0.132 identified by ‘slave’;
mysql> exit

and restart the mysql master1.
#service mysqld restart

3.
Now edit my.cnf on Slave1 or Master2 :

Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
old_passwords=1
 
server-id=2
master-host = 192.168.0.131
master-user = replication
master-password = slave
master-port = 3306
 
[mysql.server]
user=mysql
basedir=/var/lib
 
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

 

4.
Restart mysql slave 1 and check config at

#service mysqld restart

#mysql -u root -p
mysql> start slave;
mysql> show slave statusG;

ensure Slave_IO_Running and Slave_SQL_Running: must be to YES.

mysql> exit

5.
On master 1:

MySQL
1
2
3
4
5
6
7
mysql> show master status;
+------------------------+----------+--------------+------------------+
| File                   | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------------+----------+--------------+------------------+
|MysqlMYSQL01-bin.000008 |       79 | horde        | mysql,test       |
+------------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

The above scenario is for master-slave, now we will create a slave master scenario for the same systems and it will work as master master.

6.
On Master2/Slave 1, edit my.cnf and master entries into it:

#vim /etc/my.cnf

Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
 
server-id=2
 
master-host=192.168.0.131
master-user=replication
master-password=slave
master-port=3306
 
log-bin                     #information for becoming master added
binlog-do-db=horde
 
[mysql.server]
user=mysql
basedir=/var/lib
 
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

 

7.
Create a replication slave account on master2 for master1

mysql> grant replication slave on *.* to ‘replication’@192.168.0.131 identified by ‘slave2’;

8.
Edit my.cnf on master1 for information of its master.

#vim /etc/my.cnf

Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
 
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
 
#master
log-bin
binlog-do-db=adam
binlog-ignore-db=mysql
binlog-ignore-db=test
server-id=1
 
#information for becoming slave.
master-host=192.168.0.132
master-user=replication
master-password=slave2
master-port=3306
 
[mysql.server]
user=mysql
basedir=/var/lib

9.

Restart both mysql master1 and master2.

On mysql master1:
mysql> start slave;

On mysql master2:
mysql > show master status;

On mysql master 1:
mysql> show slave statusG;

*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.132
Master_User: replication
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: Mysql1MYSQL02-bin.000008
Read_Master_Log_Pos: 410
Relay_Log_File: Mysql1MYSQL01-relay-bin.000008
Relay_Log_Pos: 445
Relay_Master_Log_File: Mysql1MYSQL02-bin.000008
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: 410
Relay_Log_Space: 445
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: 103799
1 row in set (0.00 sec)

ERROR:
No query specified

make sure its running.

Now you can create tables in the database and you will see changes in slave. Enjoy!!

vimrc

February 23, 2007|Linux|電腦編程

CentOS 4.4
/etc/vimrc

set background=dark    “brighter the color
set ai
set smartindent

...102030...70717273...100...

 

如果你喜歡我的文章,請幫忙按 1-10次 LikeButton 化讚為賞,非常感謝!越喜歡當然可以越按越多 😛

搜尋 Search

簡介 Bio

香港人,現居南十字星空下。

為人貪心,科技、生活、財經、散文 皆有興趣,周身刀冇張利。

思想矛盾,喜歡現在work-life balance 既生活又懷念a city never sleep。

 

每月送我一杯咖啡支持我: liker.land/hang321




分類 Categories

  • 好文閱讀
  • 時事評論
  • 未分類
  • 生活記事
  • 科技資訊
  • 金融財經
  • 電腦編程
  • 音樂電影

文章存檔 Archives




熱門文章 Popular Posts

  • Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8)
    Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8) June 8, 2015
  • 呢幾日個blogger 有問題….
    呢幾日個blogger 有問題…. October 28, 2004
  • assembly
    assembly February 11, 2006
  • 新工作
    新工作 January 6, 2009
  • 嫁人要嫁工程師
    嫁人要嫁工程師 April 27, 2006

標籤雲 Tag Cloud

CentOS Character chroot Cluster crash cryptography DD-WRT debug Domino DSM Dual Core DWA email ESXi GCP git google HylaFax IE Java Javascript JRE LikeCoin Linux log LotusScript mint MX MySQL nginx PKI PowerShell Qwiklabs srt telent VMware vpn vSphere WinXP wordpress XPEnology 專欄 網絡資訊 選股 風帆

日曆 Calendar

June 2025
M T W T F S S
  « Feb    
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Follow Me

Follow Us on RSSFollow Us on TwitterFollow Us on YouTube

文章存檔 Archives

Copyright © 2004-2021 hang321.net. All Rights Reserved