分类目录归档:linux

Enqueue: Owners, Converters and Waiters

This is a case about enqueue from the book Oracle Core. The case demonstrates two feature of oracle enqueue:

1. Lock conversion
Lock conversion appears in the common foreign key problem, If supporting index is missing on a foreign key, and a session is try to update or delete on the parent table, it will lock the child table with mode 4. If the session already hold a lock on child table with mode 3, when it update or delete on the parent table, it’ll convert the lock to mode 5.

2. The priority of the converters and waiters
There are 3 queues per enqueue, owners/converters/waiters. Once the owner release the enqueue, which session will hold the lock first, the one in converters queue or the one in waiters queue? 继续阅读

“Linux kernel Development” Read Notes[Part I]

I am a progmatic engineer and this is a practical book. It shouldbe fun, easy to read, and useful. ——Robert Love

I’ve dived into the book in recent two weeks, it’s surprising that how straight forward and funny the book is. Armed with knowledge of the design and implement of the kernel, some oracle featurne such as latching,enqueue suddently become clear to me.

Here comes some notes, I’ll definitely go through the book for second time, then the Part II will come:-)

1. About the Process status

TASK_RUNNING: This is the only possible state for a process executing in the user-space.

If The process is in user-space, it is now running on CPU or wait for CPU in run queue.
If the process need to proactive sleep or wait, it is done by system call, which is in kernel-space. For example, in oracle, when the server process wait for the enqueue TX, the waiting is done by semorphore operation, the system call semop.

--session 1
sid@SID10G> create table t as select 1 n from dual;

Table created.

sid@SID10G> update t set n = 2;

1 row updated.

--session 2 is blocked
sid@SID10G> update t set n = 3;

–if we trace the process of session 2 where is is blocked, we can found the process wait and timeout on the semop syscall every 3 seconds.

oracle ~ $sudo dtruss -p 48367
semop(0x40002, 0x7FFF5FBF6C80, 0x1)		 = -1 Err#4

2. Thread in Linux

To the Linux kernel, there is no concept of a thread. Linux implements all threads as standard process.

Thread is process, just share resource, such as the process address space, file descriptor.

3. Complete Fair Scheduling in 2.6 Kernel

When the CFS id deciding what process to run next, it picks the process with the smallest vruntime.

it’s surpprising to see that there is no fixed *timeslice* concept in the schedule algorithim, the CFS will make sure all the process share the same cpu resource, the one have least cpu time will be selected to run.

4. Simplicity

Start simple and grow in complexity as needed, Simplicity is key.

5. Compromise

Picking the right value, like a successful relationship, is all about compromise

tune Linux physical memory

32G memory的Linux,跑一些application batch report,把archive redo log 搬到Tape上面,以及每天的Rman Full database backup,physical free memory只有35M

zzz ***Mon Dec 21 08:57:00 HKT 2009
MemTotal:     32889900 kB
MemFree:         35348 kB
Buffers:        109088 kB
Cached:       28892412 kB
SwapCached:       8592 kB
Active:        7049552 kB
Inactive:     24023160 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:     32889900 kB
LowFree:         35348 kB
SwapTotal:    16777208 kB
SwapFree:     16466904 kB
Dirty:            1628 kB
Writeback:           0 kB
Mapped:        6811368 kB
Slab:           839432 kB
CommitLimit:  33222156 kB
Committed_AS: 14507408 kB
PageTables:     801492 kB
VmallocTotal: 536870911 kB
VmallocUsed:    273416 kB
VmallocChunk: 536597367 kB
HugePages_Total:     0
HugePages_Free:      0
Hugepagesize:     2048 kB

通过调整vm参数来保证至少2G的physical free memory,避免负载上升时发生Swap导致CPU100%和node reboot

sysctl -w vm.min_free_kbytes=2097152
sysctl -w vm.vfs_cache_pressure=200

cd /proc/sys/vm
cat min_free_kbytes
cat vfs_cache_pressure

REF:http://www.oraclefans.cn/forum/showtopic.jsp?rootid=12006

oracle RAC 10.2 installation on Vmware

Ref:
http://www.oracle-base.com/articles/10g/OracleDB10gR2RACInstallationOnCentos4UsingVMware.php
http://download-uk.oracle.com/docs/cd/B19306_01/install.102/b15660/toc.htm

折腾了一个星期,终于把RAC装上了。贴出来纪念一下。
环境是
Host和Guest都装了Redhat Linux 5(2.6.18-128.el5)
host:

Guest:

终于装完了啊.

机器被我折磨的要死了.一个Guest Vm应该给一个CPU就好了,我给了两个,感觉明显比配一个慢了.

丰收的时刻

[oracle@rac1 bin]$ env | grep SID
ORACLE_SID=SIDRAC1
[oracle@rac1 bin]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Oct 17 13:24:09 2009

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


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

SQL> col host_name for A20
SQL> select instance_name, host_name from gv$instance;

INSTANCE_NAME    HOST_NAME
---------------- --------------------
SIDRAC1          rac1.localdomain
SIDRAC2          rac2.localdomain

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production