2013年11月10日 星期日

Docker on Windows

Docker
目前只支援在Ubuntu下跑,若要在Windows下,可用VirtualBox搭配Vagrant使用
官方Install Document

1.首先把VirtualBox和Vagrant安裝起來

2. git clone docker and vagrant up
git clone https://github.com/dotcloud/docker.git
cd docker
vagrant up
vagrant up之後會有一台ubuntu vm被開啟來,docker daemon就在上面執行

3. 用putty登入127.0.0.1:2222
(ubuntu vm的port 22被vagrant自動bind到host的port 2222)
default user/password 是 vagrant/vagrant


4. 登入後 基本使用教學
sudo su
docker run -t -i ubuntu /bin/bash
跑ubuntu這個image,產生一個container,執行/bin/bash並進入interactive shell

5. 之後就是在container的環境了,用apt-get可以安裝軟體,Alt+P & Alt+Q sequence可以跳回host(ubuntu vm)而不會結束container,跳host之後可用docker attach 回去。

6. docker ps查看還在跑的container資訊,包括ID和port(docker run時用-p參數),docker ps -a可看全部

7. docker commit 可存下container成image,例如新安裝的軟體,方便下次直接run成新的container

8. 編寫Dockerfile可build新的image

9. docker images查看現在有的images

10. 若要讓vagrant bind ubuntu vm的port給host,在vagrant up之前要先set FORWARD_DOCKER_PORTS=True
(好像沒辦法正常up起來)

Best Practice

2013年11月4日 星期一

MediaWiki 更改權限設定

http://www.mediawiki.org/wiki/Manual:Preventing_access

改LocalSettings.php裡的變數
$wgGroupPermissions['*']['edit'] = false;
防止沒登入的人編輯頁面

2013年10月24日 星期四

Python Google Chart

安裝pygooglechart時出現找不到module setuptools:

Note if you catch an error:"ImportError: No module named setuptools" please download http://peak.telecommunity.com/dist/ez_setup.py and install the setuptools.



參考資料:
http://pygooglechart.slowchop.com/
http://trac.edgewall.org/wiki/TracOnWindows/Python2.5

Subversion, TortoiseSVN 介紹

Subversion(svn)是個很有名的revision control system,在許多open source專案都有被使用到,在協同工作的環境中(個人使用也可以),幫助管理檔案的版本,也可回復到之前的版本,方便追蹤軟體或文件的開發過程。Subversion是個集中式的管理機制,大部分的動作都需要與repository連線來完成,所以若是repository不正常或其他原因無法access到就不能做svn的操作了(Git可以),算是svn的缺點。

TortoiseSVN是一隻Subversion的GUI Client程式,可以方便使用者操作svn而不需要透過command line的方式,但前提是使用者還是必須對svn的各個操作有所認識才行。TortoiseSVN也整合了Office的文件,可以做版本差異的比對,方便解決conflict。

一般svn的convention(慣例)是在project的repository下建立三個directory分別是/trunk, /branches, /tags。/trunk裡面放main line of development,後續可merge進其他的branch進來。/branches裡面放各個branch,一個branch取一個directory名子,通常是從/trunk branch(svn copy)進來這裡。/tags裡面放各版的release版本,和branches directory類似,只是通常就是定版了,不會再commit或merge新的東西進來。

一般操作流程
1. Check Out一個project
2. 編輯內容(新增一個功能或是修正bug)
3. Update
4. Commit

若是要先branch,完成後再merge進trunk
1. Branch: svn copy path/trunk path/branches/feature01
2. 在path/branches/feature01做修改
3. Update & Commit
4. Merge: 先cd到path/trunk在svn merge path/branches/feature01

Reference:

2013年10月18日 星期五

setup git daemon on centos

1. install git, git-daemon, xinetd
>yum install git git-daemon xientd

2. edit /etc/xinetd.d/git file
disabled = no

3. open port 9418 in firewall

4. the git repositories in /var/lib/git directory

5. create a repository in /var/lib/git
>mkdir test
>cd test
>git init --bare --shared

5. restart xinetd
>service xinetd restart

6. try to clone test repository from remote
>git clone git://[server_ip]/test
or with ssh ( can push ):
>git clone root@[server_ip]:/var/lib/git/test

Reference:
http://blog.longwin.com.tw/2011/03/build-git-env-share-over-ssh-2011/

2013年9月23日 星期一

jenkins monitoring external jobs

1. On Jenkins web GUI, add a new job and select "Monitor an external job", name it as "job01"

2. execute from other machine:
$ export JENKINS_HOME=http://jenkins_server:8080
$ java -jar /var/cache/jenkins/war/WEB-INF/lib/jenkins-core-1.530.jar "job01" find /

("find /" is the target command)

reference:
https://wiki.jenkins-ci.org/display/JENKINS/Monitoring+external+jobs

2013年9月6日 星期五

Install fio and required packages

1. Download fio from http://freecode.com/projects/fio
2. yum install zlib-devel libaio-devel libibverbs-devel librdmacm-devel
3. unzip fio file
# tar jxvf fio-2.1.2.tar.bz2

4. configuration
# cd fio-2.1.2
# ./configure

5. make && make install
# make && make install

6.some sample jobsfile in ./t/jobs
# cd ./t/jobs
# fio t0001-52c58027.fio