Generate zh_TW Locale on a Ubuntu Server

2015-02-12 Linux No comments

First, edit /etc/default/locale to be
LANG="zh_TW.UTF-8"
Then install language pack:
# apt-get install language-pack-zh-hant
Finally, generate locale:
# locale-gen zh_TW.UTF-8

/etc/cron.{hourly,daily,weekly,monthly} 裡頭的 scripts 不能有副檔名

2015-02-09 Linux No comments

突然發現放在 Ubuntu 14.04 版 /etc/cron.daily/ 裡面的 script 居然沒有按時執行。
run-parts --test /etc/cron.daily 檢查,這些 script 也沒有被列出來,
結果在 https://justcheckingonall.wordpress.com/2009/06/28/cron-does-not-run-scripts/ 發現原來是因為 run-parts 不接受檔案名稱包含 . (句點) 的檔案。
所以必須把 01-home-backup.sh 改名稱變成 01-home-backup 才行。
奇怪的是這些定時執行的 script 是我從 RHEL 4 的時代用到現在的,先前使用 Ubuntu 也沒有出過這個問題,怎麼會突然出這個 Bug。
追查之下才發現是 Debian 做了這項改變,而且他們似乎不認為這是一個 Bug。
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=54421

mongodb 備份與復原

2015-02-05 寫程式 No comments

詳見 http://docs.mongodb.org/manual/reference/program/mongodump/
以 mongodump 匯出者,以 mongorestore 匯入
以 mongoexport 匯出者,以 mongoimport 匯入

查區域網路網路上用掉的 IP

2015-01-16 Linux No comments

nmap -sP 192.168.3.0/24

查看究竟是那一支程式佔用了通訊埠

2014-12-30 寫程式 No comments

遇到啟動程式失敗的狀況,原因是該程式使用的 TCP 通訊埠已經被占用。
此時應以下列指令查出占用通訊埠的程式究竟是誰:

LINUX:
# netstat -tupln

WINDOWS:
先找出 PID:
netstat -bano
再找出 Process
tasklist /fi "pid eq 1544"

Import a vmdk into ESXi inventory

2014-12-23 Virtualization No comments

First transfer the vmdk file to the ESXi server with scp or vSphere client.
Then SSH to the ESXi server and cd /vmfs/volumes/datastore1 and enter the directory where the vmdk file is stored.
Last step, clone the vmdk file by
vmkfstools -i source.vmdk -d thin replica_name
where the -i option means “clone" and the -d option specify output format. The argument “thin" means “thin-provisioned".
Two files will be generated: replica_name-flat.vmdk and replica_name.vmdk.

Reference: http://www.shadowandy.net/2011/05/toying-with-vmware-esxi-importing-existing-vmdk.htm

Enable mongodb network access

2014-12-16 Linux, 寫程式 No comments

To access mongodb from another host other than localhost, edit /etc/mongodb.conf and modify the line bind_ip = 0.0.0.0

OS: Ubuntu 14.04 LTS
MongoDB: 2.6.3

CoreOS Installation

2014-11-24 Linux, Virtualization No comments

The installation of a CoreOS 444.5.0 Linux VM on VMware ESXi 5.5 is described as following.
Network Environment:
I have a LAN with DHCP service enabled. The network configuration of the LAN is 192.168.4.0/24.
I have a PC running Scientific Linux version 7, whose hostname is YUN and IP address is 192.168.4.52.
Before Installation:
Download CoreOS ISO image from http://stable.release.core-os.net/amd64-usr/current/. The filename of the ISO image is coreos_production_iso_image.iso.
Create a VM on a VMware ESXi 5.5 server. The guest operating system type of the VM is Other 2.6.x Linux (64-bit).
Create SSH RSA keys on YUN as follows:
$ ssh-keygen -t rsa
The private key will be written into ~/.ssh/id_rsa and the public key will be written into ~/.ssh/id_rsa.pub.
Copy the public key and create a configuration file named cloud-config as follows:

#cloud-config
hostname: coreos1
ssh_authorized_keys:
    - ssh-rsa AAAAB3NzaC1yc2E...skip... username@yun


Installation Steps:
1. Connect the VM’s CDROM to the ISO image coreos_production_iso_image.iso and force the VM boot from its CDROM.
2. After boot, switch to root by sudo su -
3. Copy the file cloud-config from YUN by scp username@192.168.4.52:cloud-config .
4. Begin installation by coreos-install -d /dev/sda -C stable -c cloud-config
After installation:
Login to coreos1 from YUN by ssh -A core@ip.to.coreos1

To upgrade all my Python packages installed by pip

2014-11-19 寫程式 No comments

# pip install -U `pip list -o | \
grep -v -i warning | grep -v -i "Could not find" | grep -v -i "use --allow-external" | \
cut -f1 -d' ' | tr "\n|\r" " "`

See http://stackoverflow.com/questions/2720014/upgrading-all-packages-with-pip

Scientific Linux 7 grub2-mkconfig

2014-10-21 Linux No comments

Scientific Linux 7 終於釋出了,趕緊拿來試裝在筆電上。筆電上原本有 Ubunto 14.04,和 Windows 8.1 做成 Dual Boot。
以 SL7 取代 Ubuntu 14.04,安裝過程還算順利。但是安裝完畢重新開機時,發現 Grub 的開機選單裡面沒有 Windows 8.1!
( 繼續閱讀… )