Title: Linux??????????
1Linux??????????
???? 2009?6?21?
2????
- ???,??????
- IXPUB ?????????? Linux????????
- ??oracle? Unix/Linux??,???????ITPUB.net?IXPUB.net?
ChinaUnix.net???????,?????oracle????Unix/Linux????
???????,??????oracle??????????????,??oracle???????
?,????,?Unix/Linux???????????? -
- ????????????
- MSNgaojf_888_at_hotmail.com
- QQ397824870
- Emaildba.gao_at_gmail.com
3Linux??????????
- ??Linux?????
- ????????
- ????????
- ?????????
- Oracle?Linux??????
4? ??Linux????????
5? ????????
?????? ???? ???? ????
?????? ? ? ??
CPU user syslt 70 user sys 85 user sys gt90
?? Swap In(si)0 Swap Out(so)0 Per CPU with 10 page/s More Swap In Swap Out
?? iowait lt 20 iowait 35 iowait gt 50
?? user??CPU?????????????? sys??CPU????????
?????? iowait??CPU??????????????? swap
in?si,??????????,??SWAP DISK???RAM swap
out?so,??????????,??RAM???SWAP DISK?
5
6? ????????
??????
Vmstat?sar?iostat?netstat?free?ps?top?
??????
- ?vmstat?sar?iostat?????CPU??
- ?free?vmstat?????????
- ?iostat???????I/O??
- ?netstat???????????
7? Linux???????
1????????(uptime??)
root_at_web1 uptime 163800 up 118 days,
301, 5 users, load average 1.22, 1.02, 0.91
????????load average?????,???????????????CPU??
?,??,???????8?CPU,??load average????????8?,??CPU??
?,????,?????????,??????8?,?????,?????????????,??lo
ad average??????CPU???,???CPU????????,????????,CPU
???????
82cpu????
- (1)??vmstat??????CPU
- ??????????????????????????,??????????CPU???????
- ???vmstat????????????
-
- root_at_node1 vmstat 2 3
- procs -----------memory---------- ---swap--
-----io---- --system-- -----cpu------ - r b swpd free buff cache si so
bi bo in cs us sy id wa st - 0 0 0 162240 8304 67032 0 0 13
21 1007 23 0 1 98 0 0 - 0 0 0 162240 8304 67032 0 0 1
0 1010 20 0 1 100 0 0 - 0 0 0 162240 8304 67032 0 0 1
1 1009 18 0 1 99 0 0 - Procs
- r????????cpu???????,???????????CPU???,??CPU??,???
?CPU? - b????????????,??????I/O?????????
- Cpu
- us???????????CPU ??????us??????,?????????cpu???,?
???????50,????????????? - sy???????????CPU??????Sy?????,???????CPU?????
- ????,ussy?????80,??ussy?? 80??????CPU?????
9(2) ??sar??????CPU
- sar?????,?????????????????,????sar?????????,??????
??????,???????????????? - ???sar????????CPU????
- root_at_webserver sar -u 3 5
- Linux 2.6.9-42.ELsmp (webserver)
11/28/2008 _i686_ (8 CPU) - 114124 AM CPU user nice system
iowait steal idle - 114127 AM all 0.88 0.00 0.29
0.00 0.00 98.83 - 114130 AM all 0.13 0.00 0.17
0.21 0.00 99.50 - 114133 AM all 0.04 0.00 0.04
0.00 0.00 99.92 - 114136 AM all 90.08 0.00 0.13
0.16 0.00 9.63 - 114139 AM all 0.38 0.00 0.17
0.04 0.00 99.41 - Average all 0.34 0.00 0.16
0.05 0.00 99.45 -
- ????????????
- user???????????CPU ??????
- nice??????????????CPU ??????
- system???????????CPU??????
- iowait????IO??????CPU?????
- steal???????????????pagein???????????steal?? ?
10???
????????CPU???????,?????????
????CPU????,??????????,?????????,CPU????????,?????
??????,????????????????,????????CPU,????CPU????100
,????????,????CPU???,???????CPU?????,???????????
113??????
(1)??free?????? free???linux????????????,????????
root_at_webserver free -m
total used free shared
buffers cached Mem 8111 7185
926 0 243 6299 -/
buffers/cache 643 7468 Swap
8189 0 8189
???????????????????/??????gt70?,????????????,????
???,????????/??????lt20?,??????????,????????,20lt?
???????/??????lt70?,?????????????????,??????????
12(2) ??vmstat??????
- root_at_node1 vmstat 2 3
- procs -----------memory---------- ---swap--
-----io---- --system-- -----cpu------ - r b swpd free buff cache si so
bi bo in cs us sy id wa st - 0 0 0 162240 8304 67032 0 0 13
21 1007 23 0 1 98 0 0 - 0 0 0 162240 8304 67032 0 0 1
0 1010 20 0 1 100 0 0 - 0 0 0 162240 8304 67032 0 0 1
1 1009 18 0 1 99 0 0 - memory
- swpd????????????????(?k???)???swpd????0,?????,??s
i?so?????0,???????????,????????? - free??????????????(?k???)
- buff???buffers cache?????,???????????????
- cache???page cached?????,????????cached,?????????
?cached,??cache???,??cached??????,????IO?bi???,???
????????? - swap
- si??????????,????????????????
- so??????????,????????????????
- ?????,si?so????0,??si?so??????0,??????????????????
?
134??I/O????
- (1)??????
- ??RAID????,?????????,?????RAID???
- ???????????????I/O,??????????????????????,???
???????????????????? - ??????????????????????,??????????????
- ??????????,????????????????
-
- ?????????
- ????????,?????????????,???????,??????????
- ?????????????,??????????????I-node??
- ????????cache????,???I/O???
- ?????????
- ????????????,???????????
14- (2)??iostat??????
- root_at_webserver iostat -d 2 3
- Linux 2.6.9-42.ELsmp (webserver)
12/01/2008 _i686_ (8 CPU) -
- Device tps Blk_read/s Blk_wrtn/s
Blk_read Blk_wrtn - sda 1.87 2.58 114.12
6479462 286537372 -
- Device tps Blk_read/s Blk_wrtn/s
Blk_read Blk_wrtn - sda 0.00 0.00 0.00
0 0 -
- Device tps Blk_read/s Blk_wrtn/s
Blk_read Blk_wrtn - sda 1.00 0.00 12.00
0 24 - ????????????
- Blk_read/s????????????
- Blk_wrtn/s????????????
- Blk_read??????????
- Blk_wrtn??????????
15(3)??sar?????? ??sar
d??,????????IO????????,????????? root_at_webserv
er sar -d 2 3 Linux 2.6.9-42.ELsmp
(webserver) 11/30/2008 _i686_ (8
CPU) 110933 PM DEV tps rd_sec/s
wr_sec/s avgrq-sz avgqu-sz await svctm
util 110935 PM dev8-0 0.00 0.00
0.00 0.00 0.00 0.00
0.00 0.00 110935 PM DEV tps
rd_sec/s wr_sec/s avgrq-sz avgqu-sz await
svctm util 110937 PM dev8-0 1.00 0.00
12.00 12.00 0.00 0.00
0.00 0.00 110937 PM DEV tps
rd_sec/s wr_sec/s avgrq-sz avgqu-sz await
svctm util 110939 PM dev8-0 1.99 0.00
47.76 24.00 0.00 0.50
0.25 0.05 Average DEV tps
rd_sec/s wr_sec/s avgrq-sz avgqu-sz await
svctm util Average dev8-0 1.00 0.00
19.97 20.00 0.00
0.33 0.17 0.02 ??????????? await??
??????I/O???????(??????)? svctm????????I/O???????
(??????)? util???????????????I/O???
16(3)??sar?????? ????IO??,????????? ?????svctm??
???await??,?svctm??????????,CPU?????????svctm?????
,????????????svctm????? await?????????svctm???I/O
??????I/O????,??svctm???await???,??????I/O??,?????
?,??await?????svctm??,???I/O??????,?????????????,?
?????????????????? util?????????I/O???????,??ut
il??100,???????I/O????,I/O???????????,???????????
???,?????????,?????????????????????????????
175??????
(1)??ping?????????? (2)??netstat
i?????????? (3)??netstat r???????????? (4)??sa
r n?????????????
18? Oracle?Linux??????
- Oracle??????????
- ?oracle?????????
- SGA?PGA????
- Oracle?????????
- ???????(ext2/ext3?xfs?ocfs2)
- Oracle ASM??
191??oracle???????????
1)?????? 2)?????????????? 3)??????????????? 4)
??????? 5)???OLTP ????OLAP ??
202Oracle??????????
(1)?????? ?? /etc/sysctl.conf
????,??????? kernel.shmmax 2147483648 kernel.s
hmmni 4096 kernel.shmall 2097152 kernel.sem
250 32000 100 128 fs.file-max
65536 net.ipv4.ip_local_port_range 1024
65000 ????? Kernel.shmmax??????????(??????)? Ke
rnel.shmmni?????????????? Kernel.shmall??????,??
???? fs.file-max?????,???Linux????????????? net.i
pv4.ip_local_port_range????????IPv4?????
21?????????
??Kernel.shmmax Oracle SGA ???????,??????
SHMMAX?????SGA ???,SHMMAX?????????????ORA-27123u
nable to attach to shared memory
segment,?????????Oracle SGA??,??SGA???????????????
??????????????,??????? Oracle??Kernel.shmmax????s
ga,??oracle?????SGA?????????,??????? ??Kernel.shm
all ???????????,?????? ??32??Linux??,8G???,????
kernel.shmall 2097152,?? 20971524k/1024/1024
8G ??????????? 8G,???4K?32??????????,?4096??? ?
?Kernel.shmmni ?????????????????????4096,??????,
?SUN OS???Kernel.shmmin??,???????????,????!
22(2)SGA?PAG????
- Oracle??????????
- Oracle 9i????PGA_AGGREGATE_TARGET????PGA???? Orac
le 10g????SGA_TARGET?????SGA?????, - Oracle 11g??????????????????,??????SGA?PGA?????
- ???????????
- MEMORY_TARGET????ORACLE???????????,??PGA?SGA????
?,?????????,??????SGA?PGA???? - MEMORY_MAX_TARGET???????MEMORY_TARGET???????????
????,??????MEMORY_MAX_TARGET?,????MEMORY_TARGET???
- ?????????,SGA_TARGET?PGA_AGGREGATE_TARGET????????
???????,??Oracle????????,??????????0?
23B. Oracle????????
- ??????,?AMM (Automatic Memory Management)
- ????????,?ASMM(Automatic Shared Memory
Management) - ????????
- ??PGA??
- ??PGA??
24??????(AMM)
????oracle11g?????AMM????????? ???? SQLgt show
parameters target NAME
TYPE
VALUE------------ ---------------------
------------------ ----------------------
archive_lag_target integer
0db_flashback_retention_target
integer 1860fast_start_io_t
arget integer
0fast_start_mttr_target
integer 0memory_max_target
big integer
1400Mmemory_target big
integer 1400Mpga_aggregate_target
big integer
0sga_target big
integer 0 ????????? LOCK_SGA
true ,? AMM ??????
25????????
?????????oracle10g???,?????????????,????MEMORY_TAR
GET0,??????SGA_TARGET??? ???? SQLgt alter
system set memory_target0 scopebothSystem
altered.SQLgt alter system set sga_target1024m
scopebothSystem altered.SQLgt
26????????
Oracle9i??????,????????????,?????????????,??????SG
A_TARGET ? MEMORY_TARGET?0? SGA??????? share_po
ol_size?????,??300-500M??? Log_buffer???????,??1
-3M??? Large_pool_size??????,?MTS??,???20-30M???
Java_pool_sizejava???,??java???,??10-20M??? db_ca
che_size???????,?????????,?????
27??PAG??
Oracle9i???????PGA??,??????AMM????,?????PGA???,???
???AMM???????,??????PGA??,?? WORKAREA_SIZE_POLICY
AUTO ????PGA_AGGREGATE_TARGET?????,
??PAG??
??????????PGA,?????????PGA,?? WORKAREA_SIZE_POLICY
manual ??????PGA?????? PGA????? SORT_AREA_SI
ZE SORT_AREA_RETAINED_SIZE,
283Oracle?????????
- ??????????
- ???????
- ??????(ext2?ext3?xfs?)
- ??????(gfs?ocfs2)
- ?????????
- ?????????
- ?????????????????,???????
- ASM(Automatic Storage Management)
- ASM??
- ???????,??????????????,?????????????????
- Oracle?????????????
29????