huakaibird - by - 09 七月, 2008 15:05

When using not in, not like, <>, not between in sql, you should pay attention, if the field is permit to null, the null value record can not be selected, you should add not null to let the null record shown. But the not exists is the except, it can select the null record, because the sql is always not exists(select field1 from table1 where table1.field1=table2.field1), if it table2's field1 is null, of course the equation is not true.


huakaibird - by - 03 四月, 2008 14:56

The recyclebin is just a virtual storage area, a data dictionary. When drop table, the real space on the tablespace this table take up would not deleted in deed. But if the space is not enough, Oracle will delete the space auto.



huakaibird - by - 21 三月, 2008 17:03

truncate 能释放表空间以及索引空间,但是前一次扩展的索引空间并不一定能记录到数据字典中, 故最好rebuild index.


huakaibird - by - 21 三月, 2008 16:56

free space 大于db file的大小

遇到一个奇怪的问题, db file free space的大小大于file的大小。导致在toad下看到的使用率为负的


select sum(bytes) from dba_free_space where file_id=8;
result: 35672489984 (这个大小已经达到了数据文件的max)


select bytes from dba_data_files where file_id=8;
result: 10171187200
由于oracle bug 5083393 导致,
solution:
purge tablespace TS_NAME;
exec dbms_space_admin.tablespace_rebuild_bitmaps('TS_NAME');


huakaibird - by - 03 二月, 2008 13:14

When you use form in html, you can have two value "post" or "get" for method get: With the HTTP "get" method, the form data set is appended to the URI specified by the action attribute (with a question-mark ("?") as separator) and this new URI is sent to the processing agent. post: With the HTTP "post" method, the form data set is included in the body of the form and sent to the processing agent. If use get, your action is "test.html?test=1", the "test=1" will be replaced by form data set, but if use the "post", the "test=1" will not be replaced, it will also be sent over. The form data set's value will be encoded by your agent automatic, but if your action is "test.html?test=1", the value will not be encoded, you have to encode it if it has the special character like '=', '?' etc..


huakaibird - by - 04 一月, 2008 15:30

move oracle from '/opt' to '/disk'

>shutdown

cp all files;

update environment.

update pfile,

change control files, background_dump_dest, core_dump_dest, user_dump_dest

sqlplus "/as sysdba"

> startup mount pfile='new'

>alter database rename file 'old' to 'new'

>alter database open

ok



huakaibird - by - 25 十二月, 2007 14:54

1. Use the analytic function is the best way.
row_number() over ( partition by col1 order by col2 )

for example: get records between 100 and 150, order by tname.

select tname,tabtype from (
select tname,tabtype,row_number() over ( order by tname ) rn from tab
)
where rn between 100 and 150;

2. use rownum
select tname,tabtype from (
select tname,tabtype,rownum rn from tab where rownum <= 150
)
where rn >= 100;

Use rownum, you can not order the whole records when using order by, it will get the front records then order these records.

But if the order by field is primary key, it is a exception, it will order the whole records first, then get the front records.



huakaibird - by - 25 十二月, 2007 14:49

When the argument list is too long, the rm command can not work, it is limit to os.

solution 1:

rm dir, recreate the dir.

solution 2:

find /path/to -name "*.png" -exec rm {} ;



huakaibird - by - 08 十一月, 2007 16:28

When you put .html file on the document root, put .pl& .pm file in a cgi-bin directory under the document root. The user can get the .pl & .pm file through http://host/documentroot/cgi-bin/aaa.pl, so we should add

AddHandler cgi-script .pl or

AddType application/x-httpd-cgi .pl .pm

in apache configure file, then user request http://host/documentroot/cgi-bin/aaa.pl, it can not work, it must through ScriptAlias.



huakaibird - by - 11 十月, 2007 09:50

1.
create table TEST
(
num1 number(10),
num2 number(10),
num3 number(10)
)

insert into TEST values(2,4,2).
update TESTHUA set num1=num1+2,num2=num2+8,num3=num2/num1;

select * from TEST

oracle's result:
4,12,2
when oracle execute num3,the value of num1 and num2 didn't change.


mysql's result:
4,12,3
when mysql execute num3,the value of num1 and num2 changed already.
num1 early than num2 because num1's position is bofore num2

It means that oracle update the field data at the same time but
the mysql not,It update the field data behind the "set" by the sequence .

2.special character: oracle: '
mysql: '

3.null phenomenon:
in mysql: null is different from '';
insert into test(ID) values(1);
insert into test(ID,name) values(2,'');
execute:
select * from test where name is null; The reuslt is only 1.
select * from test where name=''; The result is 2.

in oracle: '' is same as null;
select * from test where name is null; The reuslt is 1,2.
select * from test where name=''; No result;



huakaibird - by - 06 九月, 2007 15:20

one

select A.NAME_1,B.NAME_2,C.NAME_3 from A left join B on A.ID=B.ID left join C on B.ID_1= C.ID_1;

two

select P.NAME_1,P.NAME_2,C.NAME_3 from (select A.NAME_1,B.NAME_2,B.ID_1 from A left join B on A.ID=B.ID) P left join C on P.ID_1= C.ID_1;



huakaibird - by - 30 八月, 2007 14:34

默认系统就会加载/dev/shm ,它就是所谓的tmpfs,有人说跟ramdisk(虚拟磁盘),但不一样。象虚拟磁盘一样,tmpfs 可以使用您的 RAM,但它也可以使用您的交换分区来存储。而且传统的虚拟磁盘是个块设备,并需要一个 mkfs 之类的命令才能真正地使用它,tmpfs 是一个文件系统,而不是块设备;您只是安装它,它就可以使用了。

tmpfs有以下优势:
1。动态文件系统的大小,
2。tmpfs 的另一个主要的好处是它闪电般的速度。因为典型的 tmpfs 文件系统会完全驻留在 RAM 中,读写几乎可以是瞬间的。
3。tmpfs 数据在重新启动之后不会保留,因为虚拟内存本质上就是易失的。所以有必要做一些脚本做诸如加载,绑定的操作。

好了讲了一些大道理,大家看的烦了吧,还是讲讲我的应用吧:)

首先在/dev/stm建个tmp文件夹,然后与实际/tmp绑定

mkdir /dev/shm/tmp
chmod 1777 /dev/shm/tmp
mount --bind /dev/shm/tmp /tmp


1。squid的缓存目录设置

vi /etc/squid/squid.conf

修改成
cache_dir ufs /tmp 256 16 256
这里的第一个256表示使用256M内存,我觉得高性能LINUX双效防火墙HOWTO使用ramdisk的方法还不如直接使用tmpfs,至少每次启动不用mkfs,还可以动态改变大小。

然后重启一下服务,ok,现在所有的squid缓存文件都保存倒tmpfs文件系统里了,很快哦。


2。对php性能的优化

对于一个访问量大的以apache+php的网站,可能tmp下的临时文件都会很多,比如seesion或者一些缓存文件,那么你可以把它保存到tmpfs文件。

保存seesion的方法很简单了只要修改php.ini就行了,由于我已经把/dev/stm/tmp与/tmp绑定,所以不改写也行,至于php程序产生的缓存文件那只能改自己的php程序了:)

希望我的这个方法,能对你有所启发。

在红帽企业版Linux的应用程序如果遵循POSIX或者使用GLIBC(2.2和更高版本),通常使用/dev/shm作共享内存(shm_open,shm_unlink)。/dev/shm是一个临时文件系统(tmpfs),可以从/etc/fstab中mount。因此,支持标准的参数例如"size",可以用来增加或者减少在/dev/shm上的tmpfs大小.(默认的,它的大小是系统RAM的一半)。

例如:为了将/dev/shm的大小增加到1GB,修改/etc/fstab的这行:默认的:

none     /dev/shm       tmpfs   defaults        0 0

改成:

none      /dev/shm        tmpfs   defaults,size=1024M        0 0

size参数也可以用G作单位:size=1G。

重新mount /dev/shm使之生效:

 # mount -o remount /dev/shm

马上可以用"df -h"命令检查变化。



huakaibird - by - 04 七月, 2007 10:42

use ./mysqld_safe --user=mysql &
start mysql.

The mysql can not start. There are much mysql restart info show on the screen always. And can not find the /var/lib/mysql/mysql.sock file.

The reason:
Then find the space is full. So the mysql can not start naturally. Delete some log info, then the mysql start correctly.


The big log files are two:
1. Our application log
2. The /var/log/audit.d

在/var/log/audit.d目录下的文件是由Linux审计子系统(Linux Audit Subsystem,简称LAuS)产生的。

为了安全目的,LAuS在启动以后,默认配置是会记录一些特定的系统活动。如果不需要进行安全审计,可

以通过以下命令关机LAuS服务:

service audit stop
chkconfig audit off
停止LAuS服务以后,在/var/log/audit.d目录下面的任何save.*文件都可以删除。我们推荐您原封不动的

保留bin.*文件,以备将来使用。LAuS功能在红帽企业版Linux3以上版本默认没有打开。

因为LAuS被用来作安全审计,所以它的日志文件是不会自动删除,会一直保留。如果您的系统负载比较重

,并且在执行LAuS监控系统,LAuS的日志文件会增长的很快,有可能会占满/var的空间导致系统崩溃。有

几种方式可以用来阻止以上事件发上。最简单的方法是定时监控/var/log/audit.d目录的大小,删除过时

的save.*文件。另一种技术是不要把归档的审计日志保存为save.*文件。修改/etc/audit/audit.conf里

面的notify行,用/bin/true代替原先的/usr/sbin/audbin:

/etc/audit/audit.conf


output {
mode = bin;
num-files = 4;
file-size = 20M;
file-name = "/var/log/audit.d/bin";
notify = "/bin/true";

第三种方式是写一个脚本定时删除save.*文件。



huakaibird - by - 11 五月, 2007 16:58

When we deploy production today, a strange problem comes out.

When accessing the url, tell Can't locate loadable object for module DBI in @INC. First, we think it is the DBI install problem, but after install several time, it has no use.

Then we find the umask is 077, so when we install, the dir will be 700, so it can not be access by regular user through http. So we should change umask to 022 before we install.



huakaibird - by - 02 四月, 2007 15:19

mysql -uuser -ppass db
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)

when use root user,It is ok.Obviously, it is privilege problem.

Try to check the mysql.sock privelege. If it is ok, then check its father dir to check.



博客日历
« 七月 2008 »
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
搜索
管理控制台
TOP_Read
TOP_Reply
New_Reply
文章分类
一般分类[1]
[1]
技术[30]
心情[0]
网站链接
新闻聚合
RSS 0.90
RSS 1.0
RSS 2.0
Atom 0.3