2009年5月31日星期日

怎样作出正确的决定?经验!怎样获得经验?错误的决定!

怎样作出正确的决定?经验!怎样获得经验?错误的决定!--佚名

从twitter上看到的,有点意思

2009年5月30日星期六

转:数据类型和Json格式

1.

前几天,我才知道有一种简化的数据交换格式,叫做yaml(http://www.yaml.org/)。
我翻了一遍它的文档,看懂的地方不多,但是有一句话令我茅塞顿开。
它说,从结构上看,所有的数据最终都可以分成三种类型:
第一种类型是scalar(标量),也就是一个单独的string(字符串)或数字(numbers),比如“北京”这个单独的词。

第二种类型是sequence(序列),也就是若干个相关的数据按照一定顺序并列在一起,又叫做array(数组)或List(列表),比如“北京,东京”。


第三种类型是mapping(映射),也就是一个名/值对(Name/value),即数据有一个名称,还有一个与之相对应的值,这又称作hash(散列)或dictionary(字典),比如“首都:北京”。

我恍然大悟,数据构成的最小单位原来如此简单!难怪在编程语言中,只要有了数组(array)和对象(object)就能够储存一切数据了。

2.

我马上想到了json。

21世纪初,Douglas Crockford寻找一种数据交换格式,能够在服务器之间交换数据。这其实需要二步,第一步是将各种数据转化为一个字符串,也就是数据的串行化(serialization),第二步才是交换这个字符串。

当时通用的数据交换语言是XML,但是Douglas Crockford觉得XML的生成和解析都太麻烦,所以他提出了一种简化格式,也就是Json。

Json的规格非常简单,只用一个页面、几百个字就能说清楚,而且Douglas Crockford声称这个规格永远不必升级,因为该规定都规定了。

1) 并列的数据之间用逗号(“,”)分隔。

2) 映射用冒号(“:”)表示。

3) 并列数据的集合数组)用方括号("[]")表示。

4) 映射的集合对象)用大括号(“{}”)表示。

上面四条规则,就是Json格式的所有内容。

比如,下面这句话:

“北京市的面积为16800平方公里,常住人口1600万人。上海市的面积为6400平方公里,常住人口1800万。”

写成json格式就是这样:

[
{"城市":"北京","面积":16800,"人口":1600},
{"城市":"上海","面积":6400,"人口":1800}
]

如果事先知道数据的结构,上面的写法还可以进一步简化:
[
["北京",16800,1600],
["上海",6400,1800]
]

由此可以看到,json非常易学易用。所以,在短短几年中,它就取代xml,成为了互联网上最受欢迎的数据交换格式。

我猜想,Douglas Crockford一定事先就知道,数据结构可以简化成三种形式,否则怎么可能将json定义得如此精炼呢!

3.

我还记得,在学习javascript的时候,我一度搞不清楚“数组”(array)和“对象”(object)的根本区别在哪里,两者都可以用来表示数据的集合。

比如有一个数组a=[1,2,3,4],还有一个对象a={0:1,1:2,2:3,3:4},然后你运行alert(a[1]),两种情况下的运行结果是相同的!这就是说,数据集合既可以用数组表示,也可以用对象表示,那么我到底该用哪一种呢?

我后来才知道,数组表示有序数据的集合,而对象表示无序数据的集合。如果数据的顺序很重要,就用数组,否则就用对象。

4.

当然,数组和对象的另一个区别是,数组中的数据没有“名称”(name),对象中的数据有“名称”(name)。

但是问题是,很多编程语言中,都有一种叫做“关联数组”(associative array)的东西。这种数组中的数据是有名称的。

比如在javascript中,可以这样定义一个对象:

var a={"城市":"北京","面积":16800,"人口":1600};

但是,也可以定义成一个关联数组:

a["城市"]="北京";
a["面积"]=16800;
a["人口"]=1600;

这起初也加剧了我对数组和对象的混淆,后来才明白,在Javascript语言中,关联数组就是对象,对象就是关联数组。这一点与php语言完全不同,在php中,关联数组也是数组。

比如运行下面这段javascript:

var a=[1,2,3,4];

a['foo']='Hello World';

alert(a.length);

最后的结果是4,也就是说,数组a的元素个数是4个。

但是,运行同样内容的php代码就不一样了:

$a=array(1,2,3,4);

$a["foo"]="Hello world";

echo count($a);

最后的结果是5,也就是说,数组a的元素个数是5个。

(完)

原文在此:ref://http://www.ruanyifeng.com/blog/2009/05/data_types_and_json.html

学习备查,豁然开朗!

三教从来一祖风--出处是王重阳

想不起来从那里听说的那句话了“三教从来一祖风“,原来是王重阳说的。

王重阳主张儒、释、道三教平等,三教合一,提出“三教从来一祖风”的融合学说。全真道内以《道德经》、《孝经》、《般若波罗蜜多心经 》为必修经典 ,认为修道即修心 ,除情去欲 ,存思静定、心地清静便是修行的真捷径。

今天是我来HongKong整整一周年了

来HongKong一周年了,留个脚印,纪录一下。

决定增加一个标签

前一段时间blogger,发了一个mail怀疑我的blog是spam blog, 每次更新的时候还要写那个交验码,郁闷的够呛。

所以blog也懒了,今天决定增加一个标签:好文阅读,纪录我看过的好的文章。

2009年5月26日星期二

LUN與Volume

硬件層次上生成的虛擬磁片(virtual disk) 統一稱為 LUN,不管是不是在Scsi環境下,雖然LUN最初只是SCSI體系下的一個概念.
而由軟體生成的虛擬磁片(virtual disk)統一稱為"卷volume", 比如各種卷管理軟體,軟raid等所生成的虛擬磁片.

2009年5月24日星期日

rpm src package install iptraf

傳說比較好用的流量監控工具,試裝了一下,rpm src格式的,

我用源包make 好像不過去,可能是64-bit的問題


[root@CRRACTEST2 x86_64]# rpmbuild --rebuild iptraf-3.0.0-5.el5.src.rpm


[root@CRRACTEST2 x86_64]# pwd
/usr/src/redhat/RPMS/x86_64


[root@CRRACTEST2 x86_64]# rpm -ivh iptraf-3.0.0-5.x86_64.rpm
Preparing... ########################################### [100%]
1:iptraf ########################################### [100%]

轉:Twitter新手使用教程

ref: http://www.yeeyan.com/articles/view/riku/40749
留一個記號,備查

由盧武鉉自殺想起一個詞"危機公關"

摘文:

危機的本質不是"事件"本身,而是危機多導致的消費群體心理上對品牌認知的消極影響,品牌危機本質上就是信譽危機

在現代社會裡,人們對企業的社會責任的期望值越來越高。若一個企業在發生危機事件時,不能與公眾進行溝通,不能很好地告訴公眾它的態度、它正在盡力做什麼,這無疑會給組織的信譽帶來致命的打擊,甚至有可能導致組織消亡。而一個企業如果在事件發生後,有誠意麵對,那麼,對或錯或許就變得不再那麼重要,對人們而言,感覺勝於事實。

人們感興趣的往往並不是事情本身,而是當事人對事情的態度。


危機公關就是通過積極有效的溝通,將對企業不利的消息與事件的影響降至最低,以市場營銷的方法塑造企業品牌。

態度決定高度。一個企業的危機公關態度如何,決定了其抗風險能力和對危機的預防與處理的效率,而這些直接決定了其能在波浪洶湧的競爭中能走多遠百年品牌和“只領風騷三五年”的差別多歸於此。


自己有沒有做準備了,如何做準備呢?

k-lite video player 好东西

前两天看暴风影音导致大面积断网,觉得还是换一个其他的video player,看到高人介绍
k-lite video player,试用一下效果不错,如没啥问题以后就是它了.
ref http://www.free-codecs.com/download/K_lite_codec_pack.htm

2009年5月17日星期日

oracle 11g 中 可以使用 create spfile from memory

fail-tolerant of Oracle 11g

實驗如下:
[oracle@croracle01 ~]$ sqlplus / as sysdba;

SQL*Plus: Release 11.1.0.6.0 - Production on Mon May 18 18:09:12 2009

Copyright (c) 1982, 2007, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL>
SQL>
SQL> create spfile='/tmp/spfile.ora' from memory;

File created.

SQL> create pfile='/tmp/initcroracle.ora' from memory;

File created.

SQL>!

[oracle@croracle01 tmp]$ ll *.ora
-rw-r--r-- 1 oracle oinstall 5996 May 18 18:09 initcroracle.ora
-rw-r----- 1 oracle oinstall 13824 May 18 18:09 spfile.ora

參考文檔:http://www.eygle.com/archives/2007/08/11gspfile_fault_tolerant.html

2009年5月16日星期六

当家人的素质

人面广,手头活,黑道白道路路通;荤行素行行行精,文活武活样样灵。

一个当家人想要将自己的镖局的生意发扬光大,仅仅靠高超的武功是不行的。还要靠自己的影响力,而影响力其始就是自己在江湖上的口碑“做事先做人”这句话在镖局行业有着更具体的诠释。

在任何时代,一个领导者都应该有一种嗅觉。 当然,这种嗅觉是时刻跟着当时形势走的(与时协行,与时俱进)

伟大的领导者都是“一个人的表演”。

首先,你应该把你的技能传授给手下的工作人员,并且把他们培养成为比你更能干的人。
第二, 你要有鼓舞士气的能力 。
第三, 领导者的人格魅力都是在工作中表现出来的, 所以,你应该经常亲自参与某些项目。
第四,请不要重复做相同的决定。
最后, 也是最重要的, 应该让员工知道自己该取悦谁。 你的人格魅力就是吸引他们来取悦你的唯一保证。


在任何一个时代,政府的公信力与官员职务优势都可以影响人们的判断力!--说的到位!

转文:十个你可能不曾用过的Linux命令

下面可能是你不曾用过后十个Linux的命令。相当的有用。

1)pgrep

pgrep名字前有个p,我们可以猜到这和进程相关,又是grep,当然这是进程相关的grep命令。不过,这个命令主要是用来列举进程ID的。如:

$ pgrep -u hchen
22441
22444
这个命令相当于:

ps -ef | egrep '^hchen' | awk '{print $2}'

2)pstree

这个命令可以以树形的方式列出进程。如下所示:

[hchen@RHELSVR5 ~]$ pstree
init-+-acpid
|-auditd-+-python
| `-{auditd}
|-automount---4*[{automount}]
|-backup.sh---sleep
|-dbus-daemon
|-events/0
|-events/1
|-hald---hald-runner---hald-addon-acpi
|-httpd---10*[httpd]
|-irqbalance
|-khelper
|-klogd
|-ksoftirqd/0
|-ksoftirqd/1
|-kthread-+-aio/0
| |-aio/1
| |-ata/0
| |-ata/1
| |-ata_aux
| |-cqueue/0
| |-cqueue/1
| |-kacpid
| |-kauditd
| |-kblockd/0
| |-kblockd/1
| |-kedac
| |-khubd
| |-6*[kjournald]
| |-kmirrord
| |-kpsmoused
| |-kseriod
| |-kswapd0
| |-2*[pdflush]
| |-scsi_eh_0
| |-scsi_eh_1
| |-xenbus
| `-xenwatch
|-migration/0
|-migration/1
|-6*[mingetty]
|-3*[multilog]
|-mysqld_safe---mysqld---9*[{mysqld}]
|-smartd
|-sshd---sshd---sshd---bash---pstree
|-svscanboot---svscan-+-3*[supervise---run]
| |-supervise---qmail-send-+-qmail-clean
| | |-qmail-lspawn
| | `-qmail-rspawn
| `-2*[supervise---tcpserver]
|-syslogd
|-udevd
|-watchdog/0
|-watchdog/1
`-xinetd


3)bc

这个命令主要是做一个精度比较高的数学运算的。比如开平方根等。下面是一个我们利用bc命令写的一个脚本(文件名:sqrt)

#!/bin/bash
if [ $# -ne 1 ]
then
echo 'Usage: sqrt number'
exit 1
else
echo -e "sqrt($1)\nquit\n" | bc -q -i
fi
于是,我们可以这样使用这个脚本进行平方根运算:

[hchen@RHELSVR5]$ ./sqrt 36
6
[hchen@RHELSVR5]$ ./sqrt 2.0000
1.4142
[hchen@RHELSVR5]$ ./sqrt 10.0000
3.1622


4)split

如果你有一个很大的文件,你想把其分割成一些小的文件,那么这个命令就是干这件事的了。

[hchen@RHELSVR5 applebak]# ls -l largefile.tar.gz
-rw-r--r-- 1 hchen hchen 436774774 04-17 02:00 largefile.tar.gz

[hchen@RHELSVR5 applebak]# split -b 50m largefile.tar.gz LF_

[hchen@RHELSVR5]# ls -l LF_*
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:34 LF_aa
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:34 LF_ab
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:34 LF_ac
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:34 LF_ad
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:34 LF_ae
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:35 LF_af
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:35 LF_ag
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:35 LF_ah
-rw-r--r-- 1 hchen hchen 17344374 05-10 18:35 LF_ai


文件合并只需要使用简单的合并就行了,如:

[hchen@RHELSVR5]# cat LF_* >largefile.tar.gz


5)nl

nl命令其它和cat命令很像,只不过它会打上行号。如下所示:

[hchen@RHELSVR5 include]# nl stdio.h | head -n 10
1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991,1994-2004,2005,2006 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.

4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.

8 The GNU C Library is distributed in the hope that it will be useful,


6)mkfifo

熟悉Unix的人都应该知道这个是一个创建有名管道的系统调用或命令。平时,我们在命令行上使用竖线“|”把命令串起来是使用无命管道。而我们使用mkfifo则使用的是有名管道。下面是示例:

下面是创建一个有名管道:

[hchen@RHELSVR5 ~]# mkfifo /tmp/hchenpipe

[hchen@RHELSVR5 ~]# ls -l /tmp
prw-rw-r-- 1 hchen hchen 0 05-10 18:58 hchenpipe
然后,我们在一个shell中运行如下命令,这个命令不会返回,除非有人从这个有名管道中把信息读走。

[hchen@RHELSVR5 ~]# ls -al > /tmp/hchenpipe
我们在另一个命令窗口中读取这个管道中的信息:(其会导致上一个命令返回)

[hchen@RHELSVR5 ~]# head /tmp/hchenpipe
drwx------ 8 hchen hchen 4096 05-10 18:27 .
drwxr-xr-x 7 root root 4096 03-05 00:06 ..
drwxr-xr-x 3 hchen hchen 4096 03-01 18:13 backup
-rw------- 1 hchen hchen 721 05-05 22:12 .bash_history
-rw-r--r-- 1 hchen hchen 24 02-28 22:20 .bash_logout
-rw-r--r-- 1 hchen hchen 176 02-28 22:20 .bash_profile
-rw-r--r-- 1 hchen hchen 124 02-28 22:20 .bashrc
-rw-r--r-- 1 root root 14002 03-07 00:29 index.htm
-rw-r--r-- 1 hchen hchen 31465 03-01 23:48 index.php


7)ldd

这个命令可以知道你的一个可执行文件所使用了动态链接库。如:

[hchen@RHELSVR5 ~]# ldd /usr/bin/java
linux-gate.so.1 => (0x00cd9000)
libgij.so.7rh => /usr/lib/libgij.so.7rh (0x00ed3000)
libgcj.so.7rh => /usr/lib/libgcj.so.7rh (0x00ed6000)
libpthread.so.0 => /lib/i686/nosegneg/libpthread.so.0 (0x00110000)
librt.so.1 => /lib/i686/nosegneg/librt.so.1 (0x009c8000)
libdl.so.2 => /lib/libdl.so.2 (0x008b5000)
libz.so.1 => /usr/lib/libz.so.1 (0x00bee000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00aa7000)
libc.so.6 => /lib/i686/nosegneg/libc.so.6 (0x0022f000)
libm.so.6 => /lib/i686/nosegneg/libm.so.6 (0x00127000)
/lib/ld-linux.so.2 (0x00214000)


8)col

这个命令可以让你把man文件转成纯文本文件。如下示例:

# PAGER=cat
# man less | col -b > less.txt


9)xmlwf

这个命令可以让你检查一下一个XML文档是否是所有的tag都是正常的。如:

[hchen@RHELSVR5 ~]# curl 'http://cocre.com/?feed=rss2' > cocre.xml
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 64882 0 64882 0 0 86455 0 --:--:-- --:--:-- --:--:-- 2073k
[hchen@RHELSVR5 ~]# xmlwf cocre.xml
[hchen@RHELSVR5 ~]# perl -i -pe 's@@
@g' cocre.xml
[hchen@RHELSVR5 ~]# xmlwf cocre.xml
cocre.xml:13:23: mismatched tag


10)lsof

可以列出打开了的文件。

[root@RHELSVR5 ~]# lsof | grep TCP
httpd 548 apache 4u IPv6 14300967 TCP *:http (LISTEN)
httpd 548 apache 6u IPv6 14300972 TCP *:https (LISTEN)
httpd 561 apache 4u IPv6 14300967 TCP *:http (LISTEN)
httpd 561 apache 6u IPv6 14300972 TCP *:https (LISTEN)
sshd 1764 root 3u IPv6 4993 TCP *:ssh (LISTEN)
tcpserver 8965 root 3u IPv4 153795500 TCP *:pop3 (LISTEN)
mysqld 10202 mysql 10u IPv4 73819697 TCP *:mysql (LISTEN)
sshd 10735 root 3u IPv6 160731956 TCP 210.51.0.232:ssh->123.117.239.68:31810 (ESTABLISHED)
sshd 10767 hchen 3u IPv6 160731956 TCP 210.51.0.232:ssh->123.117.239.68:31810 (ESTABLISHED)
vsftpd 11095 root 3u IPv4 152157957 TCP *:ftp (LISTEN)

其中几个偶尔过,纪录下来以备后查
ref: http://cocre.com/?p=790

2009年5月14日星期四

crontab和mysqldump的实验

工作中用到了记录一下:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| crontest | <----这里已经创建了一个测试cron的database
| mysql |
| test |
+--------------------+
4 rows in set (0.00 sec)

mysql> grant all on crontest.* to crontestuser@'%' identified by 'abc123'; <--授权 Query OK, 0 rows affected (0.01 sec) 测试 [root@CRRACTEST mysqltest]# mysql -ucrontestuser -pabc123 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.0.45 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show tables;
ERROR 1046 (3D000): No database selected
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| crontest |
| test |
+--------------------+
3 rows in set (0.00 sec)

mysql>


--创建一个新的database,import测试使用
[root@CRRACTEST mysqltest]# mysqladmin create importtest
数据导入
[root@CRRACTEST mysqltest]# mysql importtest

数据检查
[root@CRRACTEST mysqltest]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.0.45 Source distribution

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

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| crontest |
| importtest | <---here
| mysql |
| test |
+--------------------+
5 rows in set (0.00 sec)

mysql> use importtest;
Database changed
mysql> show tables
-> ;
+----------------------+
| Tables_in_importtest |
+----------------------+
| crontesttab |
+----------------------+
1 row in set (0.00 sec)

mysql> select * from crontesttab;
+------+--------+
| id | name |
+------+--------+
| 1 | Leo |
| 2 | German |
| 3 | Cyrus |
| 4 | Ken |
+------+--------+
4 rows in set (0.00 sec)

mysql>




crontab用到的脚本:
*/1 * * * * /root/mysqltest/test.sh
#01 0 * * * /root/mysqltest/test.sh

test.sh
#!/bin/sh
. ~/.bash_profile
#echo databasename`date "+%Y%m%d"`
#mysqldump -ucrontestuser -pabc123 crontest >/home/crontest`date "+%Y%m%d"`.sql
mysqldump -ucrontestuser -pabc123 crontest >/root/mysqltest/crontest`date "+%Y%m%d%H%M"`.sql

以备后查!

升级rpm包

将原来的redhat5.1上的glibc升级 rpm来自Oracle Enterprise Linux 5.2 也就是RedHat的山寨版。

[root@localhost orapkg]# rpm -Uvh --force glibc*.rpm
warning: glibc-2.5-24.i686.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing... ########################################### [100%]
1:glibc-common ########################################### [ 14%]
2:glibc ########################################### [ 29%]
3:glibc warning: /etc/ld.so.conf created as /etc/ld.so.conf.rpmnew
warning: /etc/nsswitch.conf created as /etc/nsswitch.conf.rpmnew
########################################### [ 43%]
4:glibc-headers ########################################### [ 57%]
5:glibc-devel ########################################### [ 71%]
6:glibc-devel ########################################### [ 86%]
7:glibc-utils ########################################### [100%]
[root@localhost orapkg]# rpm -qa |grep -i glibc
glibc-2.5-24
glibc-devel-2.5-24
compat-glibc-headers-2.3.4-2.26
glibc-headers-2.5-24
compat-glibc-2.3.4-2.26
glibc-2.5-24
glibc-utils-2.5-24
glibc-devel-2.5-24
compat-glibc-2.3.4-2.26
glibc-common-2.5-24

lookup_mount: exports lookup failed for stawj12 create_udp_client: hostname lookup failed: Operation not permitted 问题处理

从/var/log/message中看到大量的类似
May 13 22:05:54 oracle01 automount[4032]: lookup_mount: exports lookup failed for stawj12
May 13 22:05:54 oracle01 automount[4032]: create_udp_client: hostname lookup failed: Operation not permitted
May 13 22:05:54 oracle01 automount[4032]: create_tcp_client: hostname lookup failed: Operation not permitted
May 13 22:05:54 oracle01 automount[4032]: lookup_mount: exports lookup failed for stawj12
May 13 22:05:54 oracle01 automount[4032]: create_udp_client: hostname lookup failed: Operation not permitted
May 13 22:05:54 oracle01 automount[4032]: create_tcp_client: hostname lookup failed: Operation not permitted
May 13 22:05:54 oracle01 automount[4032]: lookup_mount: exports lookup failed for stawj12
May 13 22:05:54 oracle01 automount[4032]: create_udp_client: hostname lookup failed: Operation not permitted
May 13 22:05:54 oracle01 automount[4032]: create_tcp_client: hostname lookup failed: Operation not permitted
May 13 22:05:54 oracle01 automount[4032]: lookup_mount: exports lookup failed for stawj12
May 13 22:05:54 oracle01 automount[4032]: create_udp_client: hostname lookup failed: Operation not permitted
May 13 22:05:54 oracle01 automount[4032]: create_tcp_client: hostname lookup failed: Operation not permitted

这样的信息,网上search了一下,算是一个oracle 的bug
ref:
http://forums.oracle.com/forums/thread.jspa?threadID=579670&tstart=29



处理如下:


[oracle@oracle01 init.d]$ ps -ef |grep automount
root 4031 1 0 May13 ? 00:00:00 automount
oracle 30197 21163 0 15:11 pts/2 00:00:00 grep automount


[root@oracle01 init.d]# chkconfig autofs off
[root@oracle01 init.d]# chkconfig --list autofs
autofs 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@oracle01 init.d]#



[root@oracle01 init.d]# ./autofs stop
Stopping automount: [ OK ]
[root@oracle01 init.d]#



[root@oracle02 init.d]# ./autofs stop
Stopping automount: [ OK ]
[root@oracle02 init.d]#
[root@oracle02 init.d]# chkconfig --list autofs
autofs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
[root@oracle02 init.d]# chkconfig autofs off
[root@oracle02 init.d]# chkconfig --list autofs
autofs 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@oracle02 init.d]#


记录之,恢复使用

2009年5月13日星期三

转文:优秀的项目经理

今天周末,在家休息,好不容易闲来无事,来回串门,无意间发现隔壁口碑的室友,有一块挺精致的鼠标垫,细细一看,上面列了7个点:

1、 坚持不懈的向团队传达目标

2、 崇拜质量

3、 每天都和项目成员聊上两句

4、 敢于说不,慎于说不

5、 帮助项目成员解决困难,而不是帮他干活

6、 敏感,不将风险留到最后才面对

7、 懂得欢庆

由于和目前项目过程中出现的一些问题有惊人的相似,于是抄录下来,以供大家参考。尤其是3567都是做为技术出身的一线管理者比较缺乏的。



原文在此:http://www.alisdn.com/wordpress/?p=1492

後知後覺Oracle Enterprise Linux 5.3出來了

後知後覺,昨天才發現,2月份已經出來了,趕緊download一個DVD version的,以備不時之需。

實驗,RAC中的各個node,插入數據的時間oracle是如何考量的?

在第一個node上

[oracle@croracle03 ~]$ date
Fri May 15 03:07:18 HKT 2009

[oracle@croracle03 ~]$ sqlplus / as sysdba;

SQL*Plus: Release 11.1.0.6.0 - Production on Fri May 15 03:07:26 2009

Copyright (c) 1982, 2007, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> create user ractest identified by password;

User created.

SQL> grant dba to ractest;

Grant succeeded.

SQL> conn ractest/password
Connected.

SQL> create table timetest( id number, testdate date);

Table created.

SQL> insert into timetest values (1, sysdate);

1 row created.

SQL> commit;

Commit complete.

SQL> select id, to_char(testdate, 'yyyymmdd HH24:MI:SS') from timetest;

ID TO_CHAR(TESTDATE,
---------- -----------------
1 20090515 03:09:59

SQL> comit;
SP2-0042: unknown command "comit" - rest of line ignored.
SQL> commit;

Commit complete.


在第二個node上:
[oracle@croracle02 ~]$ date
Thu May 14 17:34:06 HKT 2009
[oracle@croracle02 ~]$ sqlplus ractest/password

SQL*Plus: Release 11.1.0.6.0 - Production on Thu May 14 17:34:29 2009

Copyright (c) 1982, 2007, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> insert into timetest values (1, sysdate);

1 row created.

SQL> select id, to_char(testdate, 'yyyymmdd HH24:MI:SS') from timetest;

ID TO_CHAR(TESTDATE,
---------- -----------------
1 20090515 03:09:59
1 20090514 17:34:53

SQL> commit;

Commit complete.

SQL>

在第三個node上:
[oracle@croracle01 ~]$ date
Thu May 14 17:31:11 HKT 2009
[oracle@croracle01 ~]$ sqlplus ractest/password

SQL*Plus: Release 11.1.0.6.0 - Production on Thu May 14 17:31:21 2009

Copyright (c) 1982, 2007, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> insert into timetest values (1, sysdate);

1 row created.

SQL> select id, to_char(testdate, 'yyyymmdd HH24:MI:SS') from timetest;

ID TO_CHAR(TESTDATE,
---------- -----------------
1 20090515 03:09:59
1 20090514 17:34:53
1 20090514 17:31:33

SQL> commit;

Commit complete.

插入的sysdate,應該是node所在系統的date.不知道這個說法對不?

RAC中的每個節點插入的數據的時間是如何處理的?

nmon的使用笔记

ref: http://www.alidba.net/index.php/archives/227

因为工作中也用到了,刚好看到,实现一下,我的环境是Oracle Enterprose Linux 5.2不过基本上可以跑,记录如下:

工具下载: http://www.ibm.com/developerworks/wikis/display/WikiPtype/nmon

下载包:
[root@croracle03 nmon]# wget -c http://www.ibm.com/developerworks/wikis/download/attachments/53871937/nmon_x86_64_rhel4.zip?version=2
--02:56:03-- http://www.ibm.com/developerworks/wikis/download/attachments/53871937/nmon_x86_64_rhel4.zip?version=2
Resolving www.ibm.com... 129.42.60.216
Connecting to www.ibm.com|129.42.60.216|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 73468 (72K) [application/x-zip-compressed]
--02:56:05-- (try: 2) http://www.ibm.com/developerworks/wikis/download/attachments/53871937/nmon_x86_64_rhel4.zip?version=2
Reusing existing connection to www.ibm.com:80.
HTTP request sent, awaiting response... 200 OK
Length: 73468 (72K) [application/x-zip-compressed]
Saving to: `nmon_x86_64_rhel4.zip'

100%[=======================================>] 73,468 83.5K/s in 0.9s

02:56:07 (83.5 KB/s) - `nmon_x86_64_rhel4.zip' saved [73468/73468]

解压:

[root@croracle03 nmon]# unzip nmon_x86_64_rhel4.zip
Archive: nmon_x86_64_rhel4.zip
inflating: nmon_x86_64_rhel4

赋权限:
[root@croracle03 nmon]# chmod +x nmon_x86_64_rhel4

建立目录:
[root@croracle03 nmon]# mkdir bin data

[root@croracle03 nmon]# mv nmon_x86_64_rhel4 ./bin

编辑脚本:
[root@croracle03 bin]# vi nmon.sh
[root@croracle03 bin]# chmod +x nmon.sh

#!/bin/ksh
# written by ivan 20090513 for nmon

BINPATH=`dirname $0`
NPATH=$BINPATH/../data
$BINPATH/nmon_x86_64_rhel4 -s300 -c288 -f -m$NPATH

跑起来

[root@croracle03 bin]# ./nmon.sh

查看结果:
[root@croracle03 nmon]# cd data
[root@croracle03 data]# ls
croracle03_090514_0301.nmon
[root@croracle03 data]# ls -lh
total 20K
-rw-r--r-- 1 root root 20K May 14 03:11 croracle03_090514_0301.nmon

因为是一天的,所以等待明天看一下结果如何!

2009年5月12日星期二

Knowing is not enough; we must apply, willing is not enough; we must do

Knowing is not enough; we must apply. Willing is not enough; we must do.

努力的多,得到的就多;思考的多,释怀的就多。

穷理格物乃学术之精神,中国古人历来提倡。中国文物,其深不可见终底,其广不可见边缘,这对于西人国人一律公平,努力的多,得到的就多;思考的多,释怀的就多。 --马爷如是说

2009年5月11日星期一

sqlplus下灵活使用上下键

一个小工具刚装上
http://utopia.knoware.nl/~hlub/uck/rlwrap/
rlwrap is a 'readline wrapper' that uses the GNU readline library to allow the editing of keyboard input for any other command. Input history is remembered across invocations, separately for each command; history completion and search work as in bash and completion word lists can be specified on the command line.

root:
1 tar xvfz xxx.tar.gz
2 configure
3 make
4 make install

oracle:
vi .bash_profile add:
alias sqlplus="rlwrap sqlplus"
alias rman="rlwrap rman"


. .bash_profile


sqlplus test :)

插秧诗

手把青苗插满田,低头便见水中天。
六根清静方为道,退后原来是向前。
--布袋和尚

2009年5月8日星期五

word 中的 =rand()和 =lorem()

乱文生成函数,在word 2007中适用,其他的还不知道呢。
rand()和lorem()都带有两个可选的参数,分别表示需要生成的段落数和每段的句数。比如=lorem(6,20) ,表示生成一共6段,每段20句的文本。

try it!

ref:http://www.ruanyifeng.com/blog/2009/04/lorem_ipsum.html

Oracle RAC study note-- Node Applications

Node Applications

A number of node applications are automatically configured on each RAC instance.
If the node applications are enabled they will be automatically started when the node is booted. they can also be stared and stopped using the SRVCTL utility.

Listener
--The listener process runs on each node and listens for incoming connection requests from clients that are then redirected to an appropriate instance.
--The Listener process is responsible for managing connections for both dedicated and shared servers. It also behaves as an intermediary in the workload-balancing mechanism
--In a single-instance environment, the listener process runs as a daemon process and is usually started using the LSNCTL utiliy.
--In a RAC environment, the listener process is configured to run as a node application within the OCR. while the listener can still be started , stopped, and refreshed using teh LSNRCTL utility, it is normally managed with the other node applications using the SRVCTL utility.

Oracle Notification Service(ONS)
Oracle Notification Service(ONS) is used by Oracle Clusterware to propagatec传播 messages both within the RAC cluster and to clients and application-tier systems. ONS uses a publish-and-subscribe method to generate and deliver event messages to both local and remote consumers.

ONS provides the foundation for Fast Application Notification(FAN) , which in turn provides the basis for Fast Connection Failover(FCF)


Virtual IP(VIP)

Global Services Daemon(GSD)

RAC study notebook --Oracle Clusterware

in oracle1o.2, CRS has been renamed to Oracle Clusterware and is mandatory in Linux RAC environments, since third-party Clusterware si not support by Oracle on the Linux platform.
--多霸道oracle

Oracle Clusterware is installed as part of the RAC installation process.
..
In addition, in Oracle 10.2 and above, Oracle Clusterware provides a High Availability Framework that can support third-party applications running in a clustered environment, enabling them to be maintained in a running state at all times.

In a RAC envrionment it is necessary to install and configure Oracle Clusterware before installing the Oracle database software. A separate ORACLE_HOME directory must be created for oracle clusterware. This directory continues to be referred to as CRS_HOME in the Oracle 10.1 CRS terminology.

Oracle Clusterware consists of the following components:
. Cluster synchronization Services(CSS) : manages cluster node membership
--CSS 主要是管理node成员
. Cluster Ready Services(CRS): performs management operations and high availability recovery
--CRS 执行管理操作和HA 恢复
. Event Manager(EVM) manages event notifications and callouts

In Oracle 10.2 , the installation of Oracle Clusterware has been significantly improved, mainly by the inclusion of the Cluster Verification Utility(CLUVFY), which can be used to check that each stage of the process has been successfully completeed.

when Oracle Clusterware is installed , entries are added to the /etc/inittab file, and the init process spawns the EVMD, OCSSD, and CRSD processes when the node is rebooted.
-----------------
h1:35:respawn:/etc/init.d/init.evmd run >/dev/null 2>&1 h2:35:respawn:/etc/init.d/init.cssd fatal >/dev/null 2>&1 h3:35:respawn:/etc/init.d/init.crsd run >/dev/null 2>&1 -------------------


Oracle Cluster Registry
In Oracle 10.1 and above, shared storage must also be available for the OCR in which Oracle stores details of the cluster configuration, including the names and current status of the database, associated instances, services, and node applications , such as the listener process. The OCR is used by Oracle Clusterware and is managed by a number of tools, including the database configuration Assistant(DBCA), Enterprise Manager(EM), and the Server Control(SRVCTL) command-line utility.

The OCR can be stored on a raw device or on a cluster file system. It cannot , however, be stored on an automatic Storage Management(ASM) file system.

In Oracle 10.2 and above, the OCR can be mirrored, eliminating the potential for it to become a single point of failure. A maximum of two copies can be maintained by Oracle Clusterware.

Voting Disk:
shared storage is also required for a voting(or quorum) disk, which is used to determine the nodes that are currently available within the cluster. the voting disk is used by the OCSSD to detect when nodes join and leave the cluster and is therefore also known as the cluster synchronization services (CSS) voting disk.

the Voting disk has similar storage characteristics to the OCR, it can be stored on a raw device or on a cluster file system. it cannot be stored on an ASM file system.

In Oracle 10.2 and above ,t he voting disk can be mirrored , eliminating the potential for it to become a single point of failure. By default, three copies of the voting disk will be created.
Oracle recommends that an odd number of voting disk copies is maintained.



2009年5月7日星期四

grep -i 幹啥用的?

man grep
-i, --ignore-case
Ignore case distinctions in both the PATTERN and the input
files.


例子:

[root@CRRACTEST ~]# rpm -qa |grep vmware
xorg-x11-drv-vmware-10.13.0-2.1
[root@CRRACTEST ~]# rpm -qa |grep -i vmware
VMware-server-1.0.8-126538
xorg-x11-drv-vmware-10.13.0-2.1

看到差別了吧

一個rpm -e --allmatches --nodeps glibc-xxx-xxx就可以把RedHat linux徹底的幹掉了

因为production envrionment glibc有bug,会导致Oracle server random reboot, 在下面做了一个实验,记录如下:

原始的:
[root@crdb11gstd ~]# rpm -qa |grep glibc
glibc-2.5-18
glibc-devel-2.5-18
compat-glibc-2.3.4-2.26
glibc-common-2.5-18
glibc-devel-2.5-18
compat-glibc-headers-2.3.4-2.26
glibc-headers-2.5-18
compat-glibc-2.3.4-2.26
glibc-2.5-18



想update成为的:
[root@crdb11gstd ~]# rpm -Uvh glibc-common-2.5-24.x86_64.rpm
warning: glibc-common-2.5-24.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
error: Failed dependencies:
glibc-common = 2.5-18 is needed by (installed) glibc-2.5-18.i686
glibc-common = 2.5-18 is needed by (installed) glibc-2.5-18.x86_64
[root@crdb11gstd ~]# rpm -Uvh glibc-2.5-24.i686.rpm
warning: glibc-2.5-24.i686.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
error: Failed dependencies:
glibc-common = 2.5-24 is needed by glibc-2.5-24.i686
[root@crdb11gstd ~]# rpm -Uvh glibc-common-2.5-24.x86_64.rpm
warning: glibc-common-2.5-24.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
error: Failed dependencies:
glibc-common = 2.5-18 is needed by (installed) glibc-2.5-18.i686
glibc-common = 2.5-18 is needed by (installed) glibc-2.5-18.x86_64

致命的!
[root@crdb11gstd ~]# rpm -e --allmatches --nodeps glibc-2.5-18
warning: /etc/localtime saved as /etc/localtime.rpmsave
error: %trigger(redhat-lsb-3.1-12.3.EL.x86_64) scriptlet failed, exit status 255
error: %trigger(redhat-lsb-3.1-12.3.EL.i386) scriptlet failed, exit status 255
error: %postun(glibc-2.5-18.i686) scriptlet failed, exit status 255

系统崩溃了!:(

[root@crdb11gstd ~]# rpm -e --allmatches --nodeps glibc-common-2.5-18
-bash: /bin/rpm: No such file or directory
[root@crdb11gstd ~]# rpm
rpm rpm2cpio rpmbuild rpmdb rpmgraph rpmquery rpmsign rpmverify
[root@crdb11gstd ~]# rpm -e --allmatches --nodeps glibc-common-2.5-18
-bash: /bin/rpm: No such file or directory
[root@crdb11gstd ~]# man rpm
-bash: /usr/bin/man: No such file or directory
[root@crdb11gstd ~]# man rpm
-bash: /usr/bin/man: No such file or directory
[root@crdb11gstd ~]# rpm
rpm rpm2cpio rpmbuild rpmdb rpmgraph rpmquery rpmsign rpmverify
[root@crdb11gstd ~]# rpm
rpm rpm2cpio rpmbuild rpmdb rpmgraph rpmquery rpmsign rpmverify
[root@crdb11gstd ~]# rpm
rpm rpm2cpio rpmbuild rpmdb rpmgraph rpmquery rpmsign rpmverify
[root@crdb11gstd ~]# rpm --help
-bash: /bin/rpm: No such file or directory
[root@crdb11gstd ~]#
[root@crdb11gstd ~]# ls
-bash: /bin/ls: No such file or directory
[root@crdb11gstd ~]# rp
rpcclient rpcgen rpc.idmapd rpc.lockd rpc.nfsd rpc.statd rpm rpmbuild rpmgraph rpmsign
rpcdebug rpc.gssd rpcinfo rpc.mountd rpc.rquotad rpc.svcgssd rpm2cpio rpmdb rpmquery rpmverify
[root@crdb11gstd ~]# rp
rpcclient rpcgen rpc.idmapd rpc.lockd rpc.nfsd rpc.statd rpm rpmbuild rpmgraph rpmsign
rpcdebug rpc.gssd rpcinfo rpc.mountd rpc.rquotad rpc.svcgssd rpm2cpio rpmdb rpmquery rpmverify
[root@crdb11gstd ~]# rp
rpcclient rpcgen rpc.idmapd rpc.lockd rpc.nfsd rpc.statd rpm rpmbuild rpmgraph rpmsign
rpcdebug rpc.gssd rpcinfo rpc.mountd rpc.rquotad rpc.svcgssd rpm2cpio rpmdb rpmquery rpmverify

[root@crdb11gstd ~]# where rpm
-bash: where: command not found
[root@crdb11gstd ~]# where
-bash: where: command not found
[root@crdb11gstd ~]# cd

[root@crdb11gstd ~]# rpm
-bash: /bin/rpm: No such file or directory
[root@crdb11gstd ~]# rpm
-bash: /bin/rpm: No such file or directory
[root@crdb11gstd ~]# gcc
gcc gcc34 gccmakedep
[root@crdb11gstd ~]# gcc
gcc gcc34 gccmakedep
[root@crdb11gstd ~]# gcc
-bash: /usr/bin/gcc: No such file or directory
[root@crdb11gstd ~]# gcc
-bash: /usr/bin/gcc: No such file or directory
[root@crdb11gstd ~]# cd /usr/bin
[root@crdb11gstd bin]# ls
-bash: /bin/ls: No such file or directory
[root@crdb11gstd bin]# cd /user/
-bash: cd: /user/: No such file or directory
[root@crdb11gstd bin]# cd /usr
[root@crdb11gstd usr]# ls
-bash: /bin/ls: No such file or directory
[root@crdb11gstd usr]# cd /where
-bash: cd: /where: No such file or directory
[root@crdb11gstd usr]# cd /
[root@crdb11gstd /]# ls
-bash: /bin/ls: No such file or directory
[root@crdb11gstd /]# rpm
-bash: /bin/rpm: No such file or directory
[root@crdb11gstd /]#
[root@crdb11gstd /]#
[root@crdb11gstd /]#
系统嗝屁了

一個rpm -e --allmatches --nodeps glibc-xxx-xxx就可以把RedHat linux徹底的幹掉了。
网上google一下:

Avoid touching glibc. Too much other stuff depends on that; upgrading it will lead to cascading problems with every other app on the server.

迟钝 oracle 出了mac os x版本的oracle了

昨天收到oracle的宣传mail,
Oracle Database 10g Release 2 (10.2.0.4.0) for MAC OS X on Intel x86-64
地址:

http://www.oracle.com/technology/software/products/database/oracle10g/htdocs/10204macsoft_x86-64.html?msgid=7615904

立即下载先来,得空安装一下。

2009年5月6日星期三

转文:老板评价下属的普遍性原则

image

原文在此:http://www.alisdn.com/wordpress/?p=1596

看到了吧,一定要记得,叫老板烦心,比叫他操心更差!

昨天看好文今天一直记得--时间比钱重要,因为你没法挣来更多的时间

全文:ref:http://www.ruanyifeng.com/blog/2009/05/10_lessons_from_a_failed_startup_part_one.html

4. 珍惜每一分钟

Set a dollar value on your time.

我有一个坏习惯,那就是喜欢找便宜货,因此经常同别人砍价。为了把无线上网的账单降低100美元,我可以花上3个小时去谈判。我的错误在于忽略了时间的价值。相对于我们获得的投资,这样使用时间简直太不值得了。

时间比钱重要,因为你没法挣来更多的时间。(Time is arguably more valuable than money because you can’t raise more time.)

(【感谢】我太喜欢上面这句话了。很多人的失败,不是因为他没有能力,而是因为他无法有效地管理时间。我自己就是一个例子,一定要时刻鞭策自己提高效率啊。)

Oracle 11g RAC + ASM+ openfiler方式實現備忘

1, 在一部dell的pc上實現之,因為壓力太大,可能會造成其中一個節點莫名的reboot. 所以在階段性成果之後要打個tar包放在那裡,以備recovery使用
2,截止目前openfiler2.3還是不好用,只好用會2.2
3,清理cache看似還是有用的

ref:http://www.oracle.com/technology/pub/articles/hunter_rac11gr1_iscsi.html 好文章。

Scale-up , Scale-out , Why Deploy RAC?

Scale-Up
...
If you can achieve greater throughout over a fixed period of time by increasing the amount of parallelism, it is known as scale-up. Scale-up is achieved by increasing the amount of hardware resoruces, such as processors and memory, available within a single system image.

Scale-out
in a clustered environment it is possible to add hardware resources by adding another node. this is known as Scalue-out.

why Deploy RAC?
RAC can be a complex and costly technology to implement. It requires higher levels of skill and experience to architect, install, configure, tune, and support.

Most user implement RAC to achieve either higher availability, greater scalability, or a combination of these.

---pro oracle database 1og RAC on Linux

linux cache的問題實驗

sync

[root@CRRACTEST vm]# free
total used free shared buffers cached
Mem: 8033864 7967560 66304 0 18212 7544800
-/+ buffers/cache: 404548 7629316
Swap: 2031608 140 2031468
[root@CRRACTEST vm]# echo 3 >drop_caches
[root@CRRACTEST vm]# free
total used free shared buffers cached
Mem: 8033864 349108 7684756 0 292 40212
-/+ buffers/cache: 308604 7725260
Swap: 2031608 140 2031468
[root@CRRACTEST vm]#


ref:http://qustion1234.blogspot.com/2008/03/linux-cache.html
不錯的文章

2009年5月5日星期二

oracle11g中如何清除垃圾表

SQL> purge recyclebin;

Recyclebin purged.

或者在Drop表的时候加上PURGE选项,直接删除,不放于回收站中。

SQL> drop table table_name purge;

如何查看oracle中的SGA具體的使用情況

在oracle 11g中提供自動管理的功能memory_target=具體大小G,就不用管了,但是在實際操作還是需要知道某些SGA的大小

SQL*Plus: Release 11.1.0.6.0 - Production on Tue May 5 17:23:14 2009

Copyright (c) 1982, 2007, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Release 11.1.0.6.0 - 64bit Production
With the Real Application Clusters option

SQL> col name format a20
SQL> select * from v$sgainfo;

NAME BYTES RES
-------------------- ---------- ---
Fixed SGA Size 2147392 No
Redo Buffers 17014784 No
Buffer Cache Size 2818572288 Yes
Shared Pool Size 2013265920 Yes
Large Pool Size 67108864 Yes
Java Pool Size 67108864 Yes
Streams Pool Size 67108864 Yes
Shared IO Pool Size 0 Yes
Granule Size 67108864 No
Maximum SGA Size 1.0689E+10 No
Startup overhead in 603979776 No

NAME BYTES RES
-------------------- ---------- ---
Shared Pool

Free SGA Memory Avai 5637144576
lable


12 rows selected.
SQL> col name format a20
SQL> select * from v$sgainfo;


NAME BYTES RESIZEABL
-------------------- ---------- ---------
Fixed SGA Size 2144824 No
Redo Buffers 7430144 No
Buffer Cache Size 587202560 Yes
Shared Pool Size 553648128 Yes
Large Pool Size 16777216 Yes
Java Pool Size 16777216 Yes
Streams Pool Size 16777216 Yes
Shared IO Pool Size 0 Yes
Granule Size 16777216 No
Maximum SGA Size 1603411968 No
Startup overhead in 67108864 No

NAME BYTES RESIZEABL
-------------------- ---------- ---------
Shared Pool

Free SGA Memory Avai 402653184
lable


12 rows selected.

2009年5月4日星期一

Configuring Kernel Parameters and Shell Limits


The kernel parameters and shell limits presented in this section are recommended values only as documented by Oracle. For production database systems, Oracle recommends that you tune these values to optimize the performance of the system.

On both Oracle RAC nodes, verify that the kernel parameters shown in this section are set to values greater than or equal to the recommended values. Also note that when setting the four semaphore values that all four values need to be entered on one line.

Setting Shared Memory

Shared memory allows processes to access common structures and data by placing them in a shared memory segment. This is the fastest form of inter-process communications (IPC) available, mainly due to the fact that no kernel involvement occurs when data is being passed between the processes. With shared memory, data does not need to be copied between processes.

Oracle makes use of shared memory for its Shared Global Area (SGA) which is an area of memory that is shared by all Oracle backup and foreground processes. Adequate sizing of the SGA is critical to Oracle performance because it is responsible for holding the database buffer cache, shared SQL, access paths, and so much more.

To determine all shared memory limits, use the following:

# ipcs -lm

------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 4194303
max total shared memory (kbytes) = 1073741824
min seg size (bytes) = 1


in My Env:

[oracle@crOracle01 ~]$ ipcs -lm

------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 67108864
max total shared memory (kbytes) = 17179869184
min seg size (bytes) = 1



Setting SHMMAX

The SHMMAX parameters defines the maximum size (in bytes) for a shared memory segment. The Oracle SGA is comprised of shared memory and it is possible that incorrectly setting SHMMAX could limit the size of the SGA. When setting SHMMAX, keep in mind that the size of the SGA should fit within one shared memory segment. An inadequate SHMMAX setting could result in the following:

ORA-27123: unable to attach to shared memory segment

You can determine the value of SHMMAX by performing the following: # cat /proc/sys/kernel/shmmax
4294967295


[oracle@crOracle01 ~]$ cat /proc/sys/kernel/shmmax
68719476736

For most Linux systems, the default value for SHMMAX is 32MB. This size is often too small to configure the Oracle SGA. The default value for SHMMAX in Enterprise Linux 5.0 is 4GB. Note that this value of 4GB is not the "normal" default value for SHMMAX in a Linux environment — Oracle Enterprise Linux 5.0 inserts the following two entries in the file /etc/sysctl.conf:

..................................................................
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 4294967295
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 268435456
..................................................................


I highly recommend removing these two values from both Oracle RAC nodes and replacing them with the recommended values document by Oracle. All recommended Oracle kernel parameter values are documented in this section.

Oracle recommends sizing the SHMMAX parameter as the minimum of (4GB - 1 byte), or half the size of physical memory (in bytes), whichever is lower. Given my nodes are configured with 2GB of physical RAM, I will configure SHMMAX to 1GB:

  • You can alter the default setting for SHMMAX without rebooting the machine by making the changes directly to the /proc file system (/proc/sys/kernel/shmmax) using the following command:
    # sysctl -w kernel.shmmax=1073741823
    
  • You should then make this change permanent by inserting the kernel parameter in the /etc/sysctl.conf startup file:
    # echo "kernel.shmmax=1073741823" >> /etc/sysctl.conf
    

Setting SHMMNI

We now look at the SHMMNI parameters. This kernel parameter is used to set the maximum number of shared memory segments system wide. The default value for this parameter is 4096.

You can determine the value of SHMMNI by performing the following:

# cat /proc/sys/kernel/shmmni 4096 The default setting for SHMMNI should be adequate for your Oracle RAC 11g Release 1 installation.




Setting SHMALL

Finally, we look at the SHMALL shared memory kernel parameter. This parameter controls the total amount of shared memory (in pages) that can be used at one time on the system. In short, the value of this parameter should always be at least:

ceil(SHMMAX/PAGE_SIZE)
The default size of SHMALL is 2097152 and can be queried using the following command:
# cat /proc/sys/kernel/shmall

2097152

[oracle@crOracle01 ~]$ cat /proc/sys/kernel/shmall
4294967296

The default setting for SHMALL should be adequate for our Oracle RAC 11g Release 1 installation.

(Note: The page size in Red Hat Linux on the i386 platform is 4,096 bytes. You can, however, use bigpages which supports the configuration of larger memory page sizes.)

Setting Semaphores

Now that you have configured your shared memory settings, it is time to configure the semaphores. The best way to describe a "semaphore" is as a counter that is used to provide synchronization between processes (or threads within a process) for shared resources like shared memory. Semaphore sets are supported in UNIX System V where each one is a counting semaphore. When an application requests semaphores, it does so using "sets."

To determine all semaphore limits, use the following:

# ipcs -ls


max number of arrays = 128
max semaphores per array = 250
max semaphores system wide = 32000
max ops per semop call = 32


semaphore max value = 32767
You can also use the following command:
# cat /proc/sys/kernel/sem

250 32000 32 128


Setting SEMMSL

The SEMMSL kernel parameter is used to control the maximum number of semaphores per semaphore set.

Oracle recommends setting SEMMSL to the largest PROCESS instance parameter setting in the init.ora file for all databases on the Linux system plus 10. Also, Oracle recommends setting the SEMMSL to a value of no less than 100.

Setting SEMMNI

The SEMMNI kernel parameter is used to control the maximum number of semaphore sets in the entire Linux system. Oracle recommends setting the SEMMNI to a value of no less than 100.

Setting SEMMNS

The SEMMNS kernel parameter is used to control the maximum number of semaphores (not semaphore sets) in the entire Linux system.

Oracle recommends setting the SEMMNS to the sum of the PROCESSES instance parameter setting for each database on the system, adding the largest PROCESSES twice, and then finally adding 10 for each Oracle database on the system.

Use the following calculation to determine the maximum number of semaphores that can be allocated on a Linux system. It will be the lesser of:

SEMMNS -or- (SEMMSL * SEMMNI)


Setting SEMOPM

The SEMOPM kernel parameter is used to control the number of semaphore operations that can be performed per semop system call.

The semop system call (function) provides the ability to do operations for multiple semaphores with one semop system call. A semaphore set can have the maximum number of SEMMSL semaphores per semaphore set and is therefore recommended to set SEMOPM equal to SEMMSL.

Oracle recommends setting the SEMOPM to a value of no less than 100.

Setting Semaphore Kernel Parameters

Finally, we see how to set all semaphore parameters using several methods. In the following, the only parameter I care about changing (raising) is SEMOPM. All other default settings should be sufficient for our example installation.

  • You can alter the default setting for all semaphore settings without rebooting the machine by making the changes directly to the /proc file system (/proc/sys/kernel/sem) using the following command:
    # sysctl -w kernel.sem="250 32000 100 128"
  • You should then make this change permanent by inserting the kernel parameter in the /etc/sysctl.conf startup file:
    # echo "kernel.sem=250 32000 100 128" >> /etc/sysctl.conf

Setting File Handles

When configuring the Oracle RAC nodes, it is critical to ensure that the maximum number of file handles is sufficiently large. The setting for file handles denotes the number of open files that you can have on the Linux system.

Use the following command to determine the maximum number of file handles for the entire system:

# cat /proc/sys/fs/file-max

205733



[oracle@crOracle01 ~]$ cat /proc/sys/fs/file-max
248278

[oracle@oracle01 ~]$ cat /proc/sys/fs/file-max
6553600


Oracle recommends that the file handles for the entire system be set to at least 65536.

  • You can alter the default setting for the maximum number of file handles without rebooting the machine by making the changes directly to the /proc file system (/proc/sys/fs/file-max) using the following:
    # sysctl -w fs.file-max=65536

  • You should then make this change permanent by inserting the kernel parameter in the /etc/sysctl.conf startup file:
    # echo "fs.file-max=65536" >> /etc/sysctl.conf
You can query the current usage of file handles by using the following: # cat /proc/sys/fs/file-nr
960 0 65536


[oracle@oracle01 ~]$ cat /proc/sys/fs/file-nr
185640 0 6553600


[oracle@crOracle01 ~]$ cat /proc/sys/fs/file-nr
1020 0 248278

The file-nr file displays three parameters: total allocated file handles, currently used file handles, and maximum file handles that can be allocated.

Note: If you need to increase the value in /proc/sys/fs/file-max, then make sure that the ulimit is set properly. Usually for 2.4 and 2.6 kernels it is set to unlimited. Verify the ulimit setting by issuing the ulimit command:

# ulimit unlimited

Setting IP Local Port Range

Configure the system to allow a local port range of 1024 through 65000.

Use the following command to determine the value of ip_local_port_range:

# cat /proc/sys/net/ipv4/ip_local_port_range
32768 61000

The default value for ip_local_port_range is ports 32768 through 61000. Oracle recommends a local port range of 1024 to 65000.

  • You can alter the default setting for the local port range without rebooting the machine by making the changes directly to the /proc file system (/proc/sys/net/ipv4/ip_local_port_range) using the following command:
    # sysctl -w net.ipv4.ip_local_port_range="1024 65000"
  • You should then make this change permanent by inserting the kernel parameter in the /etc/sysctl.conf startup file:
    # echo "net.ipv4.ip_local_port_range = 1024 65000" >> /etc/sysctl.conf

[oracle@oracle01 ~]$ cat /proc/sys/net/ipv4/ip_local_port_range
1024 65000

[oracle@crOracle01 ~]$ cat /proc/sys/net/ipv4/ip_local_port_range
32768 61000



Setting Shell Limits for the oracle User

To improve the performance of the software on Linux systems, Oracle recommends you increase the following shell limits for the oracle user:

Shell Limit
Item in limits.conf
Hard Limit
Maximum number of open file descriptors
nofile
65536
Maximum number of processes available to a single user
nproc
16384

To make these changes, run the following as root:
cat >> /etc/security/limits.conf <oracle soft nproc 2047

oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF
cat >> /etc/pam.d/login <# Added for Oracle Shell Limits

session required /lib/security/pam_limits.so
session required pam_limits.so

ref:http://www.oracle.com/technology/pub/articles/hunter_rac11gr1_iscsi_2.html
EOF

How to add temporary swap file

If you have less than 2GB of memory (between your RAM and SWAP), you can add temporary swap space by creating a temporary swap file. This way you do not have to use a raw device or even more drastic, rebuild your system.

As root, make a file that will act as additional swap space, let's say about 500MB:

# dd if=/dev/zero of=tempswap bs=1k count=500000

Now we should change the file permissions:

# chmod 600 tempswap

Finally we format the "partition" as swap and add it to the swap space:

# mke2fs tempswap
# mkswap tempswap
# swapon tempswap

2009年5月3日星期日

How to: Mount an ISO image under Linux

ref: http://www.cyberciti.biz/tips/how-to-mount-iso-image-under-linux.html

An ISO image is an archive file (disk image) of an optical disc using a conventional ISO (International Organization for Standardization) format. ISO image files typically have a file extension of .ISO. The name "ISO" is taken from the ISO 9660 file system used with CD-ROM media, but an ISO image can also contain UDF file system because UDF is backward-compatible to ISO 9660.

You can mount an ISO images via the loop device under Linux. It is possible to specify transfer functions (for encryption/decryption or other purposes) using loop device.

But, how do you mount an ISO image under Linux? You need to use mount command as follows:

Procedure to mount ISO images under Linux

1) You must login as a root user, if not root user then switch to root user using following command:
$ su -

2) Create the directory i.e. mount point:
# mkdir -p /mnt/disk

3) Use mount command as follows to mount iso file called disk1.iso:
# mount -o loop disk1.iso /mnt/disk

4) Change directory to list files stored inside an ISO image:
# cd /mnt/disk
# ls -l

More about loop device

A loop device is a pseudo-device that makes a file accessible as a block device. Loop devices are often used for CD ISO images and floppy disc images. Mounting a file containing a filesystem via such a loop mount makes the files within that filesystem accessible. They appear in the mount point directory using above commands.


我的实验:

[root@CRRACTEST media]# vi mnt.sh

mount -o loop Enterprise-R5-U2-Server-x86_64-disc1.iso /media/disk1
mount -o loop Enterprise-R5-U2-Server-x86_64-disc2.iso /media/disk2
mount -o loop Enterprise-R5-U2-Server-x86_64-disc3.iso /media/disk3
mount -o loop Enterprise-R5-U2-Server-x86_64-disc4.iso /media/disk4

记录一下:)