在Ubuntu 13.10 / Linux Mint或其他Debian based的GNU/Linux上安裝ElasticSearch

翻了一些文章, 以前裝ElasticSearch比較麻煩一點, 要自己處理, 不過現在官方已經有打包deb了!

ElasticSearch官方下載頁面:http://www.elasticsearch.org/download/

目前的版本為0.90.9, 下載網址為:https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.9.deb

因為依賴於java環境, 所以先安裝jre(JAVA Runtime Environment):

可以只裝minimal的版本, 比較輕量一點, 不用裝那麼多東西, 安裝也比較快:
sudo apt-get install openjdk-7-jre-headless(不想裝輕量版就把-headless拿掉就好了!)

安裝好java環境後來下載elasticsearch:
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.9.deb

然後來安裝:
sudo dpkg -i elasticsearch-0.90.9.deb

沒問題的話service應該會自動跑起來,這邊來測試看看,有curl的話就用curl直接在terminal測(用telnet應該也可以!?):
curl http://localhost:9200

或是直接在瀏覽器開http://localhost:9200也可以

結果應該會長這樣:
{
"ok" : true,
"status" : 200,
"name" : "Drake, Frank",
"version" : {
"number" : "0.90.9",
"build_hash" : "a968646da4b6a2d9d8bca9e51e92597fe64e8d1a",
"build_timestamp" : "2013-12-23T10:35:28Z",
"build_snapshot" : false,
"lucene_version" : "4.6"
},
"tagline" : "You Know, for Search"
}

看到這就表示沒問題了!

用 bash-completion 增強 Bash shell 的自動補齊功能(apt-get / aptitude / portsnap … 等)

bash 預設的自動補齊功能只會補命令跟檔名而已,假如要 apt-get install openjdk-7-jre 的話只打了 openjdk-7- 按下 tab 是不會有效果的…

透過 bash-completion 這個套件的話就可以支援非常多常用工具的命令自動補齊,bash-completion 其實就是一堆 bash shell scripts 寫出來的自動補齊功能,基於 Ubuntu 的 GNU/Linux 分支可能都有內建了,如果沒有,手動安裝的方式也很簡單:

Debian/Ubuntu 系列用
sudo apt-get install bash-completion

如果是用 yum 來管套件的Linux distro (CentOS/Fedora/RHEL)
sudo yum install bash-completion

FreeBSD(新的套件管理系統請使用 pkg install 取代 pkg_add):
sudo pkg_add bash-completion

想知道 bash-completion 到底支援了多少命令,可以看一下他的 filelist (以 Debian sid 套件為例, 應該都大同小異):
http://packages.debian.org/sid/all/bash-completion/filelist

另外要注意的是,不是每個 distribution 裝起來的 bash-completion 都會幫你處理好自動取用 bash-completion 這件事,按照不同的系統可能要手動使用類似這樣的指令:
source /usr/local/share/bash-completion/bash_completion.sh

通常是會加在 bashrc 底下,system admin 的話加入系統預設的 bashrc 也是不錯的做法

Debian / Ubuntu / LinuxMint /Deepin … dpkg忽略相依性強制移除

dpkg –remove (-r) 移除套件的時候如果會造成相依性問題預設就不會做處理

看了一下dpkg --help, 應該是可以透過–force來幫忙(!?)

又看了一下dpkg --force-help…有這些說明

dpkg forcing options - control behaviour when problems found:
warn but continue: --force-,,...
stop with error: --refuse-,,... | --no-force-,...
Forcing things:
[!] all Set all force options
[*] downgrade Replace a package with a lower version
configure-any Configure any package which may help this one
hold Process incidental packages even when on hold
not-root Try to (de)install things even when not root
bad-path PATH is missing important programs, problems likely
bad-verify Install a package even if it fails authenticity check
bad-version Process even packages with wrong versions
overwrite Overwrite a file from one package with another
overwrite-diverted Overwrite a diverted file with an undiverted version
[!] overwrite-dir Overwrite one package's directory with another's file
[!] unsafe-io Do not perform safe I/O operations when unpacking
[!] confnew Always use the new config files, don't prompt
[!] confold Always use the old config files, don't prompt
[!] confdef Use the default option for new config files if one
is available, don't prompt. If no default can be found,
you will be prompted unless one of the confold or
confnew options is also given
[!] confmiss Always install missing config files
[!] confask Offer to replace config files with no new versions
[!] architecture Process even packages with wrong or no architecture
[!] breaks Install even if it would break another package
[!] conflicts Allow installation of conflicting packages
[!] depends Turn all dependency problems into warnings
[!] depends-version Turn dependency version problems into warnings
[!] remove-reinstreq Remove packages which require installation
[!] remove-essential Remove an essential package

WARNING - use of options marked [!] can seriously damage your installation.
Forcing options marked [*] are enabled by default.

原先加上--force-breaks無效, 加了--force-depens就對了!

用 portmaster 升級已經安裝的 freebsd 套件

久久作一次,每次都要翻一下 man 跟 –help … 作個筆記把常用參數記下來…

-G 不做make config
-d 每次跑完都會作清理(make clean?)
-B 不把舊的套件打包成package備份
-w deinstall之前把舊的共享函式庫備份起來
-P 有現成的package可以用就用package(沒有要調整編譯參數的話可以省編譯時間)
–no-confirm 不跟使用者確認會進行安裝以及升級的清單
-a 檢查所有套件並升級
-y 所有提示問題都答yes
-x 排除某個port
–delete-build-only 砍掉只有在編譯時相依到的port
–delete-packages 安裝後把package砍掉
-g 把新的port順便打包成package (適合大量部署)
-v 輸出詳細資訊

example:
portmaster -GdBPay --delete-packages --no-confirm -x apache24 -x php\*
# 升級apache24 和php開頭以外的所有套件,可以用package就用,用完就砍掉,每次編譯完都作清理,不用確認要升級/安裝哪些 ports,不把舊的port備份成package,所有問題自動回答yes