使用gitlab搭建代码仓库

我来之前,公司一直用windows server搭建的svn托管代码,每次都要手动远程登陆到服务器然后后台授权。我看网上很多类github的平台,于是选了gitlab实验推荐大家迁移到git上来。

1. 搭建脚本很简单,下载安装包,启动即可。

1
2
3
4
5
6
7
curl -O https://downloads-packages.s3.amazonaws.com/centos-6.6/gitlab-7.6.1_omnibus.5.3.0.ci.1-1.el6.x86_64.rpm

yum install openssh-server postfix cronie

service postfix start && chkconfig postfix on

rpm -i gitlab-7.6.1_omnibus.5.3.0.ci.1-1.el6.x86_64.rpm

然后按说明配置一下gitlab.rb,启动服务即可。注意8080端口和ssh端口转发。

2. 用docker来更新最新版本的gitlab

Updated 2016-03-24

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
## 修改防火墙
iptables -A INPUT -m state --state NEW -p tcp --dport 10022 -j ACCEPT
iptables -A INPUT -m state --state NEW -p tcp --dport 8080 -j ACCEPT
service iptables save
service iptables status
service iptables restart
iptables -L

service docker restart
docker run --detach \
    --hostname gitlab.example.com \
    --env GITLAB_OMNIBUS_CONFIG="external_url 'http://119.*.*.*/'; gitlab_rails['lfs_enabled'] = true;" \
    -p 443:443 -p 8080:80 -p 10022:22 \
    --name gitlab \
    --restart always \
    --volume /srv/gitlab/config:/etc/gitlab \
    --volume /srv/gitlab/logs:/var/log/gitlab \
    --volume /srv/gitlab/data:/var/opt/gitlab \
    gitlab/gitlab-ce:latest

rChart and morris.js

1. Using rChart and morris.js for time series visualization

Here are the codes!

library('rCharts', 'ramnathv')
df <- read.csv("type.1h.csv",header=FALSE,stringsAsFactors=FALSE)
colnames(df) <- c("date","1", "2","3","4","5","6","7","8","9","10")
transform(df, date = as.character(date))
m1 <- mPlot(x = "date", y = c("1", "2","3","4","5","6","7","8","9","10"), type = "Line", data = df)
m1$set(pointSize = 0, lineWidth = 1)
m1$print("chart2")
m1
#base64enc
# install.packages("base64enc")
library("base64enc")
m1$save('graph1.html', 'inline', cdn=TRUE)
#m1$save('graph1.html', 'inline', standalone=TRUE)

2. Graph

Here, we can see this is a test graph!

Here is a test image!

Here is a test page!
graph1.html

Python Pocket Reference

The Zen of Python

1
2
3
4
5
6
7
8
9
10
11
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.

Packages

1
2
3
4
5
6
package/
    __init__.py
    module1.py
    subpackage/
        __init__.py
        module2.py
1
2
3
import package.module1
from packages.subpackage import module2
from packages.subpackage.module2 import name

References

https://www.python.org/dev/peps/pep-0008/
“Python Objects”, Fredrik Lundh, http://www.effbot.org/zone/python-objects.htm
“How to think like a Pythonista”, Mark Hammond, http://python.net/crew/mwh/hacks/objectthink.html
“Python main() functions”, Guido van Rossum, http://www.artima.com/weblogs/viewpost.jsp?thread=4829
“Python Idioms and Efficiency”, http://jaynes.colorado.edu/PythonIdioms.html
“Python track: python idioms”, http://www.cs.caltech.edu/courses/cs11/material/python/misc/python_idioms.html
“Be Pythonic”, Shalabh Chaturvedi, http://shalabh.infogami.com/Be_Pythonic2
“Python Is Not Java”, Phillip J. Eby, http://dirtsimple.org/2004/12/python-is-not-java.html
“What is Pythonic?”, Martijn Faassen, http://faassen.n--tree.net/blog/view/weblog/2005/08/06/0
“Sorting Mini-HOWTO”, Andrew Dalke, http://wiki.python.org/moin/HowTo/Sorting
“Python Idioms”, http://www.gungfu.de/facts/wiki/Main/PythonIdioms
“Python FAQs”, http://www.python.org/doc/faq/

刷新时间检测

小伙伴后台跑的java程序总是莫名其妙卡死,于是帮他写了个脚本定时检查日志文件有没有更新,没有更新的话重启程序。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash 
today=`date +%Y-%m-%d`
logfi='analysis'$today'.log'
otime=`stat -c %y /home/AnalysisLog/$logfi|awk '{print $2}'`

while ; do
    ctime=`stat -c %y /home/AnalysisLog/$logfi|awk '{print $2}'`
    if [[ "$otime" == "$ctime"  ]]; then
        `ps aux |grep $cmp |grep  -v "grep" |awk '{print "kill -9\t"$2}' |sh`
        `nohup /bin/sh /root/run/analysis/newAnalysis.bat &`
        sleep(30) # 等待重启 30s
        today=`date +%Y-%m-%d`
        logfi='analysis'$today'.log'
        otime=`stat -c %y /home/AnalysisLog/$logfi|awk '{print $2}'`
        sleep(3600) # 一个小时以后再检查 
    else
        echo "It is keeping updating!"
    fi  
    # 时间更新
    now=`date +%Y-%m-%d`
    today=$now
    logfi='analysis'$today'.log'
    otime=`stat -c %y /home/AnalysisLog/$logfi|awk '{print $2}'`
done

服务器重装centOS设定静态ip

电信机房5台托管服务器被攻击,为安全起见,老板令我需要重装系统。可采用光盘刻录或u盘安装方法(过程从略)。

1. 重装系统

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
reboot(crtl+allt+delete) 
-> 
F2(system manage) 
-> 
F11(BIOS Menu) 
-> 
BIOS Boot Setting 
->
Boot Sequence 
-> 
# 光盘或U盘
COD(DVD or U Driver) 
-> 
OK 
-> 
Install from video / U Driver
-> 
No Test 
-> 
Basic 
-> 
Fresh 
-> 
Use All 
-> 
Basic Server 
-> 
reboot

2. 设置固定IP上网

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#### 内网或外网ip
IPADDR=192.168.1.201

#### 2.1 网关配置
cp /etc/sysconfig/network /etc/sysconfig/network.bak
echo "
NETWORKING=yes
NETWORKING_IPV6=yes
GATEWAY=192.168.1.1
" >> /etc/sysconfig/network

#### 2.2 网卡配置 
cp /etc/sysconfig/network-scripts/ifcfg-em1 /etc/sysconfig/network-scripts/ifcfg-em1.bak
sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=none/' /etc/sysconfig/network-scripts/ifcfg-em1
sed -i 's/ONBOOT=no/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-em1

echo "
BROADCAST=192.168.1.255
IPADDR=$IPADDR
NETWORK=192.168.1.0
" >>/etc/sysconfig/network-scripts/ifcfg-em1

#### 2.3 DNS解析
echo "nameserver 202.103.24.68" >/etc/resolv.conf

#### 2.4 测试
chkconfig | grep network
service network restart
ping www.baidu.com

3. 参考

http://blog.51yip.com/linux/1120.html
https://github.com/iofdata/DM/issues/8

Sysbench for MySQL Testing

1. For whole testing scripts

    host=localhost
    port=3306
    socket=/home/data/mysql/mysql.sock
    user=root
    password=123456

    resultsdir=./results-thread

    threads="8 16 32 64 128"

    sizes="1000000 5000000 10000000 15000000 20000000 25000000 30000000"


    printf "sizes,threads,transactions,trns p/s,deadlocks, dls p/s,read/write requests,r/w reqs p/s,min,avg,max,99 percentile \n" >> stat.txt

    mkdir -p $resultsdir

    for thread in $threads;do
        mkdir $resultsdir/thread-$thread
        for size in $sizes; do
            sysbench --test=oltp --mysql-table-engine=innodb \
            --oltp-table-size=$size  --mysql-socket=$socket \
            --mysql-user=$user --mysql-host=$host \
            --mysql-password=$password --mysql-db=students \
            --oltp-table-name=test$size prepare;
            sysbench --test=oltp --mysql-table-engine=innodb \
            --oltp-table-size=$size --mysql-socket=$socket \
            --mysql-user=$user --mysql-host=$host \
            --mysql-password=$password --mysql-db=students \
            --oltp-table-name=test$size  --max-requests=1000 \
            --num-threads=$thread run | \ 
            tee -a $resultsdir/thread-$thread/sysbench.$thread.$size.report;
            sysbench --test=oltp --mysql-host=$host  --mysql-user=$user \
            --mysql-password=$password --mysql-socket=$socket \
            --mysql-db=students --oltp-table-name=test$size  cleanup;

            cat $resultsdir/thread-$thread/sysbench.$thread.$size.report | \
            egrep "cat|threads:|transactions:|deadlocks|
            read/write|min:|avg:|max:|percentile:" | \
            sed  -e '1 s/Number of threads: //' | \
            tr -d "\n" | \
            sed -e 's/Number of threads: /\n/g' \
            -e 's/[A-Za-z\/]\{1,\}://g' \
            -e 's/read\/write//g' \
            -e 's/approx\.  95//g' \
            -e 's/per sec.)//g' \
            -e 's/ms//g' \
            -e 's/(//g'  \
            -e 's/  */,/g' | awk -v d=$size '{$0=d","$0}1' >> stat.txt
        done
    done

2. Results

SIZES,THREADS,TRANSACTIONS,TRNS P/S,DEADLOCKS,DLS P/S,READ/WRITE REQUESTS,R/W REQS P/S,MIN,AVG,MAX,99 PERCENTILE
1000000,8,1000,236.13,0,0.00,19000,4486.45,7.16,33.66,118.17,59.32
5000000,8,1000,265.81,0,0.00,19000,5050.47,6.35,29.99,99.14,46.96
10000000,8,1000,379.46,127,48.19,21413,8125.43,3.54,21.01,306.08,34.70
15000000,8,1000,202.33,0,0.00,19000,3844.31,8.76,39.36,113.15,62.77
20000000,8,1000,185.34,0,0.00,19000,3521.38,10.48,43.05,111.56,66.92
25000000,8,1000,171.11,0,0.00,19000,3251.01,7.46,46.69,506.47,74.60
30000000,8,1000,163.24,0,0.00,19000,3101.55,14.49,48.91,504.90,77.21
1000000,16,1000,288.82,0,0.00,19000,5487.51,7.82,54.95,168.84,89.33
5000000,16,1000,270.04,0,0.00,19000,5130.82,19.13,59.02,323.48,92.27
10000000,16,1000,231.99,0,0.00,19000,4407.90,5.73,68.45,329.40,112.02
15000000,16,1000,230.78,0,0.00,19000,4384.76,8.29,69.03,233.97,124.21
20000000,16,1000,170.32,0,0.00,19000,3236.17,9.48,93.60,799.09,158.71
25000000,16,1000,164.44,0,0.00,19000,3124.34,5.68,96.44,633.64,165.06
30000000,16,1000,174.87,0,0.00,19000,3322.48,9.50,90.89,520.92,151.65
1000000,32,1000,316.29,0,0.00,19000,6009.43,7.72,99.23,346.24,172.95
5000000,32,1000,248.03,0,0.00,19000,4712.60,23.21,125.06,383.60,208.35
10000000,32,1000,229.40,0,0.00,19000,4358.52,5.39,138.82,598.64,350.74
15000000,32,1000,211.46,0,0.00,19000,4017.80,13.27,150.13,501.56,284.44
20000000,32,1000,198.36,0,0.00,19000,3768.77,8.54,159.58,822.41,252.87
25000000,32,1000,181.85,0,0.00,19000,3455.19,21.85,174.35,891.91,271.78
30000000,32,1000,156.00,0,0.00,19000,2964.03,9.45,204.21,811.06,339.07
1000000,64,1000,311.37,0,0.00,19000,5916.07,19.86,198.48,562.27,369.82
5000000,64,1000,287.12,0,0.00,19000,5455.27,29.12,216.80,843.55,338.67
10000000,64,1000,222.90,0,0.00,19000,4235.16,13.82,285.81,975.70,773.48
15000000,64,1000,193.57,0,0.00,19000,3677.74,12.19,327.30,1143.78,846.66
20000000,64,1000,170.73,0,0.00,19000,3243.88,55.67,370.57,1217.91,1092.95
25000000,64,1000,157.72,0,0.00,19000,2996.74,11.59,401.83,1680.79,1306.81
30000000,64,1000,158.19,0,0.00,19000,3005.66,19.20,401.41,1304.60,1107.11
1000000,128,1000,302.16,0,0.00,19000,5741.04,52.05,408.05,1041.78,772.32
5000000,128,1000,251.01,0,0.00,19000,4769.20,26.99,489.92,1724.37,781.39
10000000,128,1000,207.77,0,0.00,19000,3947.55,102.64,604.39,1577.85,1285.85
15000000,128,1000,149.60,0,0.00,19000,2842.35,146.68,841.09,3348.05,2764.42
20000000,128,1000,145.41,0,0.00,19000,2762.83,132.31,865.04,3247.91,2620.98
25000000,128,1000,139.95,0,0.00,19000,2658.97,252.97,896.25,2942.05,2773.54
30000000,128,1000,115.80,0,0.00,19000,2200.18,221.51,1089.31,4408.08,4141.01 

3. Visulization

library("ggplot2")
df <- read.csv("C:\\Users\\tanhao\\Documents\\GitHub\\DM\\mysql\\work\\stat.csv",head=TRUE)
ggplot(df, aes(x = factor(sizes), y = trns.p.s, fill=factor(threads))) + geom_bar(stat = "identity", position="dodge")

image

以上数据为一台1核1G主机的性能测试结果.

欢迎参见Details

sysbench testing

sysbench 测试

1 cpu 性能测试

1
sysbench --test=cpu --cpu-max-prime=20000 run

cpu测试主要是进行素数的加法运算,在上面的例子中,
指定了最大的素数为 20000,自己可以根据机器cpu的性能来适当调整数值。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
sysbench 0.4.10:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1

Doing CPU performance benchmark

Threads started!

Done.

Maximum prime number checked in CPU test: 20000


Test execution summary:
    total time:                          30.5083s
    total number of events:              10000
    total time taken by event execution: 30.5043
    per-request statistics:
         min:                                  2.83ms
         avg:                                  3.05ms
         max:                                  6.46ms
         approx.  95 percentile:               3.48ms

Threads fairness:
    events (avg/stddev):           10000.0000/0.00
    execution time (avg/stddev):   30.5043/0.00

2 线程测试

1
sysbench --test=threads --num-threads=64 --thread-yields=100 --thread-locks=2 run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
sysbench 0.4.10:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 64

Doing thread subsystem performance test
Thread yields per test: 100 Locks used: 2
Threads started!
Done.


Test execution summary:
    total time:                          0.6215s
    total number of events:              10000
    total time taken by event execution: 39.3849
    per-request statistics:
         min:                                  0.04ms
         avg:                                  3.94ms
         max:                                 85.26ms
         approx.  95 percentile:              30.41ms

Threads fairness:
    events (avg/stddev):           156.2500/10.52
    execution time (avg/stddev):   0.6154/0.00

3 磁盘IO性能测试,随机读写和删除

1
2
3
sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw prepare
sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw run
sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw cleanup

上述参数指定了最大创建16个线程,创建的文件总大小为3G,文件读写模式为随机读。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
sysbench 0.4.10:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 64

Doing thread subsystem performance test
Thread yields per test: 100 Locks used: 2
Threads started!
Done.


Test execution summary:
    total time:                          0.6215s
    total number of events:              10000
    total time taken by event execution: 39.3849
    per-request statistics:
         min:                                  0.04ms
         avg:                                  3.94ms
         max:                                 85.26ms
         approx.  95 percentile:              30.41ms

Threads fairness:
    events (avg/stddev):           156.2500/10.52
    execution time (avg/stddev):   0.6154/0.00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
sysbench 0.4.10:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 16

Extra file open flags: 0
128 files, 24Mb each
3Gb total file size
Block size 16Kb
Number of random requests for random IO: 10000
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Threads started!
FATAL: Failed to read file! file: 3 pos: 0 errno = 0 (Q?)
FATAL: Failed to read file! file: 3 pos: 6340608 errno = 0 ()
FATAL: Failed to read file! file: 13 pos: 16531456 errno = 0 ()
FATAL: Failed to read file! file: 48 pos: 5537792 errno = 0 ()
FATAL: Failed to read file! file: 96 pos: 8503296 errno = 0 ()
FATAL: Failed to read file! file: 26 pos: 9568256 errno = 0 ()
FATAL: Failed to read file! file: 26 pos: 15794176 errno = 0 ()
FATAL: Failed to read file! file: 127 pos: 18300928 errno = 0 ()
FATAL: Failed to read file! file: 9 pos: 21331968 errno = 0 ()
FATAL: Failed to read file! file: 119 pos: 8421376 errno = 0 ()
FATAL: Failed to read file! file: 62 pos: 17448960 errno = 0 ()
FATAL: Failed to read file! file: 87 pos: 20398080 errno = 0 ()
FATAL: Failed to read file! file: 113 pos: 13156352 errno = 0 ()
FATAL: Failed to read file! file: 20 pos: 10649600 errno = 0 ()
FATAL: Failed to read file! file: 17 pos: 9060352 errno = 0 ()
FATAL: Failed to read file! file: 16 pos: 311296 errno = 0 ()
Done.

Operations performed:  0 Read, 0 Write, 0 Other = 0 Total
Read 0b  Written 0b  Total transferred 0b  (0b/sec)
    0.00 Requests/sec executed

Test execution summary:
    total time:                          0.0029s
    total number of events:              0
    total time taken by event execution: 0.0000
    per-request statistics:
         min:                            18446744073709.55ms
         avg:                                  0.00ms
         max:                                  0.00ms

Threads fairness:
    events (avg/stddev):           0.0000/0.00
    execution time (avg/stddev):   0.0000/0.00
1
2
3
sysbench 0.4.10:  multi-threaded system evaluation benchmark

Removing test files...

4 内存测试

1
sysbench --test=memory --memory-block-size=8k --memory-total-size=4G run

上述参数指定了本次测试整个过程是在内存中传输 4G 的数据量,每个 block 大小为 8K。
1
# 无结果,待更新!

5 mysql 性能测试

5.1 prepare data
1
2
3
sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 \
--mysql-socket=/home/data/mysql/mysql.sock --mysql-user=root --mysql-host=localhost \
--mysql-password=123456 --mysql-db=students --oltp-table-name=test prepare
1
2
3
4
5
sysbench 0.4.10:  multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
Creating table 'test'...
Creating 1000000 records in table 'test'...
5.2 run test
1
2
3
4
sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 \
--mysql-socket=/home/data/mysql/mysql.sock --mysql-user=root --mysql-host=localhost \
--mysql-password=123456 --mysql-db=students --oltp-table-name=test \
--max-requests=1000 --num-threads=100 run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
sysbench 0.4.10:  multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
WARNING: Preparing of "BEGIN" is unsupported, using emulation
(last message repeated 99 times)
Running the test with following options:
Number of threads: 100

Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 1000
Threads started!
Done.

OLTP test statistics:
    queries performed:
        read:                            14000
        write:                           5000
        other:                           2000
        total:                           21000
    transactions:                        1000   (276.21 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 19000  (5247.91 per sec.)
    other operations:                    2000   (552.41 per sec.)

Test execution summary:
    total time:                          3.6205s
    total number of events:              1000
    total time taken by event execution: 356.3231
    per-request statistics:
         min:                                 55.01ms
         avg:                                356.32ms
         max:                               1223.34ms
         approx.  95 percentile:             764.73ms

Threads fairness:
    events (avg/stddev):           10.0000/0.76
    execution time (avg/stddev):   3.5632/0.03
5.3 clean data
1
2
sysbench --test=oltp --mysql-host=localhost  --mysql-user=root  --mysql-password=123456 \
--mysql-socket=/home/data/mysql/mysql.sock --mysql-db=students --oltp-table-name=test cleanup

以上测试内容参考 MySQL 中文网.

本文数据为一台1核1G主机的性能测试结果.

欢迎参见Details

sysbench libtool error and mysql testing

sysbench 安装

http://blog.163.com/digoal@126/blog/static/16387704020134142151769/

1 找不到mysqlincludelib文件目录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
wget -c http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-devel-5.6.19-1.el6.x86_64.rpm/from/http://mysql.spd.co.il/
rpm -ivh MySQL-devel-5.6.19-1.el6.x86_64.rpm

wget -c http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-shared-5.6.19-1.el6.x86_64.rpm/from/http://mysql.spd.co.il/
rpm -ivh MySQL-shared-5.6.19-1.el6.x86_64.rpm

rpm -qa|grep MySQL
rpm -ql MySQL-server-5.6.19-1.el6.x86_64

chkconfig --list|grep -i mysql

./configure --with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib64/mysql/
make
make check
make install

可惜,仍然不能很好的结果问题,继续艰难摸索中.

#### 2 最终解决方案

##### 5-0 版本但是不能测试 oltp

1
2
3
http://www.lefred.be/node/154
rpm -ivh sysbench-0.5-2.el6_.x86_64.rpm
rpm -ql sysbench
转回 4.10 版本 解决方案
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#git clone https://github.com/nettedfish/sysbench_from_percona.git
yum -y install libtool
yum -y install automake*
rm -rf libtool
ln -s /usr/bin/libtool ./

./autogen.sh
./configure
make & make install
ln -s  /usr/local/bin/sysbench /usr/bin/
sysbench --test=oltp help

sysbench 0.4.10:  multi-threaded system evaluation benchmark

oltp options:
  --oltp-test-mode=STRING         test type to use {simple,complex,nontrx,sp} [complex]
  --oltp-sp-name=STRING           name of store procedure to call in SP test mode []
  --oltp-read-only=[on|off]       generate only 'read' queries (do not modify database) [off]
  --oltp-skip-trx=[on|off]        skip BEGIN/COMMIT statements [off]
  --oltp-range-size=N             range size for range queries [100]
  --oltp-point-selects=N          number of point selects [10]
  --oltp-simple-ranges=N          number of simple ranges [1]
  --oltp-sum-ranges=N             number of sum ranges [1]
  --oltp-order-ranges=N           number of ordered ranges [1]
  --oltp-distinct-ranges=N        number of distinct ranges [1]
  --oltp-index-updates=N          number of index update [1]
  --oltp-non-index-updates=N      number of non-index updates [1]
  --oltp-nontrx-mode=STRING       mode for non-transactional test {select, update_key, update_nokey, insert, delete} [select]
  --oltp-auto-inc=[on|off]        whether AUTO_INCREMENT (or equivalent) should be used on id column [on]
  --oltp-connect-delay=N          time in microseconds to sleep after connection to database [10000]
  --oltp-user-delay-min=N         minimum time in microseconds to sleep after each request [0]
  --oltp-user-delay-max=N         maximum time in microseconds to sleep after each request [0]
  --oltp-table-name=STRING        name of test table [sbtest]
  --oltp-table-size=N             number of records in test table [10000]
  --oltp-dist-type=STRING         random numbers distribution {uniform,gaussian,special} [special]
  --oltp-dist-iter=N              number of iterations used for numbers generation [12]
  --oltp-dist-pct=N               percentage of values to be treated as 'special' (for special distribution) [1]
  --oltp-dist-res=N               percentage of 'special' values to use (for special distribution) [75]

General database options:

  --db-driver=STRING  specifies database driver to use ('help' to get list of available drivers)
  --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto]


Compiled-in database drivers:
  mysql - MySQL driver

mysql options:
  --mysql-host=[LIST,...]       MySQL server host [localhost]
  --mysql-port=N                MySQL server port [3306]
  --mysql-socket=STRING         MySQL socket
  --mysql-user=STRING           MySQL user [sbtest]
  --mysql-password=STRING       MySQL password []
  --mysql-db=STRING             MySQL database name [sbtest]
  --mysql-table-engine=STRING   storage engine to use for the test table {myisam,innodb,bdb,heap,ndbcluster,federated} [innodb]
  --mysql-engine-trx=STRING     whether storage engine used is transactional or not {yes,no,auto} [auto]
  --mysql-ssl=[on|off]          use SSL connections, if available in the client library [off]
  --myisam-max-rows=N           max-rows parameter for MyISAM tables [1000000]
  --mysql-create-options=STRING additional options passed to CREATE TABLE []

后续将继续关注数据测试结果.

3 关于libtool错误的其它参考

http://wenku.baidu.com/link?url=DGlHEoWxiLWq4829Qp_7ngYB9r3glfkk_JOHEVNDedUWDSWJxYRPiv55KWkhSPnkeKPXjn2O2N6n-Xgqi_j4c2j2GIRfqU66l2NlWZ0mHSK

4 sysbench-4.12dbt2官方测试源址

1
2
3
4
5
6
wget http://downloads.mysql.com/source/sysbench-0.4.12.5.tar.gz
gunzip sysbench-0.4.12.5.tar.gz
tar -xvf sysbench-0.4.12.5.tar
cd sysbench-0.4.12.5

wget http://downloads.mysql.com/source/dbt2-0.37.50.3.tar.gz

欢迎参见Details

A First Glance at MySQL

A 安装MySQL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
##wget http://192.168.2.2:8080/download/MySQL-client-5.6.19-1.el6.x86_64.rpm
##wget http://192.168.2.2:8080/download/MySQL-server-5.6.19-1.el6.x86_64.rpm
wget -c http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-*-5.6.19-1.el6.x86_64.rpm/from/http://mysql.spd.co.il/

rpm -ivg MySQL-server-5.6.19-1.el6.x86_64.rpm
## 报错
## file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.19-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64

yum remove mysql-libs-5.1.*
rpm -ivh MySQL-server-5.6.19-1.el6.x86_64.rpm
rpm -ivg MySQL-client-5.6.19-1.el6.x86_64.rpm
rpm -ivh MySQL-devle-5.6.19-1.el6.x86_64.rpm

## check and start MySQL
chkconfig | grep mysql
service mysql start

## 数据目录
lsof|grep mysql
ll -rt /var/lib/mysql/

## mysql 配置文件
ll -rt /usr/share/mysql/

## 相关程序命令
which mysql
/usr/bin/mysql

## 启动脚本
ll -rt /etc/rc.d/init.d/

Read More

Data Sicence ToolBox

1 Download file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
if(!file.exists("data")){
    dir.creat("data")
}
fileurl <- "http://"
download.file(fileurl, destfile="./data/data.csv", method="curl")
list.files("./data")
dateDownloaded <- date()

read.table("./data/data.csv")
read.xlsx("./data/data.xlsx", sheetIndex=1, header=TRUE)

library(XML)
fileurl <- "http://www.w3c.com/xml/simple.xml"
doc <- xmlTreeParse(fileurl, useInternal=TRUE)
rootNode <- xmlRoot(doc)
xmlName(rootNode)
xmlSApply(rootNode, xmlValue)
xpathSApply(rootNode,"//name",xmlvale)


library(jsonlite)
jsonData <- fromJSON("")
toJSON()

library(RMySQL)
biocLite("rhdf5")

Read More