我的站点

一个系统软件工程师的随手涂鸦

Month: 二月 2016 (Page 1 of 3)

Oracle笔记(7)——Oracle进程,server进程和background进程

Oracle手册上对于Oracle process的定义:

A unit of execution that runs the Oracle database code. The process execution architecture depends on the operating system. Oracle processes include server processes and background processes.

Oracle process即是运行Oracle数据库的代码,它分成server processbackground process两种。

Server process的定义:

An Oracle process that communicates with a client process and Oracle Database to fulfill user requests. The server processes are associated with a database instance, but are not part of the instance.

Server process可以看做是连接数据库client进程和数据库之间的桥梁,用来处理client的请求。虽然同Instance相关联,但不属于具体的Instance

Background process的定义:

A process that consolidates functions that would otherwise be handled by multiple Oracle programs running for each client process. The background processes asynchronously perform I/O and monitor other Oracle processes.

Background process用来做实际的I/O操作和监控其它Oracle进程。

参考资料:
Glossary

 

Oracle笔记(6)——SGA

Oracle手册上对于SGA(System Global Area)的定义:

The SGA is a read/write memory area that, along with the Oracle background processes, form a database instance. All server processes that execute on behalf of users can read information in the instance SGA. Several processes write to the SGA during database operation.

Note: The server and background processes do not reside within the SGA, but exist in a separate memory space.

Each database instance has its own SGA. Oracle Database automatically allocates memory for an SGA at instance startup and reclaims the memory at instance shutdown.

SGAOracle后台进程一起组成了数据库的Instance。每个Instance拥有自己的SGAInstance启动时会自动分配SGA,退出时会回收SGASGA包含下列组成部分:

✓ Shared pool
✓ Database buffer cache
✓ Redo log buffer
✓ Large pool
✓ Java pool
✓ Streams pool

参考资料:
Oracle 12c For Dummies
Overview of the System Global Area (SGA)

 

Go语言的函数返回多个值

以下摘自The Go Programming Language

Often, functions use these additional results to indicate some kind of error, either by returning an error as in the call to os.Open, or a bool, usually called ok. If a map lookup, type assertion, or channel receive appears in an assignment in which two results are expected, each produces an additional boolean result:
v, ok = m[key] // map lookup
v, ok = x.(T) // type assertion
v, ok = <-ch // channel receive
As with variable declarations, we can assign unwanted values to the blank identifier:
_, err = io.Copy(dst, src) // discard byte count
_, ok = x.(T)

map查找,类型断言和从channel接收数据都会返回两个值,其中一个是表示成功或失败的布尔值。同变量定义一样,不想要的值可以赋给_

 

2016年2月简讯

这个月除了春节小长假外,公司又额外放了4天假,自己又请了2天假,所以实际工作的时间也就半个月。

工作方面:
由于团队人事调整,我需要接管一些服务器性能测试的工作。这个月主要集中学习了Oracledocker的相关知识。Oracle是初次打交道,目前已经入门了。Docker去年接触过,今年捡起来,又把以前没搞清楚的一些知识点弄明白了。感觉这半个月工作上收获不小。

业余时间(技术):
业余时间集中在sysdighaskell编程两块。Sysdig已经能用起来了,也为Sysdig提交了第一个PR,下一步试着自己写一下chiselHaskell果然同以前接触过的编程语言相差太大,自己到现在还没有入门。由于不大可能有整块的时间供自己来学习,只能是抽时间加把劲了。

业余时间(读书):
读了马克吐温的《我怎样编辑农业报》和几篇小小说。

生活方面:
由于春节假期时间比较长,找时间去了一趟新加坡。气候好,空气也不错。如果以后有机会,很期待来这里工作和生活。

 

Linux kernel 笔记 (60)——scheduling domain

NUMA系统上,由于不同CPU直接访问本地内存和远端内存的时间相差很大,所以更好地调度算法就显得很重要。Linux kernel引入了scheduling domain的概念。可以参看下面例子:

[root@localhost ~]# cd /proc/sys/kernel/sched_domain/
[root@localhost sched_domain]# ls
cpu0  cpu1  cpu2  cpu3  cpu4  cpu5  cpu6  cpu7
[root@localhost sched_domain]# ls -alt *
cpu0:
total 0
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 domain0
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 domain1
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 .
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 ..

cpu1:
total 0
dr-xr-xr-x. 1 root root 0 Feb 26 20:06 domain0
dr-xr-xr-x. 1 root root 0 Feb 26 20:06 domain1
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 .
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 ..

cpu2:
total 0
dr-xr-xr-x. 1 root root 0 Feb 26 20:06 domain0
dr-xr-xr-x. 1 root root 0 Feb 26 20:06 domain1
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 .
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 ..

cpu3:
total 0
dr-xr-xr-x. 1 root root 0 Feb 26 20:06 domain0
dr-xr-xr-x. 1 root root 0 Feb 26 20:06 domain1
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 .
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 ..

cpu4:
total 0
dr-xr-xr-x. 1 root root 0 Feb 26 20:06 domain0
dr-xr-xr-x. 1 root root 0 Feb 26 20:06 domain1
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 .
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 ..

cpu5:
total 0
dr-xr-xr-x. 1 root root 0 Feb 26 20:06 domain0
dr-xr-xr-x. 1 root root 0 Feb 26 20:06 domain1
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 .
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 ..

cpu6:
total 0
dr-xr-xr-x. 1 root root 0 Feb 26 20:06 domain0
dr-xr-xr-x. 1 root root 0 Feb 26 20:06 domain1
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 .
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 ..

cpu7:
total 0
dr-xr-xr-x. 1 root root 0 Feb 26 20:06 domain0
dr-xr-xr-x. 1 root root 0 Feb 26 20:06 domain1
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 .
dr-xr-xr-x. 1 root root 0 Feb 26 19:37 ..

/proc/sys/kernel/sched_domain/目录下每个CPU都有一个自己的目录,并且每个CPU目录下都有和自己相关的domain信息。

multi-level系统中,也拥有multi-levelscheduling domain(内核中结构体是struct sched_domain)。每个scheduling domain包含一组共享属性和调度策略的CPU;每个scheduling domain包含至少一个或多个CPU group(内核中结构体是struct sched_group),每个CPU group会被scheduling domain看做一个独立的单元。

scheduling domain的核心代码位于kernel\sched\core.c中,关于/proc/sys/kernel/sched_domain/cpu$/domain$中各个文件的含义,都可以在这里找到。

NUMA系统上,如果一个node利用率非常高,比如高于90%,而另一个node利用率可能只有60%~70%,这时可以尝试disable wakeup affinity

参考资料:
Scheduling domains
sched-domains.txt
Does domain0 in /proc/sys/kernel/sched_domain/cpu$ refer top-level domain in the system?
How to understan /proc/sys/kernel/sched_domain/cpu$/domain$/flags?

docker笔记(8)—— Container的生命周期

docker create创建一个containerdocker start则启动这个container

docker run相当于docker create加上docker start。需要注意的是,一旦执行完container需要做的工作,container就会退出:

# docker run hello-world

Hello from Docker.
......

# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
62a13663511f        hello-world         "/hello"            5 seconds ago       Exited (0) 4 seconds ago                       compassionate_ptolemy

停止container可以使用下列两个命令:
docker kill:向container发送SIGKILL信号;
docker stop:先向container发送SIGTERM信号,过一段时间再发送SIGKILL信号。

彻底干掉container使用docker rm命令。移除所有已经停止的container可以使用下列命令:

$ docker rm $(docker ps -a -q)

参考资料:
Docker Cookbook

 

docker笔记(7)—— Index,registry和repository

看一下对三个词的英文解释:

An index manages user accounts, permissions, search, tagging, and all that nice stuff that’s in the public web interface.

A registry stores and serves up the actual image assets, and it delegates authentication to the index. Docker registry is a service that is storing your docker images.

Docker repository is a collection of different docker images with same name, that have different tags.

Index是管理docker的服务(包含用户账户,操作权限,等等)。Registry是存储docker image的服务。Repository则是包含同名不同tagdocker image的集合。

参考资料:
Difference between Docker registry and repository
Where are Docker images stored?

 

docker笔记(6)—— 在docker container中执行命令的脚本

下面脚本的功能是循环地在各个container中执行命令:

#!/bin/bash -x

for i in {1..2}
do
        docker exec -i hammerdb_net${i} bash <<-EOF
        su oracle
        source /tmp/ora_env
        cd /data/oracle/tablespaces/
        rm -f *.html
        ./create_awr.sh
        mv awr.html awr_${i}.html
        EOF
done

需要注意的是在dodone之间应该使用tab而不是空格。

参考资料:
Indenting bourne shell here documents
How to write a bash script which automate entering “docker container” and doing other things?
Can’t indent heredoc to match nesting’s indent

 

Haskell笔记 (19)—— Guard

guard跟在函数名和参数之后,用管道符号表示:

myCompare :: (Ord a) => a -> a -> Ordering  

myCompare a b
    | a < b = LT
    | a == b = EQ
    | otherwise = GT    

guard长得和pattern类似,pattern检查输入是否符合这个pattern,而guard则会计算布尔表达式,返回TrueFalse。如果返回值是True,则执行等号后面的函数体部分。

参考资料:
Guards, guards!

htop简介

top*nix上常用的监控系统性能工具:

top
htoptop的增强版:

htop
看完界面后,是不是都想转到htop了?htop还有很多强大的功能,比如选中一个进程,摁下l,就可以看到该进程打开的文件,相当于调用了lsof

lsof
按下s,就调用了strace来追踪进程的系统调用。

strace

关于这些使用技巧,可以参考这篇文章

另外,如果系统CPU很多,会导致界面上只会显示CPU,而不会显示其它信息:

htop

关于这个问题的解决方法,可以参考这封邮件讨论

 

Page 1 of 3

Powered by WordPress & Theme by Anders Norén