CentOS下配置MySQL Master-Master的步骤
2011-07-27 11:40
387 查看
配置mysql
1.GRANT REPLICATION SLAVE ON *.* TO 'replication'@'%' IDENTIFIED BY 'replpassword'; #配置复制账号
2.GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'%' IDENTIFIED BY 'monpassword'; #配置监控账号
3.GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'%' IDENTIFIED BY 'agentpassword'; #配置监控代理账号
4.FLUSH PRIVILEGES; #刷新权限
配置主host
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
replicate-do-db=exam
replicate-ignore-db=
log-slave-updates
slave-skip-errors=all
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=1
master-host = 10.3.1.25
master-user = replication
master-password = replpassword
master-port = 3306
配置slave主机
log-bin=mysql-bin
binlog_format=mixed
server-id = 2
replicate-do-db=exam
replicate-ignore-db=
log-slave-updates
slave-skip-errors=all
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=2
master-host = 10.3.1.17
master-user = replication
master-password = replpassword
master-port = 3306
升级perl到5.12.2-----------此种方法失败
1、wget http://www.cpan.org/src/5.0/perl-5.12.2.tar.gz 2、tar -zxvf perl-5.12.2.tar.gz
3、cd perl-5.12.2
4、./Configure -des -Dprefix=/usr/local/perl -Duseithreads Configure #开启多线程,否则monitor不运行
5、make test
6、make install
7、mv /usr/bin/perl /usr/bin/perl.bak
8、ln -s /usr/local/perl/bin/perl /usr/bin/perl
更新perl模块
cpan -i Algorithm::Diff Class::Singleton DBI DBD::mysql Log::Dispatch Log::Log4perl Mail::Send Net::Ping Proc::Daemon Time::HiRes Params::Validate Net::ARP
安装mmm
1. cd /usr/local/
2. mkdir mmm
3. cd mmm
4. wget http://mysql-mmm.org/_media/:mmm2:mysql-mmm-2.2.1.tar.gz -O mysql-mmm-2.2.1.tar.gz
5. tar -xzvf mysql-mmm-2.2.1.tar.gz
6. cd mysql-mmm-2.2.1
7. make, make install
8. mv /MMM /usr/local/perl/lib/5.12.2/
9. cd /etc/mysql-mmm/
10.ls
------------------------------------- monitor 启动失败,需要perl支持多线程-------
使用 yum 搞定
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm yum install mysql-mmm* -y
11.修改配置文件
10.3.1.17 主数据库,mmm_common.conf:
active_master_role writer
<host default>
cluster_interface eth0
pid_path /var/run/mmm_agentd.pid
bin_path /usr/lib/mysql-mmm/
replication_user replication #对应上面mysql配置时的用户名
replication_password replpassword #对应上面mysql配置时的密码
agent_user mmm_agent #对应上面mysql配置时的用户名
agent_password agentpassword #对应上面mysql配置时的密码
</host>
<host db1>
ip 10.3.1.17 #实际ip
mode master
peer db2
</host>
<host db2>
ip 10.3.1.25 #实际ip
mode master
peer db1
</host>
<role writer>
hosts db1, db2
ips 10.3.1.110 #虚ip,程序调用虚ip,由mmmm负责转向实际ip
mode exclusive
</role>
<role reader>
hosts db1, db2
ips 10.3.1.111,10.3.1.112 #虚ip,程序读取时对应的ip ,这个配置可以用户读写分离
mode balanced
</role>
10.3.1.25,次数据库配置
mmm_common.conf同上
mmm_agent.conf:
include mmm_common.conf
this db2
10.3.1.24,监控器配置
include mmm_common.conf
<monitor>
ip 127.0.0.1
pid_path /var/run/mmm_mond.pid
bin_path /usr/lib/mysql-mmm/
status_path /var/lib/misc/mmm_mond.status
ping_ips 10.3.1.17, 10.3.1.25 #实际ip
</monitor>
<host default>
monitor_user mmm_monitor #对应上面的mysql账号
monitor_password monpassword
</host>
debug 0
启动
10.3.1.17:/etc/init.d/mysql-mmm-agent start
10.3.1.25:/etc/init.d/mysql-mmm-agent start
10.3.1.24:/etc/init.d/mysql-mmm-monitor start
自动启动
/sbin/chkconfig --del mysql-mmm-agent
/sbin/chkconfig --add mysql-mmm-agent
10.3.1.24:
mmm_control set_online db1
mmm_control set_online db2 #保证虚地址生效
mmm_control show
mmm_control checks
17/25需要打开9989端口
安装完成,测试一下,发现/etc/init.d/mysql-mmm-agent stop后再启动失败,需要重启服务器才能再次启动,没有找到原因,有可能是mmm还不是正式版的原因吧.看样子mmm还不能用于生产环境,回头试一下配置linux heartbeat.
原文:http://blog.csdn.net/hshxf/article/details/6111292#comments
1.GRANT REPLICATION SLAVE ON *.* TO 'replication'@'%' IDENTIFIED BY 'replpassword'; #配置复制账号
2.GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'%' IDENTIFIED BY 'monpassword'; #配置监控账号
3.GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'%' IDENTIFIED BY 'agentpassword'; #配置监控代理账号
4.FLUSH PRIVILEGES; #刷新权限
配置主host
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
replicate-do-db=exam
replicate-ignore-db=
log-slave-updates
slave-skip-errors=all
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=1
master-host = 10.3.1.25
master-user = replication
master-password = replpassword
master-port = 3306
配置slave主机
log-bin=mysql-bin
binlog_format=mixed
server-id = 2
replicate-do-db=exam
replicate-ignore-db=
log-slave-updates
slave-skip-errors=all
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=2
master-host = 10.3.1.17
master-user = replication
master-password = replpassword
master-port = 3306
升级perl到5.12.2-----------此种方法失败
1、wget http://www.cpan.org/src/5.0/perl-5.12.2.tar.gz 2、tar -zxvf perl-5.12.2.tar.gz
3、cd perl-5.12.2
4、./Configure -des -Dprefix=/usr/local/perl -Duseithreads Configure #开启多线程,否则monitor不运行
5、make test
6、make install
7、mv /usr/bin/perl /usr/bin/perl.bak
8、ln -s /usr/local/perl/bin/perl /usr/bin/perl
更新perl模块
cpan -i Algorithm::Diff Class::Singleton DBI DBD::mysql Log::Dispatch Log::Log4perl Mail::Send Net::Ping Proc::Daemon Time::HiRes Params::Validate Net::ARP
安装mmm
1. cd /usr/local/
2. mkdir mmm
3. cd mmm
4. wget http://mysql-mmm.org/_media/:mmm2:mysql-mmm-2.2.1.tar.gz -O mysql-mmm-2.2.1.tar.gz
5. tar -xzvf mysql-mmm-2.2.1.tar.gz
6. cd mysql-mmm-2.2.1
7. make, make install
8. mv /MMM /usr/local/perl/lib/5.12.2/
9. cd /etc/mysql-mmm/
10.ls
------------------------------------- monitor 启动失败,需要perl支持多线程-------
使用 yum 搞定
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm yum install mysql-mmm* -y
11.修改配置文件
10.3.1.17 主数据库,mmm_common.conf:
active_master_role writer
<host default>
cluster_interface eth0
pid_path /var/run/mmm_agentd.pid
bin_path /usr/lib/mysql-mmm/
replication_user replication #对应上面mysql配置时的用户名
replication_password replpassword #对应上面mysql配置时的密码
agent_user mmm_agent #对应上面mysql配置时的用户名
agent_password agentpassword #对应上面mysql配置时的密码
</host>
<host db1>
ip 10.3.1.17 #实际ip
mode master
peer db2
</host>
<host db2>
ip 10.3.1.25 #实际ip
mode master
peer db1
</host>
<role writer>
hosts db1, db2
ips 10.3.1.110 #虚ip,程序调用虚ip,由mmmm负责转向实际ip
mode exclusive
</role>
<role reader>
hosts db1, db2
ips 10.3.1.111,10.3.1.112 #虚ip,程序读取时对应的ip ,这个配置可以用户读写分离
mode balanced
</role>
10.3.1.25,次数据库配置
mmm_common.conf同上
mmm_agent.conf:
include mmm_common.conf
this db2
10.3.1.24,监控器配置
include mmm_common.conf
<monitor>
ip 127.0.0.1
pid_path /var/run/mmm_mond.pid
bin_path /usr/lib/mysql-mmm/
status_path /var/lib/misc/mmm_mond.status
ping_ips 10.3.1.17, 10.3.1.25 #实际ip
</monitor>
<host default>
monitor_user mmm_monitor #对应上面的mysql账号
monitor_password monpassword
</host>
debug 0
启动
10.3.1.17:/etc/init.d/mysql-mmm-agent start
10.3.1.25:/etc/init.d/mysql-mmm-agent start
10.3.1.24:/etc/init.d/mysql-mmm-monitor start
自动启动
/sbin/chkconfig --del mysql-mmm-agent
/sbin/chkconfig --add mysql-mmm-agent
10.3.1.24:
mmm_control set_online db1
mmm_control set_online db2 #保证虚地址生效
mmm_control show
mmm_control checks
17/25需要打开9989端口
安装完成,测试一下,发现/etc/init.d/mysql-mmm-agent stop后再启动失败,需要重启服务器才能再次启动,没有找到原因,有可能是mmm还不是正式版的原因吧.看样子mmm还不能用于生产环境,回头试一下配置linux heartbeat.
原文:http://blog.csdn.net/hshxf/article/details/6111292#comments
相关文章推荐
- CentOs 7.*中配置安装phpMyAdmin的完整步骤记录
- CentOS下配置Django环境步骤
- BIND服务基础及DNS Master服务器配置步骤
- CentOS 6.4系统下编译安装LNMP和配置PHP环境具体步骤
- centos 系统下安装配置FastDFS步骤分享
- CentOS 7配置静态IP步骤
- CentOS 7.0系统安装配置步骤详解
- centos 6.5内核编译步骤及配置详解
- centos配置nfs服务详细步骤(centos开启nfs服务)
- 保存退出vi编辑以及CentOS 系统安装配置步骤详解
- CentOS 6.5-x86_64的远程yum源配置步骤
- centOS5.5下配置vnc的步骤分享
- centOS5.5下配置vnc的步骤分享(开启linux远程桌面)
- Centos6 Hadoop2.2.0完全安装配置步骤20140222
- centos 6.5内核编译步骤及配置详解
- MySQL的Master-Slave复制配置步骤
- [Java平台架构-1.2]CentOS 5.x上配置JBoss6.X步骤图解
- centos 系统下安装配置FastDFS步骤分享
- 安装MySQL先复制1. Linux (CentOS 7.3) 下快速安装Mysql数据库(安装教程)2.后复制阿里云配置 MySQL 远程连接的详细步骤
- centos配置nfs服务详细步骤(centos开启nfs服务)