环境
CentOS
Mysql 5.1
前提
安装了EPEL,具体安装步骤请参照
http://blog.csdn.net/robinsonmhj/article/details/36184863
机器列表
| 机器IP | 机器名 |
| 192.168.0.135 | db1 |
| 192.168.0.136 | monitor |
| 192.168.0.137 | db2 |
| 虚拟IP | 作用 |
| 192.168.0.138 | writter |
| 192.168.0.139 | reader |
| 192.168.0.140 | reader |
安装步骤
1. 在db1 和 db2 上安装mysql
yum install mysql-server
2. 修改配置文件
db1 的配置文件
[mysqld]
datadir = /data/mysql
socket=/data/mysql/mysql.sock
user=mysql
server-id=1
table_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 64M
thread_concurrency = 8
log-bin=mysql-bin
binlog_format = mixed
max_connections=2048
character_set_server=utf8
wait_timeout=1800
interactive_timeout=1800
skip-show-database
skip-name-resolve
tmp_table_size = 512M
max_heap_table_size = 512M
binlog-ignore-db = mysql
replicate-ignore-db = mysql
binlog-ignore-db = information_schema
replicate-ignore-db = information_schema
binlog-ignore-db = performance_schema
replicate-ignore-db = performance_schema
binlog-ignore-db = test
replicate-ignore-db = test
innodb_data_home_dir=/data/mysql/innodb
innodb_data_file_path=ibdata1:2000M;ibdata2:10M:autoextend
innodb_log_group_home_dir=/data/mysql/innodb/log
innodb_file_per_table=1
innodb_buffer_pool_size = 1000M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 100M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 50
default-storage-engine = MyISAM
#default-storage-engine = INNODB
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mysqldump]
quick
max_allowed_packet = 16M
socket=/data/mysql/mysql.sock
[mysql]
no-auto-rehash
socket=/data/mysql/mysql.sock
db2 的配置文件
[mysqld]
datadir = /data/mysql
socket=/data/mysql/mysql.sock
user=mysql
server-id=2
table_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 64M
thread_concurrency = 8
log-bin=mysql-bin
binlog_format = mixed
max_connections=2048
character_set_server=utf8
wait_timeout=1800
interactive_timeout=1800
skip-show-database
skip-name-resolve
tmp_table_size = 512M
max_heap_table_size = 512M
binlog-ignore-db = mysql
replicate-ignore-db = mysql
binlog-ignore-db = information_schema
replicate-ignore-db = information_schema
binlog-ignore-db = performance_schema
replicate-ignore-db = performance_schema
binlog-ignore-db = test
replicate-ignore-db = test
innodb_data_home_dir=/data/mysql/innodb
innodb_data_file_path=ibdata1:2000M;ibdata2:10M:autoextend
innodb_log_group_home_dir=/data/mysql/innodb/log
innodb_file_per_table=1
innodb_buffer_pool_size = 1000M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 100M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 50
default-storage-engine = MyISAM
#default-storage-engine = INNODB
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mysqldump]
quick
m