大欢乐网

终于把compiz装上了,有了一个让人头晕的桌面

Linux — 作者 gladness @ 13:23
昨天晚上,在我的ubuntu上折腾到1点,只把XGL装上了。compiz和compiz-plugins都因为依赖关系问题始终没装上。今天突然试了 一下其他的几个包,结果把compiz-vanilla相关的几个包装上了。发现桌面也可以有特效了,虽然好像好多特性都没法配,但是效果已经让我很高兴 了。有3D桌面,窗口拉动、最大化时都像是有弹性的,有抖动。窗口的标题栏是半透明的,窗口边上还有阴影等等。总算没白忙活。
下次做培训一定得借着接投影仪的机会show一把,嘿嘿。不过缺点就是不能老转换桌面,会头晕。

贴几张图片:










简单总结,xgl的安装按照ubuntu网站上的说明基本可以了。但是有两点要注意:
1。需要修改Xgl的权限,否则会报类似can't open Xorg.94.log的错误。执行:
sudo chmod ug+s /usr/bin/Xgl
2。需要在startxgl脚本上加上启动输入法的命令,我的startxgl脚本如下:
#!/bin/bash
Xgl :1 -fullscreen -ac -accel xv:pbuffer -accel glx:pbuffer &
export DISPLAY=:1
scim &
exec gnome-session

如果不加scim &,那么将来装上compiz以后,在openoffice里会打不开中文输入法。
xgl安装完成以后,似乎需要重启机器。

compiz的安装,与ubuntu网站上的文档有些不同,主要是安装的包不同。文档中说的compiz compiz-plugins包,安装不上。compis-plugins依赖的csm包,到处也找不到。最后发现装如下几个包也可以出效果:
compiz-vanilla
compiz-vanilla-aiglx
compiz-vanilla-gnome
gset-compiz
其中最后一个包是用来设置和启动各种特效的。



ubuntu6.06下编译MySQL5.0.26(打slow log补丁)

数据库 — 作者 gladness @ 15:28
MySQL的slow log可以用来看执行时间超过指定时间的SQL,但是指定的时间最小只能是一秒,有点太大了。通常是要找那些执行次数很多但每次执行又超不过一秒的SQL。打一个补丁,即可记录所有SQL的详细执行时间。原文见:

为slow log打补丁的原文
注意这里用了prefix,是因为机器还有一个mysql5.0.22,我不想引发冲突。

brum@brum-laptop:~/mysql-5.0.26$ ./configure --prefix=/usr/local/mysql
....
....
checking for termcap functions library... configure: error: No curses/termcap library found

需要安装libncurses5-dev包,安装之后,configure就通过了

补丁从这里下载:

打补丁
brum@brum-laptop:~$ pwd
/home/brum
brum@brum-laptop:~$ patch -p0 < patch.slow-micro.5.0.26.diff
patching file mysql-5.0.26/include/my_time.h
patching file mysql-5.0.26/scripts/mysqldumpslow.sh
patching file mysql-5.0.26/sql/log.cc
patching file mysql-5.0.26/sql/mysqld.cc
patching file mysql-5.0.26/sql/set_var.cc
patching file mysql-5.0.26/sql/set_var.h
patching file mysql-5.0.26/sql/sql_class.cc
patching file mysql-5.0.26/sql/sql_class.h
patching file mysql-5.0.26/sql/sql_parse.cc
patching file mysql-5.0.26/sql/sql_show.cc
patching file mysql-5.0.26/sql/structs.h
patching file mysql-5.0.26/sql-common/my_time.c

brum@brum-laptop:~$ cd mysql-5.0.26/
brum@brum-laptop:~/mysql-5.0.26$ make
brum@brum-laptop:~/mysql-5.0.26$ sudo make install
....
....
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
libtool: install: error: relink `libmysqlclient.la' with the above command before installing it
make[3]: *** [install-pkglibLTLIBRARIES] 错误 1
make[3]: Leaving directory `/home/brum/mysql-5.0.26/libmysql'
make[2]: *** [install-am] 错误 2
make[2]: Leaving directory `/home/brum/mysql-5.0.26/libmysql'
make[1]: *** [install-recursive] 错误 1
make[1]: Leaving directory `/home/brum/mysql-5.0.26'
make: *** [install] 错误 2

brum@brum-laptop:~/mysql-5.0.26$ find -name libz*
./zlib/libz.la
./zlib/.libs/libz.so.1.2.3
./zlib/.libs/libz.so.1
./zlib/.libs/libz.so
./zlib/.libs/libz.a
./zlib/.libs/libz.lai
./zlib/.libs/libz.la

brum@brum-laptop:~/mysql-5.0.26$ export LD_LIBRARY_PATH=~/mysql-5.0.26/zlib/.libs

brum@brum-laptop:~/mysql-5.0.26$ sudo make install
....
....
mv: cannot stat `libmysqlclient.so.15.0.0': No such file or directory

今天又抽了些时间,看了看configure --help的帮助,重新configure。首先是用make clean把前面做过的编译都清除。然后:
brum@brum-laptop:~/mysql-5.0.26$ ./configure --prefix=/usr/local/mysql --exec-prefix=/usr/local/mysql

make

sudo make install

brum@brum-laptop:~$ cd /usr/local/mysql/
brum@brum-laptop:~$ mkdir etc
brum@brum-laptop:/usr/local/mysql$ sudo cp /home/brum/mysql-5.0.26/support-files/my-small.cnf /usr/local/mysql/etc/my.cnf
这是为了不修改/etc/my.cnf,因为还有另一个mysql服务。

修改my.cnf中[mysql]和[mysqld]
port = 3307
socket = /usr/local/mysql/var/mysql.sock
这也是为了不与已经存在的mysql冲突

brum@brum-laptop:/usr/local/mysql$ sudo bin/mysql_install_db --user=brum
brum@brum-laptop:/usr/local/mysql$ sudo chown -R root .
brum@brum-laptop:/usr/local/mysql$ sudo chown -R brum var
brum@brum-laptop:/usr/local/mysql$ sudo chgrp -R brum .
brum@brum-laptop:/usr/local/mysql$ bin/mysqld_safe &
服务启动了
连接一下试试
brum@brum-laptop:/usr/local/mysql$ bin/mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 2 to server version: 5.0.26

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql>

好了,成功了。
修改/usr/local/mysql/etc/my.cnf
在[mysqld]中加上
log-slow-queries
long-query-time=0
前 者是让mysql记录slow query;后者是利用前面打的补丁,设置为0的含义是把所有的SQL都记录在slow query log中。如果不打补丁,那么long-query-time最小只能设为1,即1秒,即只有超过1秒的SQL才会记录。打了补丁则没有这个限制了。
随便执行了几个SQL,看一下日志:
brum@brum-laptop:~/mysql-5.0.26$ cat /usr/local/mysql/var/brum-laptop-slow.log
/usr/local/mysql/libexec/mysqld, Version: 5.0.26-log. started with:
Tcp port: 3307 Unix socket: /usr/local/mysql/var/mysql.sock
Time Id Command Argument
# Time: 061104 17:47:22 # User@Host: [brum] @ localhost []
# Query_time: 0.014273 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
use test;
create table test(a int, b varchar(100))engine=innodb;
# Time: 061104 17:47:50 # User@Host: [brum] @ localhost []
# Query_time: 0.000378 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
alter table test modify a auto_increment primary key;
# Time: 061104 17:48:23 # User@Host: [brum] @ localhost []
# Query_time: 0.007990 Lock_time: 0.000329 Rows_sent: 0 Rows_examined: 0
SET insert_id=1;
insert into test(b) values('aaaaa');
# Time: 061104 17:48:31 # User@Host: [brum] @ localhost []
# Query_time: 0.004855 Lock_time: 0.000116 Rows_sent: 0 Rows_examined: 0
SET insert_id=2;
insert into test(b) values('aaaaa');
# Time: 061104 17:48:32 # User@Host: [brum] @ localhost []
# Query_time: 0.000767 Lock_time: 0.000114 Rows_sent: 0 Rows_examined: 0
SET insert_id=3;
insert into test(b) values('aaaaa');
# Time: 061104 17:48:34 # User@Host: [brum] @ localhost []
# Query_time: 0.031763 Lock_time: 0.000115 Rows_sent: 0 Rows_examined: 0
SET insert_id=4;
insert into test(b) values('aaaaa');
# Time: 061104 17:48:40 # User@Host: [brum] @ localhost []
# Query_time: 0.000846 Lock_time: 0.000116 Rows_sent: 4 Rows_examined: 4
select * from test;
# Time: 061104 17:48:43 # User@Host: [brum] @ localhost []
# Query_time: 0.000042 Lock_time: 0.000000 Rows_sent: 4 Rows_examined: 4
# administrator command: Quit;
精确到微秒级了。然后,还可以下载一个mysql_slow_log_parser,在我上面提供的链接中可以下载。

brum@brum-laptop:~/MySQL5.0.26SlowLogPatch$ ./mysql_slow_log_parser /usr/local/mysql/var/brum-laptop-slow.log

Starting...
### 1 Query
### Total time: 0.014273, Average time: 0.014273
### Taking 0.014273 seconds to complete
### Rows analyzed 0
use test;
create table test(a int, b varchar(XXX))engine=innodb;

use test;
create table test(a int, b varchar(100))engine=innodb;


### 1 Query
### Total time: 0.000846, Average time: 0.000846
### Taking 0.000846 seconds to complete
### Rows analyzed 4
select * from test;

select * from test;


### 1 Query
### Total time: 0.000378, Average time: 0.000378
### Taking 0.000378 seconds to complete
### Rows analyzed 0
alter table test modify a auto_increment primary key;

alter table test modify a auto_increment primary key;


### 4 Queries
### Total time: 0.045375, Average time: 0.01134375
### Taking 0.000767 , 0.004855 , 0.007990 , 0.031763 seconds to complete
### Rows analyzed 0, 0, 0 and 0
SET insert_id=XXX;
insert into test(b) values('XXX');

SET insert_id=4;
insert into test(b) values('aaaaa');

每个SQL执行了几遍,总共多少时间,非常清楚。打了补丁以后,可以检测到那些每次执行时间小于1秒而执行次数非常多的SQL。很多时候都是这样的SQL在做怪,把这些SQL进行优化,或者修改程序减少这样的SQL的执行次数,都会大大提高应用的效率。

我之前在RHEL4.0上也装过,非常顺利,
./configure --prefix=/usr/local/mysql
之后,make和make install都没有问题。但在ubuntu6.06上,就需要使用
./configure --prefix=/usr/local/mysql --exec-prefix=/usr/local/mysql

没有仔细去研究原因。

Oracle9.2.0.4 dbca无法启动(segmentation fault)

数据库 — 作者 gladness @ 09:40
操作系统:
[ora9@ARCH1220 ~]$ cat /proc/version
Linux version 2.6.9-5.ELsmp (bhcompile@decompose.build.redhat.com) (gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)) #1 SMP Wed Jan 5 19:30:39 EST 2005

安装oracle9.2.0.4
打了补丁
p4198954_21_linux.zip
p3238244_9204_LINUX.zip
p2617419_210_GENERIC.zip

安装顺利,在运行dbca建库时,报错退出
/u02/app/oracle/product/9.2.0.4/bin/dbca: line 124: 24940 Segmentation fault $JRE_DIR/bin/jre -DORACLE_HOME=$OH -DJDBC_PROTOCL=thin -mx64m -classpath $CLASSPATH oracle.sysman.assistants.dbca.Dbca $ARGUMENTS
上网查文档,查到一篇
Oracle 9i R2 (9.2.0.6) on SUSE LINUX Enterprise Server 9
里面有一段
SEGMENTATION Fault: Metalink note (292278.1). modify dbca script
line #124 with -native
$JRE_DIR/bin/jre -native -DORACLE_HOME=$OH -DJDBC_PROTOCOL=thin -mx64m
即要修改dbca的124行
我找到该行
$JRE_DIR/bin/jre -DORACLE_HOME=$OH -DJDBC_PROTOCOL=thin -mx64m -classpath $CLASSPATH oracle.sysman.assistants.dbca.Dbca $ARGUMENTS
改为
$JRE_DIR/bin/jre -native -DORACLE_HOME=$OH -DJDBC_PROTOCOL=thin -mx64m -classpath $CLASSPATH oracle.sysman.assistants.dbca.Dbca $ARGUMENTS
即加了一个 -native

之后,dbca不会segmentation fault了。


MySQL安装后需要调整什么(大欢乐 译)

数据库 — 作者 gladness @ 21:21
MySQL安装后需要调整什么 大欢乐译

原文连接
http://www.mysqlperformanceblog.com/2006/09/29/what-to-tune-in-mysql-server-after-installation/

面对MySQL的DBA或者做MySQL性能相关的工作的人,我最喜欢问的问题是,在MySQL服务器安装后,需要调整什么,假设是以缺省的设置安装的。

我很惊讶有非常多的人没有合理的回答,很多的MySQL服务器都在缺省的配置下运行。

尽管你可以调整非常多的MySQL服务器变量,但是在通常情况下只有少数的变量是真正重要的。在你设置完这些变量以后,其他变量的改动通常只能带来相对有限的性能改善。

key_buffer_size ---- 非常重要,如果你使用MyISAM表。如果只使用MyISAM表,那么把它的值设置为可用内存的30%到40%。恰当的大小依赖索引的数量、数据量和负载 ----记住MyISAM使用操作系统的cache去缓存数据,所以你也需要为它留出内存,而且数据通常比索引要大很多。然而需要查看是否所有的 key_buffer总是在被使用 ---- key_buffer为4G而.MYI文件只有1G的情况并不罕见。这样就有些浪费了。如果只是使用很少的MyISAM表,你希望它的值小一些,但是仍然 至少要设成16到32M,用于临时表(占用硬盘的)的索引。

innodb_buffer_pool_size ---- 非常重要,如果使用Innodb表。相对于MyISAM表而言,Innodb表对buffer size的大小更敏感。在处理大的数据集(data set)时,使用缺省的key_buffer_size和innodb_buffer_pool_size,MyISAM可能正常工作,而Innodb可 能就是慢得像爬一样了。同时Innodb buffer pool缓存了数据和索引页,因此你不需要为操作系统的缓存留空间,在只用Innodb的数据库服务器上,可以设成占内存的70%到80%。上面 key_buffer的规则也同样适用 ---- 如果只有小的数据集,而且也不会戏剧性地增大,那么不要把innodb_buffer_pool_size设得过大。因为你可以更好地使用多余的内存。

innodb_additional_pool_size ---- 这个变量并不太影响性能,至少在有像样的(decent)内存分配的操作系统中是这样。但是仍然需要至少设为20MB(有时候更大),是Innodb分配出来用于处理一些杂事的。

innodb_log_file_size ---- 对于以写操作为主的负载(workload)非常重要,特别是数据集很大的时候。较大的值会提高性能,但增加恢复的时间。因此需要谨慎。我通常依据服务器的大小(server size)设置为64M到512M。

innodb_log_buffer_size ---- 缺省值在中等数量的写操作和短的事务的大多数负载情况下是够用的。如果有大量的UPDATE或者大量地使用blob,你可能需要增加它的值。不要把它的值 设得过多,否则会浪费内存--log buffer至少每秒刷新一次,没有必要使用超过一秒钟所需要的内存。8MB到16MB通常是足够的。小一些的安装应该使用更小的值。

innodb_flush_logs_at_trx_commit ---- 为Innodb比MyISAM慢100倍而哭泣?你可能忘记了调整这个值。缺省值是1,即每次事务提交时都会把日志刷新到磁盘上,非常耗资源,特别是没有 电池备份的cache时。很多应用程序,特别是那些从MyISAM表移植过来的,应该把它设成2。意味着只把日志刷新到操作系统的cache,而不刷新到 磁盘。此时,日志仍然会每秒一次刷新到磁盘上,因此通常你不会丢失超过1到2秒的更新。设成0会更快一些,但安全性差一些,在MySQL服务崩溃的时候, 会丢失事务。设成2只会在操作系统崩溃的时候丢失数据。

table_cache ---- 打开表是昂贵的(耗资源)。例如,MyISAM表在MYI文件头做标记以标明哪些表正在使用。你不会希望这样的操作频繁发生,通常最好调整你的cache 大小,使其能够满足大多数打开的表的需要。它使用了一些操作系统的资源和内存,但是对于现代的硬件水平来说通常不是问题。对于一个使用几百个表的应用, 1024是一个合适的值(注意每个连接需要各自的缓存)。如果有非常多的连接或者非常多的表,则需要增大它的值。我曾经看到过使用超过100000的值。

thread_cache ---- 线程创建/销毁是昂贵的,它在每次连接和断开连接时发生。我通常把这个值至少设成16。如果应用有时会有大量的并发连接,并且可以看到 threads_created变量迅速增长,我就把它的值调高。目标是在通常的操作中不要有线程的创建。

query_cache ---- 如果你的应用是以读为主的,并且你没有应用级的缓存,那么它会有很大帮助。不要把它设得过大,因为它的维护可能会导致性能下降。通常会设置在32M到 512M之间。设置好后,经过一段时间要进行检查,看看是否合适。For certain workloads cache hit ratio is lower than would justify having it enabled.(这句不会翻译)

注意:就像你看到的,上面所说的都是全局变量。这些变量依赖硬件和存储引擎的使用,而会话级的变量(per session variables)则与特定的访问量(workload)相关。如果只是一些简单的查询,就没有必要增加sort_buffer_size,即使有 64G的内存让你去浪费。而且这样做还可能降低性能。我通常把调整会话级的变量放在第二步,在我分析了访问量(或负载)之后。

此外在MySQL分发版中包含了一些my.cnf文件的例子,可以作为非常好的模板去使用。如果你能够恰当地从中选择一个,通常会比缺省值要好。


WEB应用数据库访问的优化(大欢乐 译)

数据库 — 作者 gladness @ 21:20
原文见:

http://www.mysqlperformanceblog.com/2006/09/12/database-access-optimization-in-web-applications/

WEB应用数据库访问的优化(大欢乐 译)

如果只是少量的页面访问有问题(性能问题)时,优化是非常简单的。如果是“所有的都慢”,那么最好先看看《slow query logs》这篇文章。(http://www.mysqlperformanceblog.com/2006/09/06/slow-query-log -analyzes-tools/)

你需要如何做呢?

看那些来自于数据库并且在页面上显示的信息。这是重要的,因为这些信息是需要用这样或那样的方法从数据库中读取出来的,如果你确实是打算这样显示的话。你的任务就是要使用最高效的方法,从数据库中得到这些信息。

考查这些信息的动态性。如果很少改变,或者干脆就是静态的,那么比较好的方法是预先创建(pre-create)或者缓存(http: //www.mysqlperformanceblog.com/2006/08/09/cache-performance-comparison/)它。有非常多的缓存和预建技术(http://www.mysqlperformanceblog.com/2006/08/08/caching- techinques/)可以使用。只是要记住,优化数据库访问的最好的方法,就是避免访问数据库。这对于其他的类似事情也适用----如果你可以完全避免动态页面的产生,并且使用服务器的缓存来解决,就更好了。

检查从数据库读出的数据与需要显示的信息是否相符。从数据库出读取的信息,往往比生成页面所需要的信息要多。轻一点的像是SELECT * FROM tbl,而不是只列出那些真正需要的列;严重的可以是用SELECT * FROM tbl来计算表中有多少行记录(不是开玩笑)。有时候你会看到查询了100个stories,其中任一个会被选择显示出来,由应用程序层做过滤。有时候在应用程序层这样做是高效的,但是通常应该使查询只返回你需要的信息。

检查结果集的记录数。这是非常重要、而且经常被遗忘的步骤。如果一个查询返回很少的行数,有些人就认为它是简单的,而真正重要的是这个查询分析了多少行数据。比如SELECT COUNT(*) FROM links WHERE domain='mysql.com'; 只返回一行,但却扫描了成千上万的记录(或者索引节点)。其他通常的杀手查询是GROUP BY查询和SORT查询 ---- SELECT name,descr FROM titles ORDER BY rank DESC LIMIT 10 ----如果没有适当的索引,就会使用“filesort”,会有些问题。此外就是JOIN(关联)---- 关联是高代价的(当然是相对的),并且确实增加了为了产生结果集而使用的数据量 ---- 如果你不得不关联10个表来组合出想要的结果,那么会比从一个表中得到同样的数据要慢很多。

检查结果集的生成实际需要的记录数。有时查询需要使用大量数据来产生结果集,是因为没有适当的索引 ---- 这是容易发生的。比如我们的ORDER BY rank 查询就是这样 ---- 为rank列增加索引,会使这个查询仅使用10行数据来返回10行 ---- 恰恰是我们想要的。然而我们的COUNT(*)查询是不同的 ---- 即使在domain列上有索引,它仍然需要扫描很多行数据来得到结果集。这样的查询需要重新设计,而不是简单地调整 ---- 比如汇总表(summary table)保存了每个域的link数量,就可以解决。

检查查询的次数。如果可以使用一个查询得到所需要的数据,那么就好于用多个查询得到同样的数据,前提是这一个查询不会因为与那些查询优化方式不同而需要分析更多行的数据。这里一个典型的例子是SELECT * FROM tbl WHERE id=5 执行了很多次,每次使用不同的常量 ---- 用类似 IN(5,7,4,56) 来替换是非常有效的。但也不要被这样的方法迷住。我曾经看到有人尝试用UNION(需要适当填充以使不同的字段数目及类型能够匹配)连接所有的查询--- -这不是个好主意。然而,如果可以减小查询的次数,而又不会增加应用程序架构的复杂性,那么是值得做的。


redhat linux下执行oracle的dbstart脚本没有反应

数据库 — 作者 gladness @ 11:40
原因:
1./etc/oratab的设置问题,比如:
*:/opt/oracle/product/9.2.0.4:N
ORCL:/opt/oracle/product/9.2.0.4:Y
最右侧是N的,dbstart不会管它,dbstart只启动为Y的。

2.认证方式问题。
oracle9的dbstart是在sqlplus中使用connect / as sysdba,然后用startup命令启动数据。即打算使用操作系统认证。如果$ORACHE_HOME/network/admin/sqlnet.ora中有这样一行:
SQLNET.AUTHENTICATION_SERVICES=(NONE)
那么操作系统认证就被禁止了,dbstart会无法用sqlplus以sysdba登录,也就无法启动数据库了。

3.没有pfile,即文本的初始化参数。
oracle9以后是可以使用spfile的,即二进制的初始化参数文件,因此pfile可以没有。但我看到的dbstart中不知道为何,启动前先找一 下pfile,如果找不到就直接退出,不启动数据库。因此,如果打算用dbstart启动oracle,那么必须要创建一个文本的参数文件,或者干脆去修 改dbstart脚本,把判断参数文件的地方改一下,或者去掉。


Linux下MySQL客户端mysql,select大量数据时可以分页

数据库 — 作者 gladness @ 10:18
在linux下使用mysql(特指MySQL的客户端工具)进行查询,当数据比较多时,很快就一页一页的翻过去了,无法看清数据。
在Linux下是有办法看清每一页的数据的。可以用--pager参数

比如mysql --pager=more
或者mysql --pager=less
这样每显示满一页,就会等待你按键来翻页,比如按空格键。按q则退出此查询,不用等到全部显示完。
如果使用了--pager=less还可以按B键来往前翻页,看已经看过的数据。使用上下箭头键也可以逐行上下移动。

还可以在mysql中使用pager命令,比如
[gulei@ARCH1220 ~]$ mysql EICSNEW
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 15253 to server version: 5.0.17c-pro-gpl-cert

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql>pager less -S
PAGER set to 'less -S'
之后再使用select进行查询,过宽的行(超过屏幕宽度)也不会换行了,可以使用左右箭头键来横滚,数据显示整齐多了。

总之把pager指定为less以后,less的所有功能都可以使用了,包括前后翻页、左右横滚、查找字符串等等。
用man less看一下手册就行了,功能多了。


oracle10g ORA-01536: space quota exceeded for tablespace

数据库 — 作者 gladness @ 16:27

SQL> create table test ( a number,b varchar(100));
create table test ( a number,b varchar(100))
*
ERROR at line 1:
ORA-01536: space quota exceeded for tablespace 'CRM_DATA'

SQL> select * from user_ts_quotas;

TABLESPACE_NAME BYTES MAX_BYTES BLOCKS MAX_BLOCKS DRO
------------------------------ ---------- ---------- ---------- ---------- ---
CRM_INDX 109576192 0 13376 0 NO
CRM_LOB 20905984 0 2552 0 NO
CRM_DATA 124780544 0 15232 0 NO

特别注意一下,这里的max_bytes和max_blocks是0,与9i的含义不一样!
9i中为0表示不限制,10g中是用-1表示不限制!

SQL> conn / as sysdba
Connected.
SQL> alter user turbocrm5 quota unlimited on crm_data;

User altered.

SQL> conn turbocrm5/******;
Connected.
SQL> select * from user_ts_quotas;

TABLESPACE_NAME BYTES MAX_BYTES BLOCKS MAX_BLOCKS DRO
------------------------------ ---------- ---------- ---------- ---------- ---
CRM_DATA 124846080 -1 15240 -1 NO
CRM_INDX 109576192 0 13376 0 NO
CRM_LOB 20905984 0 2552 0 NO

注意这里的-1表示不限制,0表示没有配额。



oracle10g 在 oraparam.ini 中未找到先决条件检查, 不执行系统先决条件检查

数据库 — 作者 gladness @ 11:36
同事在AS3.0上安装oracle10g,出现了如下问题:
在安装过程中,第一次在执行./runinstaller 后,出现了乱码,我们就停止了
第二此执行./runinstaller 后,出现的提示是:
正在启动 Oracle Universal Installer...
在 oraparam.ini 中未找到先决条件检查, 不执行系统先决条件检查
原因:
/tmp下的硬盘满了。每次安装,在/tmp下都需要60M左右的空间,并且不自动删除。
解决办法:
把/tmp下的以Ora开头的目录都删除。
乱码的解决办法,在运行runinstaller之前,
export LANG=en_US


Download MySQL source code

MySQL Internals — 作者 gladness @ 11:35
First, download and install free bk client:
http://www.bitkeeper.com/Hosted.Downloading.html
To see MySQL projects hosted by btkeeper:
http://mysql.bkbits.net/
On Linux(AS4.0)
sfioball bk://mysql.bkbits.net/mysql-5.1-new mysql5.1
cd mysql5.1
BUILD/compile-pentium-debug --prefix=$HOME/mysql5.1bin
make
make install
Quite easy! Thank MySQL AB.
MySQL source code is in mysql5.1 and binary in mysql5.1bin.
I think I can learn more now.


从邮件列表中看到的mysqldump导出大表时需要注意

数据库 — 作者 gladness @ 11:33
On 6/8/06, Ian Barnes <ian@cerebellum.za.net> wrote:
>
> Hi,
>
> I am trying to import a 3.2Gb sql dump file back into my sql server (
> 4.1.12)
> and im coming across the following error:
>
> mysql: Out of memory (Needed 178723240 bytes)
> mysql: Out of memory (Needed 178719144 bytes)
>
> That error comes up after about 30 minutes worth of import and I would
> guess
> about half way through the import. The file in question is a mysqldump
> -all-databases file from another server that im trying to import onto my
> desktop machine. I have tried to alter the my.cnf file a bit, and this is
> what it looks like:
>
> [client]
> #password = your_password
> port = 3306
> socket = /tmp/mysql.sock
>
> [mysqld]
> port = 3306
> socket = /tmp/mysql.sock
> skip-locking
> key_buffer = 64M
> max_allowed_packet = 8M
> table_cache = 512
> sort_buffer_size = 8M
> net_buffer_length = 8M
> myisam_sort_buffer_size = 45M
> set-variable=max_connections=300
>
> # Replication Master Server (default)
> # binary logging is required for replication
> #log-bin
>
> # required unique id between 1 and 2^32 - 1
> # defaults to 1 if master-host is not set
> # but will not function as a master if omitted
> server-id = 1
>
> #bdb_cache_size = 4M
> #bdb_max_lock = 10000
>
> # Uncomment the following if you are using InnoDB tables
> #innodb_data_home_dir = /var/db/mysql/
> #innodb_data_file_path = ibdata1:10M:autoextend
> #innodb_log_group_home_dir = /var/db/mysql/
> #innodb_log_arch_dir = /var/db/mysql/
> # You can set .._buffer_pool_size up to 50 - 80 %
> # of RAM but beware of setting memory usage too high
> #innodb_buffer_pool_size = 16M
> #innodb_additional_mem_pool_size = 2M
> # Set .._log_file_size to 25 % of buffer pool size
> #innodb_log_file_size = 5M
> #innodb_log_buffer_size = 8M
> #innodb_flush_log_at_trx_commit = 1
> #innodb_lock_wait_timeout = 50
>
> [mysqldump]
> quick
> max_allowed_packet = 16M
>
> [mysql]
> no-auto-rehash
> # Remove the next comment character if you are not familiar with SQL
> #safe-updates
>
> [isamchk]
> key_buffer = 10M
> sort_buffer_size = 20M
> read_buffer = 2M
> write_buffer = 2M
>
> [myisamchk]
> key_buffer = 10M
> sort_buffer_size = 20M
> read_buffer = 2M
> write_buffer = 2M
>
> [mysqlhotcopy]
> interactive-timeout
>
>
> Does anyone have any advice as to what I could change to make it import,
> and
> not break half way through. The command im running to import is: mysql -n
> -f
> -p < alldb.sql
>
> Thanks in advance,
> Ian
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=kjalleda@gmail.com
>
>

Assuming that you have dumped your databases using mysqldump, what options
did you give to mysqldump, as of 4.1, "--opt" is enabled by default, and
this enables the "--quick" option which basically forces mysqldump to
retrieve one row at a time instead of buffering the whole table into memory
and then writing out the result.

So if you have the --quick option enabled in myslqdump, you should not be
getting the out of memory errors, also I see you are using the -n option
with mysql CLT, which does not buffer sql statements/queries into memory
before flushing them, but if the dump itself consists of large rows of table
data flushed into one large sql statement, then mysql CLT would still treat
it as one query, so i am sure you have to change the way you dump your
tables...

Kishore Jalleda
http://kjalleda.googlepages.com/projects
也就是说,表的记录太多的时候,mysqldump导出的insert语句会非常长,可能导致在导入的时候内存不够用。


判断表是否存在的通用办法

数据库 — 作者 gladness @ 11:32
判断表是否存在的通用办法,从网上查到的,记录下来:
SELECT 1 FROM TABLENAME WHERE 1=0


mysql jdbc中文乱码原因之一

数据库 — 作者 gladness @ 16:05
MySQL5.0文档的原文

Prior to MySQL Server 4.1, Connector/J supported a single character encoding per connection, which could either be automatically detected from the server configuration, or could be configured by the user through the "useUnicode" and "characterEncoding" properties.

Starting with MySQL Server 4.1, Connector/J supports a single character encoding between client and server, and any number of character encodings for data returned by the server to the client in ResultSets.

The character encoding between client and server is automatically detected upon connection. The encoding used by the driver is specified on the server via the character_set system variable for server versions older than 4.1.0 and character_set_server for server versions 4.1.0 and newer. For more information, see Section 10.3.1, “Server Character Set and Collation”.

在同事使用jdbc联接MySQL5.0的时候出现了乱码,结果在/etc/my.cnf中加了

[mysqld]
default-character-set=utf8

就好了。我觉得挺奇怪,不知道为什么此配置文件会影响jdbc。一直以来的印象,是此配置只是建库、建表时缺省的字符集罢了。一旦建好了表,就与这个配置无关了。结果从文档中看,jdbc连接时,取了服务器端的character_set_server系统变量的值作为客户端的字符集。因此my.cnf对jdbc的字符集就有影响了。



ORA-01461: can bind a LONG value only for insert into a LONG column

数据库 — 作者 gladness @ 14:19
两个Oracle,一个用于正式运营,一个用于开发和测试。同样的java应用程序,同样的表结构。
在java应用使用开发的库时,向一个clob字段更新比较大量的字符时(比如几千个)会报ORA-01461: can bind a LONG value only for insert into a LONG column 。
而正式运营的库则没有问题。
开发人员换了换jdbc的jar包,也没效果。
后来发现,两个oracle的版本不同,运营的是Oracle10.2,用于开发的是10.1。
把10.1的换成10.2,就好了。


好文推荐,什么是软件架构

读书 — 作者 gladness @ 11:06

http://www-128.ibm.com/developerworks/rational/library/feb06/eeles/index.html

阐述了软件架构中的一些基本概念,学习中。。。。非常受益。
很值得看,引其中一段

Since an architecture focuses on significant elements only, it provides us with a particular perspective of the system under consideration -- the perspective that is most relevant to the architect.8 In this sense, an architecture is an abstraction of the system that helps an architect manage complexity.

这与软件工程、面向对象有共通的一点,就是通过抽像降低事物的复杂性,让人脑可以控制。

再摘一段:

It is also worth noting that the set of significant elements is not static and may change over time.

可以看出,架构是“以不变应万变”。当然“万变”是有范围的。但基本思想应该是以不变应万变。我想,软件工程、设计模式,等等也有同样初衷。

再一段:

An architecture embodies decisions based on rationale

An important aspect of an architecture is not just the end result, the architecture itself, but the rationale for why it is the way it is. Thus, an important consideration is to ensure that you document the decisions that have led to this architecture and the rationale for those decisions.

This information is relevant to many stakeholders, especially those who must maintain the system. This information is often valuable to the architect when he or she needs to revisit the rationale behind the decisions that were made, so that they don't end up having to unnecessarily retrace steps. For example, this information is used when the architecture is reviewed and the architect needs to justify the decisions that have been made.

不能只是一个结果,还需要那些导致各个决定的理由。



Powered by pLog