利用Federated引擎进行mysql复制
Accessing Distributed Data with the Federated Storage Engine
http://dev.mysql.com/tech-resources/articles/mysql-federated-storage.html
Federated存储引擎可以使几台数据库逻辑上组成一个数据库,其作用相当于Oracle的数据库链接,通俗地说,即在本地建立远程的数据库表的引用。
Mysql需要5.0以上
(1)查看是否安装了federated引擎
show engines;
Engine Support Comment Transactions XA Savepoints
MEMORY YES Hash based, stored in memory, useful for temporary tables NO NO NO
FEDERATED NO Federated MySQL storage engine
MyISAM YES Default engine as of MySQL 3.23 with great performance NO NO NO
BLACKHOLE YES /dev/null storage engine (anything you write to it disappears) NO NO NO
MRG_MYISAM YES Collection of identical MyISAM tables NO NO NO
CSV YES CSV storage engine NO NO NO
ARCHIVE YES Archive storage engine NO NO NO
InnoDB DEFAULT Supports transactions, row-level locking, and foreign keys YES YES YES
从中可以看出federated引擎没有开启
windows下在my.ini中加入federated,即可开启;而在linux中,需要编译时加入选项,再在my.ini中加入federated,即可开启。
(2)建立远程数据库表链接
比如:在server1中有一个数据库db1,在server2中有db1,其中server1.db1为写,server.db1为备份;假设在两个服务器db1中分别有一个表a,在server1.db1中建立server2.db1.a的链接
create table remote_a ...... engine=federated connection = 'mysql://root:123456@server2:3306/db1/a';
(3)创建触发器
delimiter ;;
create trigger copy_a_insert after insert on a for each row begin 向remote_a插入数据 end;;
create trigger copy_a_update after update on a for each row begin 向remote_a更新数据 end;;
create trigger copy_a_delete after delete on a for each row begin 向remote_a删除数据 end;;
delimiter ;
这样在向server1.db1.a中插入数据时,调用触发器copy_a_insert,向remote_a插入数据,而remote_a是对serve
相关文档:
转自:http://www.yayu.org/look.php?id=113
1:在终端下:mysql -V。
以下是代码片段:
[shengting@login ~]$ mysql -V
mysql Ver 14.7 Distrib 4.1.10a, for redhat-linux-gnu (i686)
2:在mysql中:mysql> status;
以下是代码片段:
mysql> status;
--------------
mysql ......
Real example:
/*************************by garcon1986*********************************************************/
<?php
// get the values from entreprise creation form
$secteur = $_POST['secteur'];
$nom = $_POST['nom_entreprise'];
$taille = $_POST['taille_entreprise'];
$concurrent = $_POST[' ......
来源:http://blog.csdn.net/ldb2741/archive/2010/02/25/5325161.aspx
做项目时由于业务逻辑的需要,必须对数据表的一行或多行加入行锁,举个最简单的例子,图书借阅系统。假设 id=1 的这本书库存为 1 ,但是有 2 个人同时来借这本书,此处的逻辑为
view plaincopy to clipboardprint?
Select restnum&nbs ......
Twitter公司一位名叫Ryan King的工程师日前向博客MyNoSQL透露,公司计划从MySQL迁移到Cassandra数据库,因为后者具有更大的弹性、可扩展性和大量的社区网络开源开发人员。
我们有大量的数据,在数据巨大,增长率正在加速的情况下,我们需要一个系统,它可以更为自动化,并高度可靠、可用。Ryan K ......