RHCA 442-1(1)
- Business Level Tuning > Application Level Tuning > Kernel Level Tuning(RH442)
- grep CPU /proc/cpuinfo
- lscpu
a. lscpu -p - cat /proc/cpuinfo
a. cat /proc/meminfo
RHCA 442-1(2) - dmesg(实时kernel信息)
- /var/log/dmesg(开机kernel信息写入)
- getconf -a
- x85info(yum install x86info -y)
- dmidecode
a. dmidecode -t 0 - cd /sys/class/dmi/id/
- lspci
a. lspci -v
b. lspci -vv
c. lspci -vvv - lsusb
a. lsusb -v - ethtool eth0
- powertop(yum install powertop -y)
- sosreport
RHCA 442-2(1) - K=1000
a. Ki=1024 - vmstat
a. vmstat 1 5
b. dd if=/dev/zero of=/dev/null
c. buffer= buffer cache(文件描述数据)
d. cache= page cache(文件内容数据)
e. echo 3 > /proc/sys/vm/drop_cahces
f. bi= block in
g. bo= block out - iostat
a. iostat -x sda 1 - mpstat
a. mpstat 1
b. mpstat -p 0 1 - sar
a. yum install sysstat
b. cat /etc/cron.d/sysstat
c. LANG=C sar -q(CPU负载)
d. LANG=C sar -b(I/O状况)
e. LANG=C sar -p 0 (第一颗cpu状态)i. sar -b -s 17:00:00 -e 19:00:00
f. LAMD=C sar -d(磁盘状态)
g. LANG=C sar -n DEV|EDEV(网络信息)
h. cd /var/log/sa/
i. cat /etc/sysconfig/sysstat - awk
a. awk -F: ‘{print $1}’ /etc/passwd
b. df -P | awk ‘{print $1 “ is mount on “ $NF}’
c. awk -F: ‘BEGIN{print “User List:”} {print $1} END{print “Done.”}’ /etc/passwd
d. df -hP | awk ‘BEGIN{print “File System status:”}{print $1,$(NF-2)} END{print “Done.”}’
e. awk -F: ‘/^r/ {print $1}’ /etc/passwd
f. awk -F: ‘/^[a-z]t:./ {print $1}’ /etc/passwd
g. sar -q | awk ‘/^[^a-z]+$/{print $1,$4,$5,$6}’ > /tmp/cpudata - gnuplot
a. yum install gnuplot -t
b. gnuploti. set xdata tim ii. set timefmt "%H:%M:%S" iii. plot "/tmp/cpudata" using 1:2 with lines
RHCA 442-2(2)
- Little’s Law
- L(lenth) = A(arrival time)* W(wait time)
- W(wait time) = Q(queue time) +S(service time)
- S(service time) = St(sys time) + Ut(user time)
- time command
a. time updatedb
b. echo 3 > /proc/sys/vm/drop_caches
c. time updatedb
RHCA 442-3(1-2) - lsmod
a. ls /lib/modules/3.10.0-327.el7.x86_64/ (kernel模块)
b. ll /boot/vmlinuz-3.10.0-327.el7.x86_64 (kernel本身) - modinfo
a. modinfo st
b. modinfo -p st
c. modinfo usb_storage
d. modinfo sx8 - modprobe
a. modprobe st - rmmod
a. rmmod st - /etc/modprobe.d/my.conf
a. options usb_storage delay_user = 3
b. options st buffer_kbs = 64
c. options sx8 max_queue = 15 - /sys/module/$(mname)/paraments/$(pname)
a. more /sys/module/usb_storage/parameters/delay_use - more /etc/sysconfig/modules/st.modules (开机模块加载)
- I/O Schedulers
a. cfq,deadline,anticipatory,noop
b. cat /sys/block/sda/queue/scheduler ([]中是当前电梯算法)
c. more /sys/block/sda/queue/nr_requests
d. more /sys/block/sda/queue/read_ahead_kb
e. echo cfq > /sys/block/sda/queue/scheduler
f. more /sys/block/sda/queue/scheduler
g. ll /sys/block/sda/queue/iosched
RHCA 442-3(3) - tuned
a. yum info tuned
b. yum install tuned -y
c. tuned-adm active
d. tuned-adm list
e. tuned-adm profile desktop
f. ll /usr/lib/tuned/
g. cp -a /usr/lib/tuned/desktop/* /etc/tuned/ex442/
RHCA 442-4(1) - CPU Scheduling
- CFS Scheduler
a. virtual time - chrt command
a. chrt -f 10 top
b. chrt -r 1 md5sum /dev/zero
RHCA 442-4(2) - x86info -c
- valgrind -tool=cahcegrind command1
- perf stat -e cahce-misses command
RHCA 442-4(3-4) - pam_limits
a. vi /etc/security/limits.conf
b. ulimit -ai. user hard cpu 1
c. cgroup
RHCA 442-5(1)i. service cgconfig start ii. service cgred start iii. lssubsys -m iv. echo 0 > /sys/devices/system/cpu/cpu1/online (下线cpu) v. mount -t tmpfs none /mnt/tmpfs (物理内存挂成分区) - strace
a. kernel space(system call)
b. strace updatedb
c. strace -e trace=network ping -c1 i
d. strace -e trace=file ls /
e. strace -p 1
f. strace -c updatedb - ltrace
a. user space(library call [glibc])
b. ltrace updatedb
c. ltrace ls / - systemtap
a. yum install kernel-debuginfo -y
b. stap -v abc.stapi. yum install systemtap ii. stap -c /usr/share/doc/systemtap-client-3.0/examples/profiling/topsys.stp
c. staprun abc.ko
d. stapusr group
e. stapdev group
RHCA 442-5(2) - Paging
a. pages,x86 normal page size is 4KiB
b. getconf PAGE_SIZE - VSZ
- RSS
- TLB
- mount -t hugetlbfs none /muntpoint
- Tune per-BDI Flush Threads
a. vm.dirty_expire_centisecs
b. vm.dirty_writeback_centisecs - Oou of Menory(OOM)
- Memory Overcommit
a. sysctl -p | grep overcommit_memory
b. sysctl -p | grep overcommit_ratio
c. grep Coomitted_AS /proc/meminfo - SysV IPC
a. ipcs
b. ipcs -l
c. Tune Semaphores
d. Message queues
e. Shared memory
RHCA 442-6(1)i. kernel.shmmni ii. kernel.shmmax iii. kernel.shmall - File Systems
a. EXT3
b. EXT4
c. XFS
d. BTRFS - External Journaling
a. mkfs.ext4 -O journal_dev -b 4096 /dev/vdb1
b. mkfs.ext4 -J device=/dev/vdb1 -b 4096 /dev/vda3
c. blkid
RHCA 442-6(2) - yum install qperf
- sysctl net.ipv4.tcp_low_latency
- net.ipv4.tcp_mem/net.ipv4.udp_mem(单位pages)
- tc qdisc show
Bonding mode
a. balance-rr: mode 0
b. actice-backup: mode 1
c. 802.3ad: mode 4(工作在2层,需要配交换机)
d. cat /proc/net/bonding/bond0MTU(最大传输单元 default 1500bytes)
a. TCP protocol headers 52 (52/1500=3.5% overhead)
b. TDP protocol headers 28 (28/1500=1.9% overhead)
c. Jumbo Frames (MTU bigger that 1500 需要配置交换机)i. Official maximum size is 9000 bytes (52/9000=0.58% overhead ii. vi /etc/sysconfig/network-scripts/ifcfg/eth0==》"MTU=9000"