http://fabfile.org
http://docs.fabfile.org/en/1.4.2/tutorial.html
2012/06/07
2012/03/09
SOA 討論
Service Oriented Architecture
資料來源:
http://www.cc.ntu.edu.tw/chinese/epaper/20070620_1008.htm - 2007.06.20
× 請注意資料時間與本文發表時間。
筆記:
> SOA 不是種技術:它是種建構、組織的方法,用來建立應用程式的運行環境。
> 從資訊技術層面而言,一個執行學校或企業業務的應用程式稱為一個獨立的「邏輯單位」,而對學校或企業營運層面而言則可稱為一項「服務」,在企業的整體運算環境中就存在著多個「獨立邏輯/業務服務」。
> 跳脫、超越過往對應用程式的想法,改以「既有服務可否再運用?」或者是「能否沿用其他同仁開發過的服務再建構?」的觀點來面對程式開發。
> SOA 以類似傳訊溝通的作法,將數個所需的「業務服務」進行連結,以此來實現一個新的應用程式,而非「從頭開發」。新的應用程式只要透過「傳訊微調」(參數微調)即可實現,而非「重新撰寫」。
> 組合的元素通常包括:軟體元件、服務及流程三個部份。流程負責定義外部要求的處理步驟;服務包括特定步驟的所有程式元件,而軟體元件則負責執行工作的程式。
> SOA 如同物件導向、軟體元件等軟體技術一般,運用小的零組件組合成應用系統。
> SOA 的作法是以界面標準來組合系統,只要符合界面要求,零組件可以任意替換。
> 以流程角度出發 (process centric):在建構系統時,首先了解特定工作的流程要求,並將其切割成服務界面(包括輸入與輸出資料格式),如此其他的發展者就可以依據服務界面開發 (或選擇) 合適的元件來完成工作。
重點:
> SOA 的實作,就是將所有程式邏輯及服務內容全部包裹在服務內部,並實作一個標準的介面與外部作溝通。
> SOA 介面定義的方式、資料格式、與溝通管道必須是產業標準 (http、XML、SOAP 等)。也就是說只要能實作出這樣的介面,不論介面後面是什麼,都可使成為 SOA。
想法:
簡單說,SOA 是一個概念(Guide),政客一點的講法就是:發展“方針”、發展“大方向”。
SOA(服務導向架構)跟 OOP(物件導向編程)算同宗,把“物件”換成“服務”就很好理解了。
就像物件的類別需要提供各種方法(method,例如 _get;_set)來讓外部呼叫,
一個號稱 SOA 的服務(系統、軟體、網站、etc.)也需要一個 interface 可讓外部呼叫。
“實作一個標準的介面與外部作溝通” 就很重要了。
關於這個介面的火紅名詞:
SOAP、UDDI、WSDL(都是 Web Service 的 XML + HTTP)
http://wwww.w3schools.com/webservices/ws_intro.asp
http://www.w3.org/TR/ws-arch/
不過也有人指出這些東西的毛病:
http://coolshell.cn/articles/3585.html
http://coolshell.cn/articles/3498.html
http://coolshell.cn/articles/2504.html
現在比較流行的是:
REST(Representational State Transfer)
關於 Web Service 的做法可以參考水利署的 API:
http://wrisp.wra.gov.tw/Public/Support/ServiceUseGuide.aspx
而 RESTful API 的樣子可以參考這篇文章:
http://tedwise.com/2009/03/19/what-does-a-rest-interface-look-like
資料來源:
http://www.cc.ntu.edu.tw/chinese/epaper/20070620_1008.htm - 2007.06.20
× 請注意資料時間與本文發表時間。
筆記:
> SOA 不是種技術:它是種建構、組織的方法,用來建立應用程式的運行環境。
> 從資訊技術層面而言,一個執行學校或企業業務的應用程式稱為一個獨立的「邏輯單位」,而對學校或企業營運層面而言則可稱為一項「服務」,在企業的整體運算環境中就存在著多個「獨立邏輯/業務服務」。
> 跳脫、超越過往對應用程式的想法,改以「既有服務可否再運用?」或者是「能否沿用其他同仁開發過的服務再建構?」的觀點來面對程式開發。
> SOA 以類似傳訊溝通的作法,將數個所需的「業務服務」進行連結,以此來實現一個新的應用程式,而非「從頭開發」。新的應用程式只要透過「傳訊微調」(參數微調)即可實現,而非「重新撰寫」。
> 組合的元素通常包括:軟體元件、服務及流程三個部份。流程負責定義外部要求的處理步驟;服務包括特定步驟的所有程式元件,而軟體元件則負責執行工作的程式。
> SOA 如同物件導向、軟體元件等軟體技術一般,運用小的零組件組合成應用系統。
> SOA 的作法是以界面標準來組合系統,只要符合界面要求,零組件可以任意替換。
> 以流程角度出發 (process centric):在建構系統時,首先了解特定工作的流程要求,並將其切割成服務界面(包括輸入與輸出資料格式),如此其他的發展者就可以依據服務界面開發 (或選擇) 合適的元件來完成工作。
重點:
> SOA 的實作,就是將所有程式邏輯及服務內容全部包裹在服務內部,並實作一個標準的介面與外部作溝通。
> SOA 介面定義的方式、資料格式、與溝通管道必須是產業標準 (http、XML、SOAP 等)。也就是說只要能實作出這樣的介面,不論介面後面是什麼,都可使成為 SOA。
想法:
簡單說,SOA 是一個概念(Guide),政客一點的講法就是:發展“方針”、發展“大方向”。
SOA(服務導向架構)跟 OOP(物件導向編程)算同宗,把“物件”換成“服務”就很好理解了。
就像物件的類別需要提供各種方法(method,例如 _get;_set)來讓外部呼叫,
一個號稱 SOA 的服務(系統、軟體、網站、etc.)也需要一個 interface 可讓外部呼叫。
“實作一個標準的介面與外部作溝通” 就很重要了。
關於這個介面的火紅名詞:
SOAP、UDDI、WSDL(都是 Web Service 的 XML + HTTP)
http://wwww.w3schools.com/webservices/ws_intro.asp
http://www.w3.org/TR/ws-arch/
不過也有人指出這些東西的毛病:
http://coolshell.cn/articles/3585.html
http://coolshell.cn/articles/3498.html
http://coolshell.cn/articles/2504.html
現在比較流行的是:
REST(Representational State Transfer)
關於 Web Service 的做法可以參考水利署的 API:
http://wrisp.wra.gov.tw/Public/Support/ServiceUseGuide.aspx
而 RESTful API 的樣子可以參考這篇文章:
http://tedwise.com/2009/03/19/what-does-a-rest-interface-look-like
2011/12/21
Puppet
http://puppetlabs.com/
Puppet 是一個 Client/Server 式的[配置|設定|服務]管理工具,它是用 Ruby 寫的。
簡單講,所有(Linux)機器的配置集中管理在 Puppet Server 上,
Puppet Client 機器連線到 Server 上取得對應的配置,並根據其內容對自己進行設定。
Puppet 並不是 scp 一個設定檔回來然後 Apply。
Puppet Client 使用一套用 Ruby 寫的叫 facter 的工具取得主機基本資訊。
Puppet Server 根據傳來的資訊(ex:IP, OS, RAM, etc.)編譯出相對應的配置檔並回傳。
在 Ubuntu 系統上安裝 Puppet 非常簡單:
Puppet 看待裝置或服務的哲學跟 UNIX 很像:
每一個裝置、服務對 Puppet 來說,都是一個「資源(Resource)」。
*
【*.pp】
Puppet 解讀名爲 *.pp 的檔案,然後對不同的 Client 編譯產生不同的配置。
一個簡單的 test.pp 檔案內容如下:
*.pp 有一套簡單的文法與規則,其中亦有類別跟繼承等,強烈建議閱讀文件瞭解!
*
【Puppet Client/Server 運作流程】
1」Puppet Client 的 puppetd 程式呼叫 facter 程式,facter 程式會偵測出 Puppet Client 主機的相關資訊,例如 hostname、RAM、Hard Disk、IP 等等。Puppet Client 的 puppetd 再透過“SSL”把這些訊息傳到 Puppet Server。
2」Puppet Server 的 puppetmaster 程式檢查 Puppet Client 送來的資訊,會使用 Puppet Client 的 hostname 來找到 /etc/puppet/manifest 裡面對應的 node 配置,然後分析以及解讀牽涉到的 *.pp 檔或 Puppet 程式碼,Puppet Client 使用 facter 生成的訊息會被當成變數傳入這些 *.pp 檔或 Puppet 程式碼。
3」當 Puppet Server 知道需要處理哪些 *.pp 檔後,就會將它們進行解析,這個 *.pp 檔解析的動作可以看成是程式的編譯(或是直譯?)。解析會分成幾個階段,首先是語法檢查,語法錯誤就會直接報錯了;語法檢查通過,會產生解析的結果(僞代碼檔?),這個結果同樣會透過 SSL 傳送回 Puppet Client。
4」Puppet Client 收到 Puppet Server 的解析結果,然後執行,並且把執行的結果回傳。
5」Puppet Server 把 Puppet Client 的執行結果寫到 log。
*
【Puppet Client/Server 配置】
Puppet Client 與 Puppet Server 的安裝、設定、配置,最好都使用 root 帳號。
進行 Client/Server 設置前,請務必千萬確定每臺主機的 hostname!
Puppet 的 Client/Server 配置有綁定 hostname 進行驗證。
Puppet 要求符合 FQDN 的 hostname。
請先執行 hostname 並檢查 /etc/hostname 進行確定。
並確認 /etc/hosts 檔案有正確的 hostname 與 IP 配對。
連線與驗證都需要 root 身份來進行。
Puppet Client 與 Server 的系統時間要校正一致,否則認證會出問題!
建議主機使用同樣的 NTP Server 進行時間同步。
請特別注意!
在 Client/Server 環境中,Puppet Server 預設讀取 *.pp 的路徑是:
/etc/puppet/manifests/
可以編寫一個 /etc/puppet/manifests/site.pp 檔測試:
第一次進行 Client/Server 的配置連線會需要驗證。
先在 Puppet Client 執行:
*
【Puppet CA 驗証】
Puppet 的驗證文件預設:
Puppet Client:/var/lib/puppet/ssl
Puppet Server:/var/lib/puppet/ssl/ca/
若驗證有問題,在該資料夾下找到相對應的 *.pem,刪除舊的 *.pem 檔後,重新認證。
*
【建議的 /etc/puppet/ 目錄架構】
*
【使用 Puppet Module】
來源:http://docs.puppetlabs.com/guides/modules.html
*
【使用 Puppet Template】
Puppet Template 可以用來動態產生不同的內容。
應用的情境比較像是同樣的設定檔,但是有些許的設定不盡相同。
例如都是 httpd 服務,不見得所有 Puppet node 的 httpd.conf 都完全相同。
Puppet Template 檔是使用 Ruby 的 ERB Template,並不難寫。
請參考:http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html
Puppet Template 的使用也很簡單:
Red Hat 環境通常是 /var/lib/puppet/templates;
Ubuntu 環境通常是 /etc/puppet/templates。
可以使用 puppet --configprint templatedir 指令確認。
實作的建議是把 erb 檔放到各個 Module 資料夾中。
題外話,可以執行 puppet --configprint all 看看 :-)
來源:http://docs.puppetlabs.com/guides/templating.html
*
【Puppet 設定檔範例】
https://github.com/ghoneycutt/puppet-generic
*
【Puppet 名詞解釋】
catalog : A catalog is the totality of resources, files, properties, etc, for a given system.
manifest : A configuration file written in the Puppet language. These files should have the .pp extension.
module : A collection of classes, resource types, files, and templates, organized around a particular purpose.
node (general noun) : An individual server; for the purposes of discussing Puppet, this generally refers to an agent node.
node (Puppet language keyword) : A collection of classes and/or resources to be applied to the agent node whose unique identifier (“certname”) matches the specified node name. Nodes defined in manifests allow inheritance, although this should be used with care due to the behavior of dynamic variable scoping.
provider : A simple implementation of a type; examples of package providers are dpkg and rpm, and examples of user providers are useradd and netinfo. Most often, providers are just Ruby wrappers around shell commands, and they are usually very short and thus easy to create.
templates : templates are ERB files used to generate configuration files for systems and are used in cases where the configuration file is not static but only requires minor changes based on variables that Puppet can provide (such as hostname). See also distributable file.
type : abstract description of a type of resource. Can be implemented as a native type, plug-in type, or defined type.
agent or agent node : An operating system instance managed by Puppet. This can be an operating system running on its own hardware or a virtual image.
來源:http://projects.puppetlabs.com/projects/puppet/wiki/Glossary_Of_Terms
*
強烈推薦文件:
http://puppet.wikidot.com
Reference:
http://puppet-manifest-share.googlecode.com/files/puppet-1.0.pdf
http://www.comeonsa.com/category/puppet/
http://bitcube.co.uk/content/puppet-errors-explained
http://www.example42.com
http://docs.puppetlabs.com/guides/troubleshooting.html
http://docs.puppetlabs.com/guides/troubleshooting.html
http://blog.akquinet.de/2011/11/23/managing-an-apache-server-with-puppet/
Puppet 是一個 Client/Server 式的[配置|設定|服務]管理工具,它是用 Ruby 寫的。
簡單講,所有(Linux)機器的配置集中管理在 Puppet Server 上,
Puppet Client 機器連線到 Server 上取得對應的配置,並根據其內容對自己進行設定。
Puppet 並不是 scp 一個設定檔回來然後 Apply。
Puppet Client 使用一套用 Ruby 寫的叫 facter 的工具取得主機基本資訊。
Puppet Server 根據傳來的資訊(ex:IP, OS, RAM, etc.)編譯出相對應的配置檔並回傳。
在 Ubuntu 系統上安裝 Puppet 非常簡單:
sudo apt-get install ruby-full # 安裝 Ruby 環境 sudo apt-get install facter # 安裝 Facter 後可以直接執行 facter 測試一下 sudo apt-get install puppet # Puppet Client 套件 sudo apt-get install puppetmaster # Puppet Server 套件,Client 不需安裝 # 在 Redhat 環境,Puppet Client 套件叫:puppet # 在 Redhat 環境,Puppet Server 套件叫:puppet-server
Puppet 看待裝置或服務的哲學跟 UNIX 很像:
每一個裝置、服務對 Puppet 來說,都是一個「資源(Resource)」。
*
【*.pp】
Puppet 解讀名爲 *.pp 的檔案,然後對不同的 Client 編譯產生不同的配置。
一個簡單的 test.pp 檔案內容如下:
file
{
"/tmp/test.txt": content => "hello, world";
}
執行:puppet test.pp執行結果是在 /tmp 底下產生一個 test.txt 檔,且內容爲「hello, world」。
*.pp 有一套簡單的文法與規則,其中亦有類別跟繼承等,強烈建議閱讀文件瞭解!
*
【Puppet Client/Server 運作流程】
1」Puppet Client 的 puppetd 程式呼叫 facter 程式,facter 程式會偵測出 Puppet Client 主機的相關資訊,例如 hostname、RAM、Hard Disk、IP 等等。Puppet Client 的 puppetd 再透過“SSL”把這些訊息傳到 Puppet Server。
2」Puppet Server 的 puppetmaster 程式檢查 Puppet Client 送來的資訊,會使用 Puppet Client 的 hostname 來找到 /etc/puppet/manifest 裡面對應的 node 配置,然後分析以及解讀牽涉到的 *.pp 檔或 Puppet 程式碼,Puppet Client 使用 facter 生成的訊息會被當成變數傳入這些 *.pp 檔或 Puppet 程式碼。
3」當 Puppet Server 知道需要處理哪些 *.pp 檔後,就會將它們進行解析,這個 *.pp 檔解析的動作可以看成是程式的編譯(或是直譯?)。解析會分成幾個階段,首先是語法檢查,語法錯誤就會直接報錯了;語法檢查通過,會產生解析的結果(僞代碼檔?),這個結果同樣會透過 SSL 傳送回 Puppet Client。
4」Puppet Client 收到 Puppet Server 的解析結果,然後執行,並且把執行的結果回傳。
5」Puppet Server 把 Puppet Client 的執行結果寫到 log。
*
【Puppet Client/Server 配置】
Puppet Client 與 Puppet Server 的安裝、設定、配置,最好都使用 root 帳號。
進行 Client/Server 設置前,請務必千萬確定每臺主機的 hostname!
Puppet 的 Client/Server 配置有綁定 hostname 進行驗證。
Puppet 要求符合 FQDN 的 hostname。
請先執行 hostname 並檢查 /etc/hostname 進行確定。
並確認 /etc/hosts 檔案有正確的 hostname 與 IP 配對。
連線與驗證都需要 root 身份來進行。
Puppet Client 與 Server 的系統時間要校正一致,否則認證會出問題!
建議主機使用同樣的 NTP Server 進行時間同步。
請特別注意!
在 Client/Server 環境中,Puppet Server 預設讀取 *.pp 的路徑是:
/etc/puppet/manifests/
可以編寫一個 /etc/puppet/manifests/site.pp 檔測試:
node default
{
file
{
"/tmp/puppet_server.message":
content => "Hello, Puppet Client!";
}
}
第一次進行 Client/Server 的配置連線會需要驗證。
先在 Puppet Client 執行:
puppetd --server 伺服器主機名稱 --test再到 Puppet Server 執行:
puppetca --sign 客戶端主機名稱最後回到 Puppet Client 執行:
puppetd --server 伺服器主機名稱 --test此時,Puppet Client 應該會產生一個內容爲「Puppet Manifest」的 /tmp/site.txt 檔。
*
【Puppet CA 驗証】
Puppet 的驗證文件預設:
Puppet Client:/var/lib/puppet/ssl
Puppet Server:/var/lib/puppet/ssl/ca/
若驗證有問題,在該資料夾下找到相對應的 *.pem,刪除舊的 *.pem 檔後,重新認證。
puppetca --list --all puppetca --list puppetca --sign CLIENT_HOSTNAME puppetca --print CLIENT_HOSTNAME puppetca --clean CLIENT_HOSTNAME # 刪除舊的認証 man puppetca
*
【建議的 /etc/puppet/ 目錄架構】
manifests/
site.pp
templates.pp
nodes.pp
modules/
{module_name}
modules/user/
services/
clients/
notes/
plugins/
tools/
來源:http://projects.puppetlabs.com/projects/1/wiki/Puppet_Best_Practice*
【使用 Puppet Module】
來源:http://docs.puppetlabs.com/guides/modules.html
*
【使用 Puppet Template】
Puppet Template 可以用來動態產生不同的內容。
應用的情境比較像是同樣的設定檔,但是有些許的設定不盡相同。
例如都是 httpd 服務,不見得所有 Puppet node 的 httpd.conf 都完全相同。
Puppet Template 檔是使用 Ruby 的 ERB Template,並不難寫。
請參考:http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html
Puppet Template 的使用也很簡單:
$value = template("my_template.erb")
my_template.erb 可換成 erb 檔的絕對路徑,或把 erb 檔放到 Puppet 預設會找的路徑。Red Hat 環境通常是 /var/lib/puppet/templates;
Ubuntu 環境通常是 /etc/puppet/templates。
可以使用 puppet --configprint templatedir 指令確認。
實作的建議是把 erb 檔放到各個 Module 資料夾中。
題外話,可以執行 puppet --configprint all 看看 :-)
來源:http://docs.puppetlabs.com/guides/templating.html
*
【Puppet 設定檔範例】
https://github.com/ghoneycutt/puppet-generic
*
【Puppet 名詞解釋】
catalog : A catalog is the totality of resources, files, properties, etc, for a given system.
manifest : A configuration file written in the Puppet language. These files should have the .pp extension.
module : A collection of classes, resource types, files, and templates, organized around a particular purpose.
node (general noun) : An individual server; for the purposes of discussing Puppet, this generally refers to an agent node.
node (Puppet language keyword) : A collection of classes and/or resources to be applied to the agent node whose unique identifier (“certname”) matches the specified node name. Nodes defined in manifests allow inheritance, although this should be used with care due to the behavior of dynamic variable scoping.
provider : A simple implementation of a type; examples of package providers are dpkg and rpm, and examples of user providers are useradd and netinfo. Most often, providers are just Ruby wrappers around shell commands, and they are usually very short and thus easy to create.
templates : templates are ERB files used to generate configuration files for systems and are used in cases where the configuration file is not static but only requires minor changes based on variables that Puppet can provide (such as hostname). See also distributable file.
type : abstract description of a type of resource. Can be implemented as a native type, plug-in type, or defined type.
agent or agent node : An operating system instance managed by Puppet. This can be an operating system running on its own hardware or a virtual image.
來源:http://projects.puppetlabs.com/projects/puppet/wiki/Glossary_Of_Terms
*
強烈推薦文件:
http://puppet.wikidot.com
Reference:
http://puppet-manifest-share.googlecode.com/files/puppet-1.0.pdf
http://www.comeonsa.com/category/puppet/
http://bitcube.co.uk/content/puppet-errors-explained
http://www.example42.com
http://docs.puppetlabs.com/guides/troubleshooting.html
http://docs.puppetlabs.com/guides/troubleshooting.html
http://blog.akquinet.de/2011/11/23/managing-an-apache-server-with-puppet/
2011/10/24
套件管理員
Python:pip
easy_install 或 setuptools 或 ez_setup.py
使用 easy_install 安裝起來放在 site-packages 的 *.egg 類似 Java 的 *.jar
PHP:Pear
Ruby:RubyGems
Perl:CPAN(Comprehensive Perl Archive Network)
R:CRAN
Node.js:npm
Ubuntu:apt-get、dpkg
Redhat:yum
Mac:homebrew
Reference:
01. http://www.ibm.com/developerworks/cn/linux/l-cppeak3.html
easy_install 或 setuptools 或 ez_setup.py
使用 easy_install 安裝起來放在 site-packages 的 *.egg 類似 Java 的 *.jar
PHP:Pear
Ruby:RubyGems
Perl:CPAN(Comprehensive Perl Archive Network)
R:CRAN
Node.js:npm
Ubuntu:apt-get、dpkg
Redhat:yum
Mac:homebrew
Reference:
01. http://www.ibm.com/developerworks/cn/linux/l-cppeak3.html
2011/01/28
Storage Area Network
LUN
Reference:
01. http://en.wikipedia.org/wiki/Storage_area_network
02. http://en.wikipedia.org/wiki/Logical_Unit_Number
03. http://en.wikipedia.org/wiki/ISCSI
04. http://en.wikipedia.org/wiki/Fibre_Channel
Reference:
01. http://en.wikipedia.org/wiki/Storage_area_network
02. http://en.wikipedia.org/wiki/Logical_Unit_Number
03. http://en.wikipedia.org/wiki/ISCSI
04. http://en.wikipedia.org/wiki/Fibre_Channel
訂閱:
文章 (Atom)