TPC-C简介

本文摘自BENCHMARKING TRANSACTION DATABASES

TPC-C benchmarkTransaction Processing Council制定测试数据库benchmark标准,它是基于批发供应商(也称之为company)的模型:

每个warehouse拥有100000个商品;
每个warehouse供应10个地区;
每个地区服务3000个客户。

TPC-C benchmark会增加warehouse,而保持其它常量不变。TPC-C benchmark的度量标准是tpm-C,即每分钟处理的transactionHammerDB就是一个提供TPC-C benchmark测试的开源工具。

 

Sysdig笔记(2)——sysdig的输出日志

在命令行执行sysdig命令,得到下列输出日志:

# sysdig | more
8 11:04:39.920906090 2 <NA> (0) > switch next=4606(qemu-kvm) pgft_maj=0 pgft_min=0 vm_size=0 vm_rss=0 vm_swap=0
9 11:04:39.920923972 2 qemu-kvm (4606) < ioctl res=0
10 11:04:39.920927878 2 qemu-kvm (4606) > ioctl fd=17(<X>) request=AE80 argument=0
11 11:04:39.920933865 2 qemu-kvm (4606) < ioctl res=0
12 11:04:39.920934920 2 qemu-kvm (4606) > ioctl fd=17(<X>) request=AE80 argument=0
21 11:04:39.920950032 2 qemu-kvm (4606) < ioctl res=0
22 11:04:39.920951238 2 qemu-kvm (4606) > ioctl fd=17(<X>) request=AE80 argument=0
24 11:04:39.920958802 2 qemu-kvm (4606) > switch next=0 pgft_maj=0 pgft_min=930 vm_size=1534620 vm_rss=1083932 vm_swap=0
500 11:04:39.923348311 1 <NA> (0) > switch next=17 pgft_maj=0 pgft_min=0 vm_size=0 vm_rss=0 vm_swap=0
501 11:04:39.923351955 1 <NA> (17) > switch next=0 pgft_maj=0 pgft_min=0 vm_size=0 vm_rss=0 vm_swap=0
504 11:04:39.923380189 7 <NA> (0) > switch next=22 pgft_maj=0 pgft_min=0 vm_size=0 vm_rss=0 vm_swap=0
507 11:04:39.923394983 7 <NA> (22) > switch next=0 pgft_maj=0 pgft_min=0 vm_size=0 vm_rss=0 vm_swap=0

第一列是事件序号,它是增长的,不连续的原因是因为没有包含sysdig自身产生的事件(可以使用sysdig -D得到sysdig自身产生的事件);
第二列是发生事件的时间戳;
第三列是CPU ID
第四列是命令;
第五列是线程ID
第六列是事件方向,比如进入ioctl函数为>,离开为<
第七列是事件名称(比如ioctl);
第八列是事件参数。

参考资料:
Interpreting Sysdig Output
How to understand evt.num?

 

Oracle笔记(1)——Database和Instance的区别

DatabaseInstance的区别如下:

What is a Database?

We already know that a database is a collection of data. And this data is stored in form of tables at logical level, and in the datafiles at the physical level. There are some other files as well like Redo log files, Control files, Initialization files which stores important information about the database.

What is an Instance?

To view or update data stored in tables/datafiles, Oracle must start a set of background processes, and must allocate some memory to be used during database operation. The background processes and memory allocated by Oracle together make up an Instance.

简言之,Database是存放实际数据的所有文件。为了操作这些文件,就需要有Instance:访问文件的进程和内存。

Oracle 12c For Dummies中关于DatabaseInstance二者之间关系的总结:

✓ An instance can exist without a database. Yes, it’s true. You can start an Oracle instance and not have it access any database files. Why would you do this?
• This is how you create a database. There’s no chicken-or-egg debate here. You first must start an Oracle instance; you create the database from within the instance.
• An Oracle feature called Automatic Storage Management uses an instance but isn’t associated with a database.
✓ A database can exist without an instance but would be useless. It’s just a bunch of magnetic blips on the hard drive.
✓ An instance can access only one database. When you start your instance, the next step is to mount that instance to a database. An instance can mount only one database at a time.
✓ You can set up multiple instances to access the same set of files or one database. Clustering is the basis for the Oracle Real Application Clusters feature. Many instances on several servers accessing one central data- base allows for scalability and high availability.

参考资料:

Oracle 12c For Dummies

database vs instances

Difference between Oracle Instance & Database.

 

Bash quoting简介

Bash quoting可以关闭Bash中具有特殊含义的meta字符的功能:
a)单引号:所有meta字符的功能均被关闭;
b)双引号:大部分meta字符的功能被关闭,除了$等少数字符;
c)反斜线(\):仅跟着\后面的meta字符被关闭。
这样就可以理解为什么解压多个zip文件时,要使用“unzip '*.zip'”而不是“unzip *.zip”。因为第二种会首先把*.zip替换成所有的文件名,而第一种方法不会这样做。

参考资料:
Shell十三问
How do I unzip multiple / many files under Linux?

 

shmmax和shmall

Linux kernel中针对shared memory有两个重要的配置项:shmmaxshmall

shmmax定义了一次分配shared memory的最大长度,单位是byte

# cat /proc/sys/kernel/shmmax
18446744073692774399

shmall定义了一共能分配shared memory的最大长度,单位是page

最大“shared memory” = shmall(cat /proc/sys/kernel/shmall) * pagesize(getconf PAGE_SIZE)

shmmax为例,介绍一下修改值的方法:

(1)现在系统shmmax的值:

# sysctl -a | grep shmmax
kernel.shmmax = 18446744073692774399

(2)修改shmmax的值:

# echo "536870912" > /proc/sys/kernel/shmmax
# sysctl -a | grep shmmax
kernel.shmmax = 536870912

可以看到值发生了变化。但是重启系统以后,shmmax又变回之前的值。如果要让值永久生效,可以使用下列方法:

# echo "kernel.shmmax = 536870912" >>  /etc/sysctl.conf
# sysctl -a | grep shmmax
kernel.shmmax = 18446744073692774399
# sysctl -p
kernel.shmmax = 536870912
# sysctl -a | grep shmmax
kernel.shmmax = 536870912

另外,关于如何设置shmallshmmax的值,也可以参考这个脚本

参考资料:
The Mysterious World of Shmmax and Shmall
Configuring SHMMAX and SHMALL for Oracle in Linux
What is shmmax, shmall, shmmni? Shared Memory Max

 

Haskell笔记 (12)—— 定义新的数据类型(data type)

使用data关键字来定义一种新的数据类型(data type):

data StudentInfo = Student Int String
                    deriving (Show)

StudentInfotype constructor,也是这种新type的名字,所以首字母必须大写。

Studentvalue constructor(有时也称之为data constructor)的名字,它的首字母也必须大写(可以把它看做是首字母大写的函数),作用是用来创建StudentInfo这种type的值。在Student后面的IntStringStudentInfo这种typecomponent(有时也称作fieldparameter,其作用类似于其它编程语言中结构体成员。

type constructor只用在type declarationtype signature中,而value constructor只用在实际的代码中。因此二者的使用是相互独立的,可以让type constructorvalue constructor拥有相同的名字,实际编码中基本也是这样做的:

data Student = Student Int String
                        deriving (Show)

也可以使用type关键字为已有的类型定义一个同义词(type synonym):

type SI = StudentInfo

type synonym也可以为一个冗长的类型取一个短名字,举例如下:

type SI = (Int, String)

Haskell笔记 (11)—— 函数的“type signature”

看一下take函数的type signature

ghci> :type take
take :: Int -> [a] -> [a]

这表明它有两个参数,返回值是一个list。“->”是右相关(right-associative),因此实际上也可以把take函数的type signature写成这样:

ghci> :type take
take :: Int -> ([a] -> [a])

因此也可以这样理解take函数:它有一个Int参数,返回值是另一个函数。这个函数的参数和返回类型是同一个类型的list