2015年1月22日 星期四

之前我的朋友因為支付寶退款的問題,需要打電話到中國,而Hangout之前有推出撥打電話的服務,就試著撥過去看看,沒想到通話似乎完全沒有延遲,費用還非常低廉。

以台灣為例,手機撥市話以每分鐘計算,Hangout是0.6元,中華4G是6元,雖然中華是以秒計費,但是只要講超過6秒,就比Hangout貴了。 XD


Google Hangout calling rates
https://www.google.com/voice/b/0/rates?hl=en&p=hangout

中華4G費率
http://www.emome.net/data_plan/4g_rate

2015年1月5日 星期一

Roundcube使用password plugin (chpasswd driver)的方式

基本上參考這一篇
http://www.roundcubeforum.net/index.php?topic=21861.0
之前實作的時候一直碰到密碼更改失敗的情況,看log也看不出所以然,只看到Unable to execute sudo。原來sudoers裡頭預設有"Defaults    requiretty"這個設定,php在執行chpasswd是沒有console的,所以無法執行,照這篇文章修改就行。
1) enable password function

vi /var/www/html/roundcube/config/config.inc.php

- alter the following line as follows:

$config['plugins'] = array('password');

cd /var/www/html/roundcube/plugins/password
cp config.inc.php.dist config.inc.php

2) enable the password plugin

cd /var/www/html/roundcube/plugins/password
cp config.inc.php.dist config.inc.php

vi config.inc.php

- alter the following as follows:

$config['password_driver'] = 'chpasswd';

3) allow apache to run the script

visudo

- add to bottom

Defaults:apache !requiretty
apache ALL=(root) NOPASSWD: /usr/sbin/chpass-wrapper.py

4) add blacklisted users and minimum UID below

vi /var/www/html/roundcube/plugins/password/helpers/chpass-wrapper.py

BLACKLIST = (
    # add blacklisted users here comma separated
    'root'
)

if user.pw_uid < 494:
    sys.exit('Changing the password for user id < 494 is forbidden')

5) copy the helper to executable directory & set make it executable
   
cp /var/www/html/roundcube/plugins/password/helpers/chpass-wrapper.py /usr/sbin
chmod 755 /usr/sbin/chpass-wrapper.py

6) alter the driver to run the helper which in turn runs the driver (wraps it)

vi /var/www/html/roundcube/plugins/password/config.inc.php

old:
$config['password_chpasswd_cmd'] = 'sudo /usr/sbin/chpasswd 2> /dev/null';
new:
$config['password_chpasswd_cmd'] = 'sudo /usr/sbin/chpass-wrapper.py 2> /dev/null';

2014年12月18日 星期四

CentOS 7, systemd, redis, max open files

在CentOS 7安裝好Redis,預設redis會開啟10000的檔案,所以啟動之後log總會顯示以下錯誤:
Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
即使修改/etc/security/limits.conf也沒有用,這個檔案一開頭就說:
This file sets the resource limits for the users logged in via PAM.
It does not affect resource limits of the system services.
因為CentOS 7用systemd換掉ntsysv,網路上有提示解法,就是修改redis的systemd配置檔案/lib/systemd/system/redis.service正確來說是/etc/systemd/system/redis.service.d/limit.conf,把LimitNOFILE=10240後面的數字改成所需的。

修改之後,要先重新載入systemd,否則會出現警告。如下
$ service redis restart
Redirecting to /bin/systemctl restart  redis.service
Warning: Unit file of redis.service changed on disk, 'systemctl daemon-reload' recommended.

2014年5月19日 星期一

qxl與vmware導致grub無法啟動(video adapter)

Proxmox VE 3.2 上把 OSSIM 裝上去,安裝過程一切正常,但是重開機後 grub 啟動時出現 unaligned pointer 錯誤,一查發現似乎是 grub 的 bug,而且這 bug 兩年前就已經存在。

解決之道就是把 video adapter 改回 default,不能用 qxl (SPICE) 真的有點不太方便。

2014年1月17日 星期五

為什麼我們需要第五世代的檔案系統:ZFS與btrfs

Ars Technica上面有一篇名為「Bitrot and atomic COWs: Inside “next-gen” filesystems」的文章,詳細說明了為什麼我們需要第五世代的檔案系統。

磁碟與磁帶在長期使用或不使用的情況下,會發生所謂「位元翻轉」的情況,以Jpeg檔案來說,就會出現一張圖片有一半的區域顏色有問題,MP3的話就是爆音,MP4影片的話就是出現綠色的區塊。然而有問題的磁碟、控制器、連接線,會發生位元翻轉的範圍更大。

你可能認為磁碟陣列(RAID)可以修復這些損壞的資料,但那只有在磁碟故障時才會進行修復。如果磁碟開始爆發大規模的位元翻轉,控制卡極有可能不會察覺,因為大多數的磁碟陣列控制卡不會在每一次的讀取時進行同位元檢查,即使做了檢查,也沒辦法知道哪個磁碟出現損壞的資料。能夠避免這種情況的,只有第五世代的檔案系統。

根據文章上的定義,第五世代的檔案系統必須要有以下的特徵:
  • Atomic COW快照(每個快照其實是個指標,每次修改檔案時,只會將有修改的部份指向新的區塊,如此能保有完整的修改歷程以及最小的空間需求)
  • 針對每個區塊進行校驗和檢查(RAID能確保資料的可用性卻不保證正確性,但針對每個區塊進行校驗和檢查能解決此問題)
  • 自我修復的冗餘陣列(在btrfs-raid1的設置中,即使發生了位元翻轉,因為有校驗和檢查,檔案系統便能自動修復損壞的檔案)
  • 卷冊管理(不需要傳統的分割區設置,只需要設置邏輯卷,就可以隨意分隔各種目錄,並且能動態調整大小,不用承擔失去檔案的風險)
  • 針對遙遠未來所設計的延展性(btrfs單一檔案系統的大小是16EB,你需要一台可安裝4,194,304顆4TB硬碟的機器才會達到這個上限)
  • 非同步增量式複製(從電腦A複製資料到電腦B,第一次傳檔只需要傳輸snapshot,之後每一次只需要傳輸有變動的區塊,快速又簡單)
以下只有btrfs有
  • 檔案層級的快速複製(多虧了COW的特性,要額外複製一份一模一樣的檔案,不需要完整複製一份,只要加上指標)
  • 在線均衡(你可以隨時調整Raid層級,不需要關機,也不會影響你的作業)
  • NODATACOW
  • 檔案層級與目錄層級的壓縮(ZFS只能作到檔案系統層級)
在文章的後面還實際展示這些功能,如果你想要試試,最簡單的方法就是安裝Ubuntu 12.04以上的版本,將核心更新到3.12,並安裝btrfs-tools 3.12版本。
http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.12.8-trusty/linux-headers-3.12.8-031208_3.12.8-031208.201401151952_all.deb
http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.12.8-trusty/linux-image-3.12.8-031208-generic_3.12.8-031208.201401151952_amd64.deb
http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.12.8-trusty/linux-headers-3.12.8-031208-generic_3.12.8-031208.201401151952_amd64.deb
https://launchpad.net/ubuntu/+archive/primary/+files/btrfs-tools_3.12-1_amd64.deb