一)环境拓扑今天讨论的是mysql集群这一块,资源如下所示:
二)Mysql安装配置这里不一一赘述,可以选择源代码编译安装,也可以参考我之前的一篇博文“懒人“速成——linux LAMP环境。三)节点配置主节点: 1.
首先在数据库中建立2个数据库和表:| 1234567 | #service mysqld start#mysqlmysql>create database www;mysql>use www;mysql>create table www(id int);mysql>insert into www values(1);mysql> select * from www; |
查看数据: ;同理创建blog数据库和表:
| 12345 | mysql>create database blog;mysql>use blog;mysql>create table blog(id int);mysql>insert into blog values(1);mysql> select * from blog; |
2.修改My.cnf配置文件| 123456789101112131415161718192021222324 | [mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0log-bin=mysql-bin server-id =1 binlog-do-db=blog binlog-do-db=www binlog-ignore-db=mysql,test,information_schema innodb_data_home_dir = /usr/local/mysql/data/ innodb_data_file_path = ibdata1:50M:autoextend innodb_log_group_home_dir = /usr/local/mysql/data/innodb_buffer_pool_size = 256M innodb_additional_mem_pool_size = 20Minnodb_log_file_size = 64Minnodb_log_buffer_size = 8Minnodb_flush_log_at_trx_commit = 1innodb_lock_wait_timeout = 50[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid |
3.重启数据库| 1 | [root@Test01 /]# service mysqld restart |
| 12 | Stopping mysqld: [ OK ]Starting mysqld: [ OK ] |
4.创建有权限的账号,让Slave数据库访问主数据库 | 1234567891011 | [root@Test01 /]# mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 3Server version: 5.1.69-log Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type "help;" or "h" for help. Type "c" to clear the current input statement.mysql> |
| 12 | mysql> grant replication slave on *.* to repl@"192.168.1.26" identified by "123456";Query OK, 0 rows affected (0.00 sec) |
| 12 | mysql>flush privileges;; |
注意:格式:GRANT REPLICATION SLAVE ON *.* TO "帐号"@"从服务器IP或主机名" IDENTIFIED BY "密码";
5.备份Master数据库 | 123456789 | mysql> flush tables with read lock; 同时取得快照,并记录日志和偏移量:mysql> show master status;+------------------+----------+--------------+-------------------------------+| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |+------------------+----------+--------------+-------------------------------+| mysql-bin.000001 | 196 | blog,www | mysql,test,information_schema |+------------------+----------+--------------+-------------------------------+1 row in set (0.00 sec) |
如何把视频文件直接存储到MySQL数据库里Linux MySQL 密码修改相关资讯 MySQL Slave
- 解决MySQL Slave同步问题 (10/22/2015 20:12:22)
- MySQL Slave异常关机的处理 (pt- (07/16/2014 10:08:32)
- MySQL Slave relay_log损坏修复 (04/19/2013 09:13:05)
| - slave have equal MySQL Server (02/16/2015 21:35:00)
- MySQL Slave异常关机的处理 (07/16/2014 10:04:24)
- 用meb搭建MySQL Master/Slave (04/17/2013 08:26:10)
|
本文评论 查看全部评论 (0)