Mysql Replication的安装和配置
--------------Mysql Install---------------------
#vi install_mysql.sh
groupadd mysql && useradd -g mysql mysql
tar zxvf mysql-5.0.33.tar.gz && cd mysql-5.0.33 && ./configure '--prefix=/usr/local/mysql' '--with-mysqld-ldflags=-all-static' '--with-mysqld-user=mysql' '--with-charset=cp932' '--with-pthread' 'cflags=-o3' 'cxxflags=-o3' 'cxx=gcc' && make && make install
cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql
bin/mysql_install_db --user=mysql
chown -r root .
chown -r mysql var
chgrp -r mysql .
bin/mysqld_safe --user=mysql &
/usr/local/mysql/bin/mysqld_safe --user=mysql &
#chmod 755 install_mysql.sh
#./install_mysql.sh
-------------Mysql Replication Setup------------
# The MySQL server
[mysqld]
port = 3306
server-id = 172
#log-bin
master-host = 10.99.1.171
master-user = slave
master-password = slave
master-port = 3306
slave-skip-errors = 1050,1007,1051,1062
read-only
socket = /tmp/mysql.sock
skip-locking
key_buffer = 384M
max_allowed_packet = 1M
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 = 32M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8
在master执行:
mysql>GRANT FILE ON *.* TO slave@'%' IDENTIFIED BY 'slave';
mysql>GRANT REPLICATION SLAVE ON *.* TO slave@'%' IDENTIFIED BY 'slave';
mysql>flush privileges;
修改slave的my.cnf:
master-host = 10.99.1.181
master-user = slave
master-password = slave
master-port = 3306
server-id = 182
slave-skip-errors = 1050,1007,1051,1062
read-only
master-host = 10.99.1.181
master-user = slave
master-password = slave
master-port = 3306
server-id = 183
slave-skip-errors = 1050,1007,1051,1062
read-only