MySQL高级技术

MySQL高级技术,各种优化,提高,技巧等。

[MySQL 5.1 体验]MySQL 实例管理器 mysqlmanager 初试

MySQL实例管理器(IM)是通过TCP/IP端口运行的后台程序,用来监视和管理MySQL数据库服务器实例。MySQL实例管理器适合Unix-类操作系统和Windows。

可以在mysqld_safe脚本使用MySQL实例管理器来启动和停止MySQL服务器,甚至可以从一个远程主机。MySQL实例管理器还执行mysqld_multi脚本的功能(和大多数语法)。

一、 mysqlmanager 配置文件
一个最常见的 mysqlmanager 配置文件如下:

[manager]
port	= 1999
socket	= /tmp/manager.sock
pid-file= /tmp/manager.pid
run-as-service	= true
monitoring-interval	= 10
default-mysqld-path	= /usr/local/mysql/bin/mysqld
password-file = /etc/mysqlmanager.passwd

技术相关:

MySQL复制 自动监控脚本

MySQL复制 自动监控脚本

#!/bin/sh
#
# created by yejr, 2007/06/03
#
# 本脚本用于监控MySQL 复制是否运行,并且根据具体的错误代码自动判断是否忽略
#

now=`date +"%Y%m%d%H%M%S"`

StatFile="./slave_status.$now"

echo "show slave status\G" | mysql -uroot -pmypasswd > $StatFile

#取得 io_thread, sql_thread, last_errno 的状态
IoStat=`cat $StatFile | grep Slave_IO_Running | awk '{print $2}'`
SqlStat=`cat $StatFile | grep Slave_SQL_Running | awk '{ print $2}'`
Errno=`cat $StatFile | grep Last_Errno | awk '{print $2}'`
Behind=`cat $StatFile | grep Seconds_Behind_Master | awk '{print $2}'`

#IoStat=`cat $StatFile | head -n 12 | tail -n 1 | awk '{print $2}'`

技术相关:

FreeBSD 下的 MySQL 备份方案

FreeBSD 下的 MySQL 备份方案

核心提示:如何在 FreeBSD 下实现 MySQL 的全量及增量备份,确保数据的最大可靠性。在这里利用了 MySQL 的复制以及新版本的 FreeBSD 集成的快照功能。

技术相关:

Fun with Opterons, SATA, and INNODB

原文来自: http://www.feedblog.org/2007/05/fun_with_optero.html

We've been doing a lot of performance analysis of MySQL and SATA disks over the last few days and I wanted to get some thoughts out in the open to see what you guys thought.
Now that Debian Etch is out we're seriously looking at making the jump to a full 64bit OS with 8G of memory on each of our boxes.
This also involves benchmarking SATA and potentially migrating away from MyISAM which, while very trusty, is seriously showing its age for us.
First off is raw IO tuning.
XFS benchmarks show about a 20% performance boost from bonnie++ over ext3. This is pretty obvious. Tuning readahead with 'blockdev' didn't seem to help performance much. SATA seems pretty tuned when compared to hdparm and IDE drives.

技术相关:

如何通过 PHP 取得 MySQL procedure 的多结果集

之前写过了 如何通过 PHP 取得 MySQL procedure 结果,不过按照那种方法还不能适应多结果集的情况。所谓的多结果集,就是指在存储过程中,有多次 SELECT 查询,行程多个结果集。解决的办法还是用 mysqli 提供的函数 mysqli_multi_query() 来做,如下例:

$mysqli = new mysqli("localhost", "root", "", "test");

if (mysqli_connect_errno()) {
  printf("Connect failed: %s\n", mysqli_connect_error());
  exit();
}

$query = "call yejr();";

$mysqli->multi_query($query);
while($mysqli->more_results())
{
  if ($result = $mysqli->store_result()) {
    while ($row = $result->fetch_row()) {

技术相关:

设置MySQL复制时,replicate-ignore-db模式下如何正常工作

在复制中,如果启用参数 replicate-ignore-db / replicate-do-db 后想要让复制正常运行,只需在连接数据库后不执行 "use db" 语句即可,如果是在php中,连接数据库后,不再执行 mysql_select_db() 即可。这是因为复制机制会判断是否使用了 replicate-do(ignore)-db 参数,然后判断当前数据库是否为指定的数据库,如果是,才执行相应的binlog,否则略过。如果不指定数据库的话,就可以忽略这个环节了。

InnoDB Performance Optimization

原文来自: http://mysqldatabaseadministration.blogspot.com/2007/04/innodb-performan...

I am sitting in the session "InnoDB Performance Optimization" by Heikki Tuuri and Peter Zaitsev. This is going to be the last session of a very enjoyable and informative MySQL Conference and Expo 2007.

General Application Design is Paramount
Of course, you should design your schema, indexes and queries right. Storage engines aspects are often fine tuning. Storage engine selection may affect your schema layout and indexes.

Each storage engine has unique design and operating properties. App written for 1 storage engine may not perform best with other storage engines. Special optimizations exist for each storage engine.

Google and MySQL

原文来自: http://mysqldatabaseadministration.blogspot.com/2007/04/google-and-mysql...

Chip Turner and Mark Callaghan are presenting the session "MySQL: The Real Grid Database"

Data is sharded vertically and they have a lots of replicas. Resharding is a bigger pain than sharding. Make really smart software and manage with least human resources as possible. They are going to talk about problems that matter to them.

The Grid database approach: deploy a large number of small servers.
Use highly redundant commodity components.
Added capacity has a low incremental cost.
Not much capacity lost when a server fails.
Which allows them to support many servers with a few DBAs.

技术相关:

YouTube and MySQL

原文来自: http://mysqldatabaseadministration.blogspot.com/2007/04/youtube-and-mysq...

Paul Tuckfield of YouTube is giving a keynote. He has been sysadmin for 25 years, Oracle DBA for 15 years and MySQL DBA for 8 months.

For them, MySQL is one (important) piece of scalability. Top reasons for YouTube Scalability includes drinking :).

Top reasons for YouTUbe database scalability include Python, Memcache and MySQL replication. WHat you can do with Python, you can't do with other scripting languages. The fastest query on the database is that is never sent to the database.

技术相关:

Using the New MySQL Query Profiler

原文来自: http://dev.mysql.com/tech-resources/articles/using-new-query-profiler.html

One of the great things about MySQL is the superior innovation model that’s used to deliver database server software. Rather than relying solely on internal engineers who create and maintain a piece of software (as in a traditional software company), MySQL partners with the millions of active users across the world who take advantage of the open source model and daily extend the MySQL server to do new and pioneering things. These innovations can then be submitted to MySQL AB, tested, validated, and rolled into the database server so everyone can benefit from the creativity of the very active MySQL community.

技术相关:

页面

Subscribe to RSS - MySQL高级技术