<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[运维进行时]]></title> 
<link>https://blog.liuts.com/index.php</link> 
<description><![CDATA[互联网运维与架构]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[运维进行时]]></copyright>
<item>
<link>https://blog.liuts.com/post/208/</link>
<title><![CDATA[译文-Symbolic一个基于func集中式管理平台[原创]]]></title> 
<author>刘天斯 &lt;liutiansi@gmail.com&gt;</author>
<category><![CDATA[Func]]></category>
<pubDate>Fri, 23 Jul 2010 16:27:31 +0000</pubDate> 
<guid>https://blog.liuts.com/post/208/</guid> 
<description>
<![CDATA[ 
	<a href="http://www.opensymbolic.org/" target="_blank"><strong><u>Symbolic</u></strong></a>是一个开源的企业平台，旨在建立、配置和管理您的庞大分布式数据中心为目的开源框架，代表了目前最先进的数据中心解决方案的集中管理平台。<br/><br/><strong>特征</strong><br/>1、属于RedHat认证协议栈的应用<br/>2、具于func后端应用<br/>3、支持 RHEL、Centos及Fedora<br/>4、先进的拖放标签管理(Ajax)<br/>5、提供Cobbler支持<br/>6、灵活管理操作用户、主机<br/>7、组和权限管理标记<br/>8、先进的基于Web的Ajax接口<br/>9、支持LDAP，Kerberos和本地认证<br/>10、符合JEE标准<br/>11、完全可定制的业务<br/>12、灵活的管理用户和主机<br/>13、安全的SSL连接<br/>14、虚拟机管理<br/>15、可定制的插件支持<br/>16、执行各种语言编写的外部脚本（Python、Groovy、bashshell）<br/><br/><strong>平台截图</strong><br/><a href="http://www.opensymbolic.org/sites/opensymbolic.org/files/images/operation-edit.preview.png" target="_blank"><img src="http://www.opensymbolic.org/sites/opensymbolic.org/files/images/operation-edit.preview.png" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><br/><a href="http://www.opensymbolic.org/sites/opensymbolic.org/files/images/cluster-manager.preview.png" target="_blank"><img src="http://www.opensymbolic.org/sites/opensymbolic.org/files/images/cluster-manager.preview.png" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><br/><a href="http://www.opensymbolic.org/sites/opensymbolic.org/files/images/cobbler-vm-2.png" target="_blank"><img src="http://www.opensymbolic.org/sites/opensymbolic.org/files/images/cobbler-vm-2.png" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><br/><a href="http://www.opensymbolic.org/sites/opensymbolic.org/files/images/user-adding-authority.preview.png" target="_blank"><img src="http://www.opensymbolic.org/sites/opensymbolic.org/files/images/user-adding-authority.preview.png" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><br/><strong>如何部署平台？</strong><br/>192.168.0.1 symbolic.example.com - Symbolic Machine (管理端)<br/>192.168.0.2 station1.example.com - Symbolic Client (被控端)<br/><br/><a href="http://www.opensymbolic.org/sites/opensymbolic.org/files/docs/v1.2.1/html/images/tutorial.png" target="_blank"><img src="http://www.opensymbolic.org/sites/opensymbolic.org/files/docs/v1.2.1/html/images/tutorial.png" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>平台架构图<br/><br/>1、如没有内部DNS服务器，需要修改hosts<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>echo "127.0.0.1&nbsp;&nbsp;&nbsp;&nbsp; localhost.localdomain&nbsp;&nbsp;&nbsp;&nbsp;localhost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" >&nbsp;&nbsp;/etc/hosts<br/>echo "192.168.0.1&nbsp;&nbsp; symbolic.example.com&nbsp;&nbsp;&nbsp;&nbsp; symbolic&nbsp;&nbsp; certmaster" >> /etc/hosts<br/>echo "192.168.0.2&nbsp;&nbsp; station1.example.com&nbsp;&nbsp;&nbsp;&nbsp; station1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " >> /etc/hosts<br/></div></div><br/>2、安装EPEL包<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm<br/></div></div><br/>3、安装Certmaster and Func<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>yum install certmaster func smolt<br/></div></div><br/><span style="color: #FF0000;">注：也可参考<a href="http://blog.liuts.com/post/186/" target="_blank">源码安装方式</a></span><br/>4、启用端口，记得在防火墙开启以下端口<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>51235/TCP on symbolic.example.com<br/>51234/TCP on symbolic.example.com<br/>51234/TCP on station1.example.com<br/></div></div><br/>5、配置func日志分隔<br/>#vi /etc/logrotate.d/func_rotate<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>/var/log/func/audit.log &#123;<br/>&nbsp;&nbsp; missingok<br/>&nbsp;&nbsp; notifempty<br/>&nbsp;&nbsp; rotate 4<br/>&nbsp;&nbsp; weekly<br/>&nbsp;&nbsp; postrotate<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if [ -f /var/lock/subsys/funcd ]; then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /etc/init.d/funcd condrestart<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fi<br/>&nbsp;&nbsp; endscript<br/>&#125;<br/><br/>/var/log/func/func.log &#123;<br/>&nbsp;&nbsp; missingok<br/>&nbsp;&nbsp; notifempty<br/>&nbsp;&nbsp; copytruncate<br/>&nbsp;&nbsp; rotate 4<br/>&nbsp;&nbsp; weekly<br/>&#125;<br/></div></div><br/><br/>6、配置Certmaster及func<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>#chkconfig certmaster on<br/>#service certmaster start<br/><br/>#chkconfig funcd on<br/>#service funcd start<br/></div></div><br/>7、查看被控端认证请求<br/><br/>certmaster-ca --list<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>[root@symbolic ~]# certmaster-ca --list<br/>symbolic.example.com<br/></div></div><br/>8、认证主机<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>#certmaster-ca --sign symbolic.example.com<br/></div></div><br/>9、下载并安装Symbolic<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>wget http://downloads.sourceforge.net/symbolic/symbolic-&#123;VERSION&#125;.noarch.rpm<br/>yum --nogpgcheck localinstall symbolic-&#123;VERSION&#125;.noarch.rpm<br/></div></div><br/>10、配置JAVA_HOME<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>#vi /etc/sysconfig/symbolic<br/>...<br/>JAVA_HOME="/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0"<br/>...<br/></div></div><br/>11、配置启用symbolic<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>#symbolic-setup<br/>#service symbolic start<br/>#chkconfig symbolic on<br/></div></div><br/>12、完毕，访问平台<br/>http://symbolic.example.com:8081/symbolic<br/>Username:&nbsp;&nbsp;&nbsp;&nbsp;root<br/>Password:&nbsp;&nbsp;&nbsp;&nbsp;pass<br/><br/><strong>如何添加主机？</strong><br/>1、安装EPEL包<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm<br/></div></div><br/>2、安装Func与Smolt<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>yum install func smolt<br/></div></div><br/>3、配置hosts<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>echo "127.0.0.1&nbsp;&nbsp;&nbsp;&nbsp; localhost.localdomain&nbsp;&nbsp;&nbsp;&nbsp;localhost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" >&nbsp;&nbsp;/etc/hosts<br/>echo "192.168.0.1&nbsp;&nbsp; symbolic.example.com&nbsp;&nbsp;&nbsp;&nbsp; symbolic&nbsp;&nbsp; certmaster" >> /etc/hosts<br/>echo "192.168.0.2&nbsp;&nbsp; station1.example.com&nbsp;&nbsp;&nbsp;&nbsp; station1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " >> /etc/hosts<br/></div></div><br/>4、配置客户端certmaster配置<br/>#vi /etc/certmaster/minion.conf<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/># configuration for minions<br/>[main]<br/>certmaster = symbolic.example.com<br/>log_level = DEBUG<br/>cert_dir = /etc/pki/certmaster<br/></div></div><br/>5、启动func服务<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>chkconfig funcd on<br/>service funcd start<br/></div></div><br/>6、到服务器主进行认证，方法见部署平台第8点。在平台Admin → Reload Certs可以看到请求的主机清单。<br/><br/><strong>在线文档V1.5.0</strong><br/><a href="http://www.opensymbolic.org/sites/opensymbolic.org/files/docs/v1.5.0/html/index.html" target="_blank">http://www.opensymbolic.org/sites/opensymbolic.org/files/docs/v1.5.0/html/index.html</a><br/><br/>译文：<a href="http://www.opensymbolic.org/sites/opensymbolic.org/files/docs/v1.2.1/html/Symbolic-Tutorial.html#Symbolic-Tutorial-Server_Configuration" target="_blank">http://www.opensymbolic.org/sites/opensymbolic.org/files/docs/v1.2.1/html/Symbolic-Tutorial.html#Symbolic-Tutorial-Server_Configuration</a><br/>Tags - <a href="https://blog.liuts.com/tags/symbolic/" rel="tag">symbolic</a> , <a href="https://blog.liuts.com/tags/func/" rel="tag">func</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/200/</link>
<title><![CDATA[Func非Python API实现远程调用[原创]]]></title> 
<author>刘天斯 &lt;liutiansi@gmail.com&gt;</author>
<category><![CDATA[Func]]></category>
<pubDate>Wed, 02 Jun 2010 04:04:26 +0000</pubDate> 
<guid>https://blog.liuts.com/post/200/</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;关于Func非Python API实现远程调用，目的是给第三方工具提供调用及返回接口。Func使用func-transmit命令来实现，支持YAML 1.0 与 JSON，使用上非常简单。例子如下：<br/><span style="color: #0000FF;"><strong>YAML格式</strong></span><br/>#vi run.yaml<br/><textarea name="code" class="c" rows="15" cols="100">
clients: "*"
async: False
nforks: 1
module: command
method: run
parameters: "/bin/echo Hello World"
</textarea><br/><span style="color: #0000FF;"><strong>JSON格式</strong></span><br/>#vi run.json<br/><textarea name="code" class="c" rows="15" cols="100">
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"clients": "*",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"async": "False",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"nforks": 1,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"module": "command",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"method": "run",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"parameters": "/bin/echo Hello World"
&#125;
</textarea><br/><span style="color: #0000FF;"><strong>参数说明</strong></span><br/><span style="color: #008000;">clients</span>&nbsp;&nbsp;&nbsp;&nbsp;目标主机，"*"代码所有被控主机。<br/><span style="color: #008000;">async</span>&nbsp;&nbsp;&nbsp;&nbsp; 是否异步，是一个bool值，True为使用异步，False则不使用。<br/><span style="color: #008000;">nforks</span>&nbsp;&nbsp;&nbsp;&nbsp;启用的线程数，用数字表示。<br/><span style="color: #008000;">module</span>&nbsp;&nbsp;模块名称，如command。<br/><span style="color: #008000;">method</span>&nbsp;&nbsp;方法名称，如command模块下的run方法。<br/><span style="color: #008000;">parameters</span>&nbsp;&nbsp;参数，如"/usr/bin/tail -100 /var/log/messages"。<br/><br/><span style="color: #0000FF;"><strong>运行结果</strong></span><br/>func-transmit --json < run.json<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>&#123;"SERVER-005": "Hello World www.tianya.cn", "SERVER-004": "Hello World www.tianya.cn", "SERVER-001": "Hello World www.tianya.cn", "SERVER-003": "Hello World www.tianya.cn", "SERVER-002": "Hello World www.tianya.cn"&#125;<br/></div></div><br/>func-transmit --yaml < run.yaml<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>---<br/>SERVER-001: Hello World www.tianya.cn<br/>SERVER-002: Hello World www.tianya.cn<br/>SERVER-003: Hello World www.tianya.cn<br/>SERVER-004: Hello World www.tianya.cn<br/>SERVER-005: Hello World www.tianya.cn<br/></div></div><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 从运行结果可以看出，根据不同的接口格式能返回相应的结果。此时输出的YAML与JSON格式能够被绝大多数的语言识别，接下来就可以做一些后续的处理了。<br/>Tags - <a href="https://blog.liuts.com/tags/func/" rel="tag">func</a> , <a href="https://blog.liuts.com/tags/func-transmit/" rel="tag">func-transmit</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/199/</link>
<title><![CDATA[编写Func自定义模块[原创]]]></title> 
<author>刘天斯 &lt;liutiansi@gmail.com&gt;</author>
<category><![CDATA[Func]]></category>
<pubDate>Mon, 31 May 2010 03:54:17 +0000</pubDate> 
<guid>https://blog.liuts.com/post/199/</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://fedorahosted.org/func/" target="_blank">Func</a>是目前redhat系列平台最棒的集群管理工具(个人看法)，发现越来越多的人已经开始在使用，从接触的大部分人都会说自带的模块已经够用了。其实在我们的日常维护当中，尤其是大规模的服务器集群、满天飞的业务系统等等。此时Func自带的模块已经远远不能满足我们的需求，现介绍Func是如何实现一个简单的自定义模块的。<br/><br/><strong>[方法一]</strong><br/>通过CommandModule来实现,只需修改要运行命令参数就可以了。<br/><br/>优点：简单、部署方便；<br/>缺点：不够灵活，扩展性弱；<br/>适合场景：中小型集群;<br/><br/><span style="color: #0000FF;">命令方式：</span><br/><textarea name="code" class="c" rows="15" cols="100">
#查看所有服务器时间;
func "*" call command run "/bin/date"

#查看所有服务器系统日志，执行的超时时间为3秒；
func -t 3 "*" call command run "/usr/bin/tail -10 /var/log/messages"

#查看所有主机uptime，开启5个线程异步运行(主机数超过10台建议开启)；
func -t 3 "*" call --forks="5" --async command run "/usr/bin/uptime"

#格式化输出结果，默认格式为python的元组，分别添加--jsion或--xml来输出json及xml的格式。
func -t 3 "*" call --forks="5" --json --async command run "/usr/bin/uptime"
</textarea><br/><span style="color: #0000FF;">python api方式：</span><br/><textarea name="code" class="python" rows="15" cols="100">
import func.overlord.client as fc
client = fc.Client("*")
print fc.client.command.run("/usr/bin/tail -10 /var/log/messages")
</textarea><br/><strong>[方法二]</strong><br/>通过编写func模块来达到扩展的目的。<br/><br/>优点：可以根据自身的应用特点定制，扩展性非常强；<br/>缺点：复杂、部署不够方便；<br/>适合场景：大型集群;<br/><br/>操作：<br/>1、模块存放位置说明<br/>/usr/local/lib/python2.5/site-packages/func/minion/modules/(源码安装位置)<br/>or<br/>/usr/local/python2.5/site-packages/func/minion/modules/(rpm或yum安装默认位置)<br/><br/>2、func-create-module 建模块工具<br/>填写相关项，比较简单就不一一说明了。<br/>#cd /usr/local/lib/python2.5/site-packages/func/minion/modules<br/>#func-create-module<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>Module Name: MyModule<br/>Description: My module for func.<br/>Author: liutiansi<br/>Email: liutiansi@gmail.com<br/><br/>Leave blank to finish.<br/>Method: echo <br/>Method: <br/>Your module is ready to be hacked on. Wrote out to mymodule.py.<br/></div></div><br/><br/>3、编写模块代码<br/>#vi mymodule.py<br/><textarea name="code" class="python" rows="15" cols="100">
#
# Copyright 2010
# liutiansi <liutiansi@gmail.com>
#
# This software may be freely redistributed under the terms of the GNU
# general public license.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

import func_module

class Mymodule(func_module.FuncModule):

&nbsp;&nbsp;&nbsp;&nbsp;# Update these if need be.
&nbsp;&nbsp;&nbsp;&nbsp;version = "0.0.1"
&nbsp;&nbsp;&nbsp;&nbsp;api_version = "0.0.1"
&nbsp;&nbsp;&nbsp;&nbsp;description = "My module for func."

&nbsp;&nbsp;&nbsp;&nbsp;def echo(self):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"""
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TODO: Document me ...
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"""
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pass
</textarea><br/>系统已经帮我们自动生成了一些初始化代码，只需在此基础上做修改就可以了。如简单根据我们指定的条数返回最新系统日志,修改后的代码如下：<br/><textarea name="code" class="python" rows="15" cols="100">
#
# Copyright 2010
# liutiansi <liutiansi@gmail.com>
#
# This software may be freely redistributed under the terms of the GNU
# general public license.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

import func_module
from func.minion import sub_process

class Mymodule(func_module.FuncModule):

&nbsp;&nbsp;&nbsp;&nbsp;# Update these if need be.
&nbsp;&nbsp;&nbsp;&nbsp;version = "0.0.1"
&nbsp;&nbsp;&nbsp;&nbsp;api_version = "0.0.1"
&nbsp;&nbsp;&nbsp;&nbsp;description = "My module for func."

&nbsp;&nbsp;&nbsp;&nbsp;def echo(self,vcount):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"""
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TODO: Document me ...
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"""
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command="tail -n "+str(vcount)+" /var/log/messages"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmdref = sub_process.Popen(command, stdout=sub_process.PIPE,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stderr=sub_process.PIPE, shell=True,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; close_fds=True)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data = cmdref.communicate()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return (cmdref.returncode, data[0], data[1])
</textarea><br/>4、编写模块分发功能<br/>＃cd ~<br/>#vi RsyncModule.py<br/><textarea name="code" class="python" rows="15" cols="100">
#!/usr/local/bin/python

import sys

import func.overlord.client as fc
import xmlrpclib

module = sys.argv[1]
pythonmodulepath="/usr/local/lib/python2.5/site-packages/func/minion/modules/"
client = fc.Client("*")

fb&nbsp;&nbsp; = file(pythonmodulepath+module, "r").read()
data = xmlrpclib.Binary(fb)

#同步模块
print client.copyfile.copyfile(pythonmodulepath+ module,data)

#重启func服务
print client.command.run("/etc/init.d/funcd restart")
</textarea><br/>＃python RsyncModule.py mymodule.py<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>&#123;'NN-server1': 1&#125;<br/>&#123;'NN-server1': [0, 'Stopping func daemon: &#92;nStarting func daemon: &#92;n', '']&#125;<br/>................<br/></div></div><br/>5、模块调用<br/>func -t 10 "*" call mymodule echo 10<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>&#123;'NN-server1': [0,<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'May 30 04:02:06 SN2010-04-020 syslogd 1.4.1: restart.&#92;n',<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '']&#125;<br/></div></div><br/><br/>大功告成！<br/><br/>如大家有什么疑问或感兴趣的话题可以通过weibo与我交流：<a href="http://t.qq.com/yorkoliu" target="_blank">http://t.qq.com/yorkoliu</a><br/>Tags - <a href="https://blog.liuts.com/tags/func/" rel="tag">func</a> , <a href="https://blog.liuts.com/tags/%25E6%25A8%25A1%25E5%259D%2597/" rel="tag">模块</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/186/</link>
<title><![CDATA[部署Func/Certmaster平台[原创]]]></title> 
<author>刘天斯 &lt;liutiansi@gmail.com&gt;</author>
<category><![CDATA[Func]]></category>
<pubDate>Wed, 10 Mar 2010 03:40:19 +0000</pubDate> 
<guid>https://blog.liuts.com/post/186/</guid> 
<description>
<![CDATA[ 
	<strong>Func简介</strong><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Func是由红帽子公司以Fedora平台统一网络控制器 Func（Fedora Unified Network Controller https://fedorahosted.org/func），目的是为了解决这一系列统一管理监控问题而设计开发的系统管理基础框架。 它是一个能有效的简化我们多服务器系统管理工作的工具，它很容易学习、很容易使用、也很容易被扩展，它功能强大而我们只需要非常非常少的配置和维护。<br/>&nbsp;&nbsp;&nbsp;&nbsp;Func分为master及slave两部分，master为主控端，slave为被控端。以下为两部分的安装配置说明<br/>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://blog.liuts.com/post/121/" target="_blank">FUNC模块学习笔记</a><br/>========================Func 2.5版本安装文档[Master]=========================<br/><strong><span style="color: #DC143C;">环境要求</span></strong><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>Linux2.6内核<br/>python2.5或以上(建议源码安装，系统自带的python2.3、2.4对func支持不好)<br/></div></div><br/><br/><strong>下载软件包</strong><br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>wget http://people.fedoraproject.org/~alikins/files/certmaster/certmaster-0.25.tar.gz<br/>wget http://people.fedoraproject.org/~alikins/files/func/func-0.25.tar.gz<br/>wget http://ovh.dl.sourceforge.net/sourceforge/pyopenssl/pyOpenSSL-0.9.tar.gz<br/></div></div><br/><strong>安装</strong><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>tar -zxvf pyOpenSSL-0.9.tar.gz<br/>cd pyOpenSSL-0.9<br/>/usr/local/bin/python setup.py install<br/><br/>tar -zxvf certmaster-0.25.tar.gz<br/>cd certmaster-0.25<br/>/usr/local/bin/python setup.py install<br/><br/>tar -zxvf func-0.25.tar.gz<br/>cd func-0.25<br/>/usr/local/bin/python setup.py install安装<br/><br/>ln -s /usr/local/bin/certmaster /usr/bin/certmaster<br/>ln -s /usr/local/bin/certmaster-request /usr/bin/certmaster-request<br/>ln -s /usr/local/bin/certmaster-ca /usr/bin/certmaster-ca<br/>ln -s /usr/local/bin/certmaster-sync /usr/bin/certmaster-sync<br/><br/>ln -s /usr/local/bin/funcd /usr/bin/funcd<br/>ln -s /usr/local/bin/func /usr/bin/func<br/>ln -s /usr/local/bin/func-create-module /usr/bin/func-create-module<br/>ln -s /usr/local/bin/func-inventory /usr/bin/func-inventory<br/>ln -s /usr/local/bin/func-transmit /usr/bin/func-transmit<br/>ln -s /usr/local/bin/func-build-map /usr/bin/func-build-map<br/></div></div><br/><strong>配置</strong><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>vi /etc/certmaster/certmaster.conf<br/>[main]<br/>autosign = no<br/>listen_addr =<br/><br/>#证书交换通讯端口<br/>listen_port = 1998<br/><br/>cadir = /etc/pki/certmaster/ca<br/>cert_dir = /etc/pki/certmaster<br/>certroot = /var/lib/certmaster/certmaster/certs<br/>csrroot = /var/lib/certmaster/certmaster/csrs<br/>cert_extension = cert<br/>sync_certs = False<br/><br/>vi /etc/func/minion.conf<br/>[main]<br/>log_level = DEBUG<br/>acl_dir = /etc/func/minion-acl.d<br/><br/>listen_addr =<br/><br/>#(Func通讯端口<br/>listen_port = 1999<br/>minion_name =<br/></div></div><br/><br/><strong>启动服务</strong><br/>service certmaster start<br/><br/><br/>=============================2.5版本安装文档[slave]=========================<br/><strong>下载软件包</strong><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>wget http://people.fedoraproject.org/~alikins/files/certmaster/certmaster-0.25.tar.gz<br/>wget http://people.fedoraproject.org/~alikins/files/func/func-0.25.tar.gz<br/>wget http://ovh.dl.sourceforge.net/sourceforge/pyopenssl/pyOpenSSL-0.9.tar.gz<br/></div></div><br/><strong>安装</strong><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>tar -zxvf pyOpenSSL-0.9.tar.gz<br/>cd pyOpenSSL-0.9<br/>/usr/local/bin/python setup.py install<br/><br/>tar -zxvf certmaster-0.25.tar.gz<br/>cd certmaster-0.25<br/>/usr/local/bin/python setup.py install<br/><br/>tar -zxvf func-0.25.tar.gz<br/>cd func-0.25<br/>/usr/local/bin/python setup.py install<br/><br/>ln -s /usr/local/bin/certmaster /usr/bin/certmaster<br/>ln -s /usr/local/bin/funcd /usr/bin/funcd<br/></div></div><br/><strong>配置</strong><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>vi /etc/certmaster/certmaster.conf<br/>[main]<br/>autosign = no<br/>listen_addr =<br/><br/>#与master端口保持一致<br/>listen_port = 1998<br/>cadir = /etc/pki/certmaster/ca<br/>cert_dir = /etc/pki/certmaster<br/>certroot = /var/lib/certmaster/certmaster/certs<br/>csrroot = /var/lib/certmaster/certmaster/csrs<br/>cert_extension = cert<br/>sync_certs = False<br/><br/>vi /etc/certmaster/minion.conf<br/>[main]<br/>certmaster = func.master.server.com<br/><br/>#与master端口保持一致<br/>certmaster_port = 1998<br/>log_level = DEBUG<br/>cert_dir = /etc/pki/certmaster<br/><br/>vi /etc/func/minion.conf<br/>[main]<br/>log_level = DEBUG<br/>acl_dir = /etc/func/minion-acl.d<br/><br/>listen_addr =<br/><br/>#与master端口保持一致<br/>listen_port = 1999<br/><br/>#slave主机名<br/>minion_name =NN2007-08-048<br/></div></div><br/><strong>启动服务</strong><br/>/sbin/chkconfig --level 345 certmaster on<br/>/sbin/service certmaster start<br/><br/>/sbin/chkconfig --level 345 funcd on<br/>/sbin/service funcd start<br/><br/>*安装完毕后一定要重启服务器操作系统，不然服务器端有时看不到该主机的证书请求。<br/><br/>=============================Master端常用操作==============================<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>func "*" call --forks="5" command run "date" 启用5个进程来执行date命令。<br/>certmaster-ca --list 可以查看未签名的计算机名。<br/>certmaster-ca --sign NN2004-02-008 对slave服务器进行签名(证书交换)。<br/>certmaster-ca --sign `certmaster-ca --list ` 如证书请求的服务器比较多，可以这样一下子搞定。<br/>certmaster-ca -c NN2004-02-008 删除该主机证书<br/></div></div><br/><br/>=============================防火墙配置==============================<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>Slave主机需对master开放1998(certmaster)、1999(func)端口<br/>master需对所有Slave主机开放1998(certmaster)端口<br/></div></div><br/><br/>如大家有什么疑问或感兴趣的话题可以通过weibo与我交流：<a href="http://t.qq.com/yorkoliu" target="_blank">http://t.qq.com/yorkoliu</a><br/>Tags - <a href="https://blog.liuts.com/tags/func/" rel="tag">func</a> , <a href="https://blog.liuts.com/tags/certmaster/" rel="tag">certmaster</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/121/</link>
<title><![CDATA[FUNC模块学习笔记[原创]]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[Func]]></category>
<pubDate>Thu, 22 May 2008 13:23:42 +0000</pubDate> 
<guid>https://blog.liuts.com/post/121/</guid> 
<description>
<![CDATA[ 
	* BridgeModule -- Allows for simple network bridge management<br/>-------------------------------------------------------------<br/>功能：操作网桥<br/>方法：<br/>list() Returns a dictionary containing the bridges and their connected interfaces.<br/>add_bridge(brname) Creates a new bridge named brname.<br/>add_interface(brname, ifname) Adds interface ifname to bridge brname.<br/>delete_bridge(brname) Deletes bridge brname.<br/>delete_interface(brname, ifname) Removes interface ifname from bridge brname.<br/>add_promisc_bridge(brname, ifname) Creates a new bridge brname, attaches interface ifname to it and sets the MAC address of the connected interface to FE:FF:FF:FF:FF:FF, so traffic can flow freely through the bridge. This is required for use with Xen.<br/>up_bridge(brname) Marks bridge brname and all it's connected interfaces as up.<br/>down_bridge(brname) Marks bridge brname and all it's connected interfaces as down<br/>-------------------------------------------------------------<br/><br/><br/>* CertMasterModule -- For power users out there, allows manipulating the certmaster from Func's API.<br/>-------------------------------------------------------------<br/>功能：Certmaster Module<br/>方法：<br/>添加/删除Certmaster客户端<br/>get_hosts_to_sign(list_of_hosts)<br/>sign_hosts(list_of_hosts)<br/>cleanup_hosts(list_of_hosts)<br/>-------------------------------------------------------------<br/><br/><br/>* CommandModule -- Running Arbitrary Commands Like SSH Does<br/>-------------------------------------------------------------<br/>功能：命令行模板,在客户端运行命令行。<br/>方法：<br/>#exists方法：检测/bin/foo文件是否存在<br/>func target.example.org call command exists /bin/foo<br/><br/>#运行该命令<br/>func target.example.org call command run "/bin/foo arg1 arg2 arg3"<br/>-------------------------------------------------------------<br/><br/><br/>* CopyFileModule -- Copyfile File Copying and Checksumming<br/>-------------------------------------------------------------<br/>功能：文件同步模板,同步指定文件到客户端<br/>方法：<br/>func target.example.org copyfile -f localfile --remotepath /remotepath/filename<br/><br/>返回值说明：<br/># -1 = problem file was not copied<br/># 1 = file was copied<br/># 0 = file was not copied b/c file is unchanged<br/>-------------------------------------------------------------<br/><br/><br/>* FileTrackerModule -- tracks file changes, for use with FuncInventory<br/>-------------------------------------------------------------<br/>功能：跟踪模块，为了安全考虑，跟踪一些重要的文件的情况。<br/>方法：<br/>第一步,添加跟踪的文件或目录<br/># func "*" call filetracker track /etc/passwd 1 <br/># func "dbservers*" call filetracker track /etc/foo <br/># func "webservers*" call filetracker track /tmp/bar <br/># func "*" call filetrack untrack /etc/bar <br/># func "*" call filetrack track "/etc/*" 1 <br/>1代表跟踪文件的更新变化。<br/><br/>第二步，查看跟踪结果<br/>func "target.example.org" call filetracker inventory<br/>-------------------------------------------------------------<br/><br/><br/>* JBossModule -- monitoring and control jboss instances<br/>-------------------------------------------------------------<br/>功能：监控与操作JBOSS实例<br/>方法：(略)<br/>-------------------------------------------------------------<br/><br/><br/>* IPtablesModule -- iptables management<br/>-------------------------------------------------------------<br/>功能：IPtables管理模板<br/>方法：(略)<br/>-------------------------------------------------------------<br/><br/><br/>* HardwareModule -- Hardware Profilling<br/>-------------------------------------------------------------<br/>功能：硬件信息模板,显示CPU、驱动等等。<br/>方法：<br/>func target.example.org call hardware info<br/>-------------------------------------------------------------<br/><br/><br/>* MountModule -- mount, unmount, and query mounted resources<br/>-------------------------------------------------------------<br/>功能：挂载模板，挂载/unmount分区模板<br/>方法：<br/>func target.example.org call mount /dev/device /path/to/dir<br/>-------------------------------------------------------------<br/><br/><br/>* NagiosCheck -- be able to call Nagios plugins and get their results, without needing to install nagios. Works with any plugin<br/>-------------------------------------------------------------<br/>功能：Nagios检查模块<br/>方法：(略)<br/>-------------------------------------------------------------<br/><br/><br/>* NetappModule -- Administer Netapp filers<br/>-------------------------------------------------------------<br/>功能：NetApp模块<br/>方法：(略)<br/>-------------------------------------------------------------<br/><br/>* NetworkTest -- Test out network stuff.<br/>-------------------------------------------------------------<br/>功能：网络测试模块<br/>方法：<br/>PING<br/>#数字2为ping的次数<br/>func tachikoman call networktest ping redhat.com -c 2<br/><br/>NETSTAT<br/>func tachikoman call networktest netstat<br/><br/>traceroute<br/>func tachikoman call networktest traceroute redhat.com -m 10<br/><br/>dig<br/>func tachikoman call networktest dig redhat.com<br/>-------------------------------------------------------------<br/><br/><br/>* ProcessModule -- Process Info, memory usage, and Killing<br/>-------------------------------------------------------------<br/>功能：进程管理模块<br/>方法：<br/>#ps -aux等价<br/>func target.example.org call process info "aux"<br/><br/>#显示全部进程使用内存情况，返回格式：[[Private, Shared, Total RAM used, Program], ... ]<br/>func target.example.org call process mem<br/><br/>#pkill thunderbird进程，返回整形<br/>func "*" call process pkill thunderbird -9<br/><br/>#kill firefox-bin进程，返回整形<br/>func "*" call process kill firefox-bin SIGHUP<br/><br/>-------------------------------------------------------------<br/><br/><br/>* ServiceModule -- Service Status and Control<br/>-------------------------------------------------------------<br/>功能：服务管理模块<br/>方法：<br/>func target.example.org call service start httpd<br/>-------------------------------------------------------------<br/><br/><br/>* SysctlModule -- Configure kernel parameters at runtime<br/>-------------------------------------------------------------<br/>功能：配置内核参数模块<br/>方法：<br/>func "*" call sysctl list<br/>func "*" call sysctl get <br/>func "*" call sysctl set <br/><br/>参数可以是：<br/>'kernel.sched_latency_ns = 20000000',<br/>'kernel.sched_wakeup_granularity_ns = 1000000',<br/>'kernel.sched_batch_wakeup_granularity_ns = 25000000',<br/>'kernel.sched_stat_granularity_ns = 0',<br/>'kernel.sched_runtime_limit_ns = 20000000',<br/>'kernel.sched_child_runs_first = 1',<br/>'kernel.sched_features = 21',<br/>'kernel.sched_compat_yield = 0',<br/>'kernel.panic = 0',<br/>'kernel.exec-shield = 1',<br/>-------------------------------------------------------------<br/><br/><br/>* RebootModule -- Reboot your system<br/>-------------------------------------------------------------<br/>功能：重启服务器模块<br/>方法：<br/>func target.example.org reboot.reboot<br/>func target.example.org reboot.reboot now "Going down for a reboot"<br/>返回值：<br/>Integer. 0 == success.<br/>-------------------------------------------------------------<br/><br/><br/>* RpmModule -- for any distro that supports RPM, lists installed packages<br/>-------------------------------------------------------------<br/>功能：RPM管理模板<br/>方法：<br/>#返回一个已安装包的一个列表<br/>func target.example.org call rpms inventory<br/>-------------------------------------------------------------<br/><br/><br/>* SmartModule -- Disk Smart (Hard Drive) Status<br/>-------------------------------------------------------------<br/>功能：Smart管理模板<br/>方法：<br/>#返回smart信息<br/>func target.example.org call smart info<br/>-------------------------------------------------------------<br/><br/><br/>* UserModule -- we still need to implement this :)<br/>-------------------------------------------------------------<br/>功能：用户管理模板<br/>方法：(略)<br/>-------------------------------------------------------------<br/><br/><br/>* VirtModule -- works with koan, KVM, Xen, etc<br/>-------------------------------------------------------------<br/>功能：Virt管理模板<br/>方法：(略)<br/>-------------------------------------------------------------<br/><br/><br/>* VlanModule -- Simple VLAN management<br/>-------------------------------------------------------------<br/>功能：Vlan管理模板<br/>方法：(略)<br/>-------------------------------------------------------------<br/><br/><br/>* YumModule -- for any distro that is yum based, installs packages<br/>-------------------------------------------------------------<br/>功能：yum管理模板<br/>方法：<br/>func target.example.org call yumcmd update<br/>Tags - <a href="https://blog.liuts.com/tags/func/" rel="tag">func</a> , <a href="https://blog.liuts.com/tags/%25E5%25AD%25A6%25E4%25B9%25A0%25E7%25AC%2594%25E8%25AE%25B0/" rel="tag">学习笔记</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/120/</link>
<title><![CDATA[终于找到问题了(about func)]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[Func]]></category>
<pubDate>Thu, 22 May 2008 13:21:41 +0000</pubDate> 
<guid>https://blog.liuts.com/post/120/</guid> 
<description>
<![CDATA[ 
	<strong>一、故障现象</strong><br/>1、在客户端安装好func及certmaster，配好certmaster参数。<br/>2、service funcd start，端口及进程都起来了。<br/>3、在certmaster server 运行certmaster-ca --list死活看不到客户端的主机名。<br/><strong>排查过程</strong><br/>1、将certmaster的主机名换成IP，无效。<br/>2、更新客户端的func及certmaster版本，无效。<br/>3、运行/usr/bin/certmaster-request，提示：socket.error: (111, 'Connection refused')，将certmaster修改成localhost就正常了。原因可以就在这里，因为certmaster是双向的，发现在/etc/hosts中有主机名指向127.0.0.1，此时连接不上certmaster server了。将/etc/hosts中的主机名删除，再用/usr/bin/certmaster-request来测试连接，成功！！在certmaster也能看到主机了，大功告成。 <br/><br/><strong>二、故障现象</strong><br/>#/usr/local/bin/certmaster-request 被控端证书请求<br/>certificate does not match key (run certmaster-ca --clean first?)<br/><br/><strong>排查过程</strong><br/>1、删除/etc/pki/certmaster/证书文件再试，无效<br/>2、分别重启certmaster、funcd服务，无效<br/>3、删除服务器证书文件.cert后再请求正常。<br/>原因为主机名称发生变更时服务器端certmaster-ca -c "servername"没有成功删除.cert文件导致。<br/><br/><strong>二、后续问题</strong><br/>1、ImportError: No module named dbm (NetSeek提供)<br/>解决：<br/>yum -y install gdbm gdbm-devel<br/>Tags - <a href="https://blog.liuts.com/tags/func/" rel="tag">func</a>
]]>
</description>
</item>
</channel>
</rss>