批量处理多个表

十月 30th, 2009

xaprb上发现的一个工具,很是有用,记录之.

平时在数据库设计的过程中会设计成单个表为分表,比如说POST表最终为一个POST库,这个库有几百个表,对数据进行切分。

在这种情况下,如果添加或者修改字段或者清空数据时就很麻烦了,之前一直是使用自己的脚本进行处理,而Xaprb开发的这个小工具则刚好可以做这个事,呵,以后不用再为类似的事情操心了。

$ wget http://www.maatkit.org/get/mk-find
$ perl mk-find --exec 'TRUNCATE TABLE %D.%N'

%D表示任意数据库
%N表示任意表

对于单个数据库进行操作则如下:

$ wget http://www.maatkit.org/get/mk-find
$ perl mk-find dbname --exec 'TRUNCATE TABLE %D.%N'

作者:张立冰
出处:http://www.libing.name/2009/02/06/mysql-map-data-to-memcachedmysql-map-data-to-memcached.html

差不多在一年前,写过一篇文章介绍将MySQL数据映射到Memcached,当时MySQL和Memcached Functions for MySQL都还不够成熟,时过一年,Memcached Functions for MySQL升级到了0.8版本,而MySQL也发布了GA版本,加上很多朋友反应前一篇文章中的实现他们因种种原因没能成功,于是便有了这篇文章,就当是上一篇文章的升级版本吧。

测试环境在Linux下进行,版本系统为CentOS5.
以下为相关软件,包括其版本和下载地址:

mysql-5.1.30 下载
memcached-1.2.6 下载
libevent-1.4.7-stable 下载
memcached_functions_mysql-0.8 下载
libmemcached-0.26 下载

Read the rest of this entry »

本文权当笔记用: :)

下载相关文件:

wget http://www.sphinxsearch.com/downloads/sphinx-0.9.8-rc2.tar.gz
wget http://www.coreseek.com/uploads/sources/sphinx-0.98rc2.zhcn-support.patch 
wget http://www.coreseek.com/uploads/sources/fix-crash-in-excerpts.patch
wget http://www.coreseek.com/uploads/sources/coreseek_fulltext_2.5.tar.gz
wget http://www.coreseek.com/uploads/sources/mmseg-0.7.3.tar.gz

先安装mmseg:

tar xzf mmseg-0.7.3.tar.gz 
cd mmseg-0.7.3
./configure --prefix=/usr/local/mmseg
 make && make install

再为sphinx打上中文分词的patch:

tar zxvf sphinx-0.9.8-rc2.tar.gz
cd sphinx-0.9.8-rc2
patch -p1 < ../sphinx-0.98rc2.zhcn-support.patch
patch -p1 < ../fix-crash-in-excerpts.patch

安装sphinx:

./configure --prefix=/usr/local/sphinx --with-mysql=/usr/local/mysql-5.0.50 --with-mysql-includes=/usr/local/mysql-5.0.50/include/mysql/ --with-mysql-libs=/usr/local/mysql-5.0.50/lib/mysql --with-mmseg-includes=/usr/local/mmseg/include/mmseg --with-mmseg-libs=/usr/local/mmseg/lib
make & make install

笔记完成!

Random Tips

四月 6th, 2008

php5.3的新特性: Slides

*Namespace

*MySQLnd -更高效的MySQL For PHP

* And so on &

两个函数的异同:

*htmlentities

*htmlspecialchars

别搞混了,后果很严重 &

————美丽的分隔线————

Sendmail和垃圾邮件

*不可缺少MX记录

*别忘了反向解析,试试Telnet X.X.X.X 25, 域名应当出现在里边

*多队列,M4和Sendmail.cf,Q*,别忘了mkdir,Fo0.com?:)

*还有您的磁盘

[root@nd ~]# du /var/spool/mail/root -h
6.5G /var/spool/mail/root
[root@nd ~]# du /var/spool/mqueue/ -h
973M /var/spool/mqueue/q6
969M /var/spool/mqueue/q3
972M /var/spool/mqueue/q2
978M /var/spool/mqueue/q5
978M /var/spool/mqueue/q4
986M /var/spool/mqueue/q1
5.8G /var/spool/mqueue/

*清除您的邮件队列(2 times ||  bad mx record)

*rm -rf?:)&^%

————美丽的分隔线————

MySQL的字符集

*大小写不区分,select  X fromxxx where x=LiBInG === select X fromxxx where x=libing

*X_ci ==>X_bin ?

*是否有更完美的解决办法?

一个叫Kickfire的东西

*stream based sql-queries process

*have no test..:)

*it sounds good ..:)

————邪恶的分隔线————

夜深人静,早睡早起 ^_^

By:matt

Ref:http://www.bigdbahead.com/?p=46

As I run into the same mistake over and over again I am going to throw them out here in order to serve as a warning and a learning tool to others. Some of these may seem like I am beating a dead horse because you can find examples of these on other sites, in other blogs, or even in the manual. Despite the large amounts of data on the subjects these things still pop up. This is not a complete list, and this list is not in any order… so please don’t dispare if I miss your favorite common performance gaff. As I encounter more I will post them to the common mistakes category here on bigdbahead.com. Hopefully this list will grow to include a large subset of issues and maybe one or two people will take note and fix their applications and databases.

Read the rest of this entry »