天天看點

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

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

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

Func的特點有:

1、Func可以在主要機上一次管理任意多台或任意多個伺服器組。

2、Func基于Certmaster(https://fedorahosted.org/certmaster/)建立了Master-Slaves主從SSL證書管控體系,可以将證書自動分發到所有受控伺服器。

3、Func指令行可以直接發送遠端指令或者遠端擷取資料。

4、Func 開發者已經完成了大多數常用任務子產品的開發,包括指令執行子產品、檔案傳輸子產品、IPtables子產品、檢視硬體資訊子產品、Mount子產品、程序子產品、服務子產品、重新開機系統子產品等。

5、可以通過Func提供的Python API輕松編寫擴充子產品,以實作具體功能擴充。而且任何Func指令行能完成的工作,都能通過API程式設計實作。

6、Func通訊基于XMLRPC和SSL标準協定。

系統:Master : centos 5.8 x86

Minion: centos 6.3 x86

配置hosts檔案,使master與minions可以互相解析。

func安裝

一、Master控制端配置

1.安裝fedora釋出的epel yum源,

http://fedoraproject.org/wiki/EPEL

2.安裝func

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

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

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

3.minions用戶端配置

vi /etc/func/minion.conf

#configuration for minions

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

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可以檢視已有的子產品。

四 指令使用示例

操作對象可以使用正則比對,可以列舉多個【用分号對分隔】

<a>檢視已有子產品</a>

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"

本文轉自 劉園  51CTO部落格,原文連結:http://blog.51cto.com/colynn/1303808