func統一網絡控制器安裝配置

Func 是紅帽子公司 Fedora平臺統一網絡控制器

FuncFedora UnifiedNetwork Controller https://fedorahosted.org/func),目的是爲了解決這一系列統一管理監控問題而設計開發的系統管理基礎框架。能有效的簡化多服務器系統管理工作的工具,易於學習,易於使用,易於擴展,而且功能強大。

Func的特點有:

1Func可以在主控機上一次管理任意多臺或任意多個服務器組。

2Func基於Certmasterhttps://fedorahosted.org/certmaster/)建立了Master-Slaves主從SSL證書管控體系,可以將證書自動分發到所有受控服務器。

3Func命令行可以直接發送遠程命令或者遠程獲取數據。

4Func 開發者已經完成了大多數常用任務模塊的開發,包括命令執行模塊、文件傳輸模塊、IPtables模塊、查看硬件信息模塊、Mount模塊、進程模塊、服務模塊、重啓系統模塊等。

5、可以通過Func提供的Python API輕鬆編寫擴展模塊,以實現具體功能擴展。而且任何Func命令行能完成的工作,都能通過API編程實現。

6Func通訊基於XMLRPCSSL標準協議。


系統:Master : centos 5.8 x86

Minion: centos 6.3 x86

配置hosts文件,使masterminions可以相互解析。

func安裝

一、Master控制端配置

1.安裝fedora發佈的epel yum源,

rpm –Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

如果下載地址失效可以從這裏針對自己的版本進行下載

http://fedoraproject.org/wiki/EPEL

2.安裝func

func基於certmaster,本次會一同安裝,都在epel源裏,我這裏安裝的時候提示少個依賴包python-simplejson,網上搜了一個(如果你的源裏有的話可以不用下載)

wget ftp://ftp.pbone.net/mirror/ftp.centos.org/5.9/os/i386/CentOS/python-simplejson-2.0.9-8.el5.i386.rpm

rpm -ivh python-simplejson-2.0.9-8.el5.i386.rpm

yum install func

3.配置certmaster

vi/etc/certmaster/certmaster.conf

#configuration for certmasterd and certmaster-ca


[main]

autosign= no

listen_addr= 192.168.15.188 #監聽IP,也可以不寫

listen_port= 51235 #監聽端口,自己定義

cadir =/etc/pki/certmaster/ca

cert_dir= /etc/pki/certmaster

certroot= /var/lib/certmaster/certmaster/certs

csrroot =/var/lib/certmaster/certmaster/csrs

cert_extension= cert

sync_certs = False

###############################################################


4.iptables允許,啓動certmaster服務

#func

/sbin/iptables -A INPUT -s 192.168.15.183 -p tcp --dport 51235 -j ACCEPT

/sbin/iptables -A INPUT -s 192.168.1.200 -p tcp --dport 51235 -j ACCEPT

注意:Master端是啓動certmaster服務,被控制端是啓動funcd服務

#/etc/init.d/certmaster start


minion被控制端

1.安裝epel

版本5

wgethttp://mirrors.yun-idc.com/epel/5/i386/epel-release-5-4.noarch.rpm

rpm -ivh epel-release-5-4.noarch.rpm


版本6

rpm –Uvh http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarch.rpm


2.安裝func

同樣,還是少這個包【應該5.5及以下的系統版本會少】,如果你的系統沒有報錯缺少,可以跳過

wget ftp://ftp.pbone.net/mirror/ftp.centos.org/5.9/os/i386/CentOS/python-simplejson-2.0.9-8.el5.i386.rpm

rpm -ivh python-simplejson-2.0.9-8.el5.i386.rpm

yum install func


3.minions客戶端配置

vi /etc/func/minion.conf

#configuration for minions


[main]

log_level= INFO #默認日誌級別爲debug

acl_dir =/etc/func/minion-acl.d


listen_addr=

listen_port= 51234 #默認端口被監控主機監聽的端口

minion_name=

method_log_dir = /var/log/func/methods/


這裏可選配置minion被控制端的監聽地址,在/etc/func/minion.conf文件中,該監聽端口用於響應master發送的指令。這個修改要在申請證書前完成,完成後不可修改。【由於沒有瞭解到更深層的東西,所以端口的修改建議不要做,保留默認的51234端口。】


certmaster關聯配置

vi /etc/certmaster/minion.conf

#configuration for minions


[main]

certmaster= server.puppet.com #配置master的地址或master主機名【要能夠互相解析】

certmaster_port= 51235 #服務端的偵聽端口

log_level= DEBUG

cert_dir = /etc/pki/certmaster


4.啓動funcd服務

/sbin/iptables -A INPUT -s 192.168.15.188 -p tcp --dport 51234 -j ACCEPT #允許master訪問minions

/etc/init.d/funcd start

服務啓動後會自動向master服務器提交證書申請

這個服務啓動有沒有成功都不會報錯,如果有報錯,會在日誌 /var/log/func/func.log裏,


注意:master連接minions時,要求minions監聽在相同的端口

Funcd's listening port can be configured in /etc/func/minion.conf inthe listen_port option.

Overlord's will also check this file and setting todetermine which ports to connect to the minions with.Note that currentlyoverlord requires all minions to be listening on the same port.


如果以上都沒有報錯可以進行第三步證書籤署,有報錯先解決了。


證書籤署及驗證操作

1. master服務器端

certmaster-ca –l 查看證書請求

certmaster-ca –s hostname 簽署證書(這個hostname即是通過-l列出來的)爲客戶端簽署證書

certmaster-ca--list-signed查看已經簽署了哪些證書

2以上的操作都能在日誌裏面看到,涉及的日誌有

/var/log/certmaster/*

/var/log/func/*

3. 使用簡例(master端)

1.列出有多少個minions

[root@Master_station~]# func "*" list_minions

myvmware_station.example.com

myvmware_station2.example.com

2. 查看minions是否都在線

[root@Master_station ~]# func "*" ping

[ ok ... ] myvmware_station.example.com

[ ok ... ] myvmware_station2.example.com

3.[root@server ~]#func "myvmware_station2.example.com" call cpu usage

有返回數據,則說明安裝完成正常,具體使用語法參考其他資料。

4.master端執行funcd --list-modules可以查看已有的模塊。

四 命令使用示例

操作對象可以使用正則匹配,可以列舉多個【用分號對分隔】

查看已有模塊

funcd --list-modules

查看minions主機列表

func “*” list_minions

拷貝文件[拷貝到遠端]

func "myvmware_statio*" copyfile -f /tmp/check_disk.sh --remotepath=/tmp/file1


判斷文件是否存在

func "myvmware_statio*"call command exists /tmp/file1


執行腳本

func "myvmware_statio*"call command run " /tmp/file1"


刪除使用的臨時文件

func "myvmware_statio*"call command run "rm /tmp/file1"



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章