标签:des style blog http io os 使用 ar for
一、说明
| 服务器 | 主机名 | IP | serverID | mysql版本 | 系统 |
|
master1
|
db1
|
172.28.26.101
|
101
|
mysql5.5.15 | Centos 6.4 |
| master2 |
db2
|
172.28.26.102
|
102
|
mysql5.5.15
|
Centos 6.4
|
| slave1 |
db3
|
172.28.26.188
|
188
|
mysql5.5.15
|
Centos 6.4
|
| slave2 |
db4
|
172.28.26.189
|
189
|
mysql5.5.15
|
Centos 6.4
|
|
monitor
|
monitor
|
172.28.26.103
|
无 | ? |
Centos 6.4
|
| VIP | Role | description |
| 172.28.26.104 | write | 应用配置的写入VIP |
| 172.28.26.105 | read |
应用配置的读入VIP
|
| 172.28.26.106 | read |
应用配置的读入VIP
|
|
1
2
3
4
5
6
|
tar -zxvf mysql-5.5.15.tar.gzcd mysql-5.5.15cmake -DCMAKE_INSTALL_PREFIX:PATH=/data/mysql/navy1 -DMYSQL_DATADIR=/data/mysql/navy1/db -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1makemake installuseradd mysql -s /sbin/nologin; cd /data/mysql/navy1; chown mysql:mysql db/ logs/ -R |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
[mysqld_safe]log-error=/data/mysql/navy1/logs/mysqld.logpid-file=/data/mysql/navy1/logs/mysqld.pid[client]port = 3306socket = /data/mysql/navy1/logs/mysql.sock[mysqld]port = 3306socket = /data/mysql/navy1/logs/mysql.sockkey_buffer = 384Mmax_allowed_packet = 1Mtable_cache = 512sort_buffer_size = 2Mread_buffer_size = 2Mread_rnd_buffer_size = 8Mmyisam_sort_buffer_size = 64Mthread_cache_size = 8query_cache_size = 64Mbasedir=/data/mysql/navy1datadir=/data/mysql/navy1/dbthread_concurrency = 8log-bin=mysql-binbinlog_format = mixedserver-id = 101max_connections=2048character_set_server=utf8wait_timeout=1800interactive_timeout=1800skip-show-databaseskip-name-resolvetmp_table_size = 512Mmax_heap_table_size = 512Mbinlog-ignore-db = mysqlreplicate-ignore-db = mysqlbinlog-ignore-db = information_schemareplicate-ignore-db = information_schemabinlog-ignore-db = performance_schemareplicate-ignore-db = performance_schemabinlog-ignore-db = testreplicate-ignore-db = testinnodb_data_home_dir = /data/mysql/navy1/db#innodb_data_file_path = ibdata1:4000M;ibdata2:10M:autoextendinnodb_file_per_table=1innodb_log_group_home_dir = /data/mysql/navy1/dbinnodb_buffer_pool_size = 2000Minnodb_additional_mem_pool_size = 20Minnodb_log_file_size = 100Minnodb_log_buffer_size = 8Minnodb_flush_log_at_trx_commit = 2innodb_lock_wait_timeout = 50#default-storage-engine = MyISAMdefault-storage-engine = InnoDB[mysqldump]quickmax_allowed_packet = 16M[mysql]no-auto-rehash[isamchk]key_buffer = 256Msort_buffer_size = 256Mread_buffer = 2Mwrite_buffer = 2M[myisamchk]key_buffer = 256Msort_buffer_size = 256Mread_buffer = 2Mwrite_buffer = 2M[mysqlhotcopy]interactive-timeout |
|
1
|
/data/mysql/navy1/scripts/mysql_install_db --user=mysql --basedir=/data/mysql/navy1 --datadir=/data/mysql/navy1/db/ |
|
1
|
cd /data/mysql/navy1; /data/mysql/navy1/bin/mysqld_safe --defaults-extra-file=/data/mysql/navy1/my.cnf --user=mysql & |
|
1
|
useradd mysql -s /sbin/nologin; cd /data/mysql/navy1; chown mysql:mysql db/ logs/ -R |
|
1
|
cd /data/mysql/navy1; /data/mysql/navy1/bin/mysqld_safe --defaults-extra-file=/data/mysql/navy1/my.cnf --user=mysql & |
|
1
2
3
|
grant replication slave on *.* to slave@‘172.28.26.102‘ identified by "123456";grant replication slave on *.* to slave@‘172.28.26.188‘ identified by "123456";grant replication slave on *.* to slave@‘172.28.26.189‘ identified by "123456"; |
|
1
2
3
|
grant replication slave on *.* to slave@‘172.28.26.101‘ identified by "123456";grant replication slave on *.* to slave@‘172.28.26.188‘ identified by "123456";grant replication slave on *.* to slave@‘172.28.26.189‘ identified by "123456"; |
|
1
2
3
4
5
6
7
8
9
10
11
|
mysql> show master status \GERROR 2006 (HY000): MySQL server has gone awayNo connection. Trying to reconnect...Connection id: 3974Current database: *** NONE ****************************** 1. row ***************************File: mysql-bin.000024Position: 107Binlog_Do_DB:Binlog_Ignore_DB: mysql,information_schema,performance_schema,test,mysql,information_schema,performance_schema,test1 row in set (0.00 sec) |
|
1
2
|
change master to master_host=‘172.28.26.101‘, master_Port=3306, master_user=‘slave‘, master_password=‘123456‘, master_log_file=‘mysql-bin.000024‘, master_log_pos=107;slave start; |
|
1
2
3
4
5
6
7
|
mysql> show master status \G*************************** 1. row ***************************File: mysql-bin.000025Position: 107Binlog_Do_DB: navyBinlog_Ignore_DB: mysql,mysql,information_schema,performance_schema,test,mysql,information_schema,performance_schema,test1 row in set (0.00 sec) |
|
1
2
|
change master to master_host=‘172.28.26.101‘, master_Port=3306, master_user=‘slave‘, master_password=‘123456‘, master_log_file=‘mysql-bin.000025‘, master_log_pos=107;slave start; |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
mysql> show slave status \G*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 172.28.26.102Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000025Read_Master_Log_Pos: 107Relay_Log_File: mysqld-relay-bin.000015Relay_Log_Pos: 253Relay_Master_Log_File: mysql-bin.000025Slave_IO_Running: YesSlave_SQL_Running: Yes |
|
1
|
yum -y install mysql-mmm-agent |
|
1
|
yum -y install mysql-mmm* |
|
1
2
|
GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO ‘mmm_agent‘@‘172.28.26.%‘ IDENTIFIED BY ‘123456‘;GRANT REPLICATION CLIENT ON *.* TO ‘mmm_monitor‘@‘172.28.26.%‘ IDENTIFIED BY ‘123456‘; |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
active_master_role writer<host default>cluster_interface eth1pid_path /var/run/mysql-mmm/mmm_agentd.pidbin_path /usr/libexec/mysql-mmm/replication_user slavereplication_password 123456agent_user mmm_agentagent_password 123456</host><host db1>ip 172.28.26.101mysql_port 3306mode masterpeer db2</host><host db2>ip 172.28.26.102mysql_port 3306mode masterpeer db1</host><host db3>ip 172.28.26.188mysql_port 3306mode slavepeer db3</host><host db4>ip 172.28.26.189mysql_port 3306mode slavepeer db4</host><role writer>hosts db1, db2ips 172.28.26.104mode exclusive</role><role reader>hosts db3, db4ips 172.28.26.105,172.28.26.106mode balanced</role> |
peer的意思是等同,表示db1与db2是同等的。
ips指定VIP
mode exclusive 只有两种模式:exclusive是排他,在这种模式下任何时候只能一个host拥有该角色
balanced模式下可以多个host同时拥有此角色。一般writer是exclusive,reader是balanced
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
include mmm_common.conf<monitor>ip 127.0.0.1pid_path /var/run/mysql-mmm/mmm_mond.pidbin_path /usr/libexec/mysql-mmmstatus_path /var/lib/mysql-mmm/mmm_mond.statusping_ips 172.28.26.101,172.28.26.102auto_set_online 10# The kill_host_bin does not exist by default, though the monitor will# throw a warning about it missing. See the section 5.10 "Kill Host# Functionality" in the PDF documentation.## kill_host_bin /usr/libexec/mysql-mmm/monitor/kill_host#</monitor><host default>monitor_user mmm_monitormonitor_password 123456</host>debug 0 |
|
1
2
|
/etc/init.d/mysql-mmm-agent startecho "/etc/init.d/mysql-mmm-agent start" >> /etc/rc.local |
|
1
2
3
4
5
|
[root@monitor ~]# mmm_control showdb1(172.28.26.101) master/ONLINE. Roles: writer(172.28.26.104)db2(172.28.26.102) master/ONLINE. Roles:db3(172.28.26.188) slave/ONLINE. Roles: reader(172.28.26.106)db4(172.28.26.189) slave/ONLINE. Roles: reader(172.28.26.105) |
|
1
2
3
4
5
|
[root@monitor ~]# mmm_control showdb1(172.28.26.101) master/HARD_OFFLINE. Roles:db2(172.28.26.102) master/ONLINE. Roles: writer(172.28.26.104)db3(172.28.26.188) slave/ONLINE. Roles: reader(172.28.26.106)db4(172.28.26.189) slave/ONLINE. Roles: reader(172.28.26.105) |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
mysql> show slave status \GConnection id: 5844Current database: *** NONE ****************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 172.28.26.102Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000025Read_Master_Log_Pos: 107Relay_Log_File: mysqld-relay-bin.000002Relay_Log_Pos: 253Relay_Master_Log_File: mysql-bin.000025Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB: |
本文出自 “屌丝运维男” 博客,请务必保留此出处http://navyaijm.blog.51cto.com/4647068/1230674
标签:des style blog http io os 使用 ar for
原文地址:http://www.cnblogs.com/hllnj2008/p/3990509.html