快捷搜索:   nginx

Linux MYSQL数据同步机制

1.安装

# tar zxvf .tar.gz    //解压mysql

进入解压目录:

# ./configure --prefix=/usr/local/mysql --enable-assembler --with-client-ldflags--all-static --with--ldflags=-all-static --disable-shared

# make

# make install

增加用户:

# groupadd mysql

# useradd -g mysql mysql

设置path环境变量:

#export PATH=$PATH:/usr/local/mysql/bin

#cd /usr/local/mysql/share/mysql

#cp my-huge.cnf /etc/my.cnf

# cp mysql.server /etc/init.d/mysqld

# chmod 700 /etc/init.d/mysqld

# cd /usr/local/mysql/bin

# ./mysql_install_db

# cd /usr/local/

# chmod 750 mysql -R
# chgrp mysql mysql -R
# chown mysql mysql/var -R
# chkconfig --add mysqld
# chkconfig --level 345 mysqld on
# service mysqld start

# netstat -atln 看看有没有3306的端口打开

2.配置

/etc/my.cnf文件,设置如下参数:

1.Key_buf:索引缓冲区,假设2GB内存,可设置它为384M

2.Sort_buffer_size :排序缓冲区大小,设为2M

3.Record_buffer_size :顺序扫描缓冲区,2M

4.max_connections:允许同时客户数量,3000

5.Query_cache_size:查询缓冲,32M

3.设置mysql同步

GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%.mydomain.com' IDENTIFIED BY 'slavepass';

在master机上/etc/my.cnf文件里[mysqld]区段修改参数

log-bin

server-id=1

sql-bin-update-same

binlog-do-db=vpopmail       #同步数据库名

把数据库文件拷贝到slave机上(注意修改读取权限)

重起mysql

在slave机上/etc/my.cnf文件里[mysqld]区段修改参数

master-host=192.168.0.1

master-user=root

master-password=root

paster-port=3306

server-id=2

master-connect-retry=60

replicate-do-db=vpopmail

重起mysql

顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论