cfengine的基础安装和测试

cfengine 的基础安装和测试
 
cfengine 是一个功能强大的自动化系统管理工具 , 更详细的信息可以访问其主页
[url]http://www.cfengine.org/[/url]
中文主页
[url]http://www.cfengine.org/china.phtml[/url]
网站里面有丰富的文档可以参考 . 现在我就来简单安装和测试以下 .
按照其安装文档 , cfengine 需要 openssl Berkely DB, 一般系统自带的就满足要求了 . 按照文档采用源码方式安装 ,make 报错 , 所以估计是没装 Berkely DB 的原因 , 所以源码安装了 Berkely DB, 路径为 /usr/local/BerkeleyDB.4.6
安装 cfengine 在执行 configure 的时候 , 运行到一半停止了 , 显示
checking for BerkeleyDB location in default... /usr/local/BerkeleyDB.4.6
checking Berkeley DB Version... configure: error: This release of cfengine requires BerkeleyDB 3.2 or later
搜索到的原因如下
The linker might be the wrong place to look for the source of this error. The configure snippet builds a little program and checks the values of the DB_VERSION* macros from db.h .. So even if you have a newish bdb installed someplace, this will fail if '#include <db.h> ' either a) pulls in an old version from /usr/include or b) can't find your version at all.  If you installed the 4.5 specifically to fix this, remove it and install the 'db4-devel' rpm for your update level and architecture. The regular 'db4' rpm doesnt include the header file
安装 db4-devel openssl rpm , 再运行 cfengine configure 就通过 .
 
看到别人的建议里面有这段话
You might be making this harder that it has to be.  Is there any
reason you don't use the already installed berkely db on your RHEL4
system (currently db4-4.2.52-7.1)?
原来系统自带的 db4 的包就是 berkeley DB 的包 . 系统是默认就安装好了的 .
看了很多的建议 , 都说装 rpm 版的 cfengine, 不会有这些问题 , 很简单 . 所以改用 rpm 的装
下载地址
[url]http://dag.wieers.com/rpm/packages/cfengine/[/url]
redhat 9 系统的
[url]http://dag.wieers.com/rpm/packages/cfengine/cfengine-2.2.2-1.rh9.rf.i386.rpm[/url]
rhel 5 系统的
[url]http://dag.wieers.com/rpm/packages/cfengine/cfengine-2.2.2-1.el5.rf.i386.rpm[/url]
 
整个的安装过程确实没任何问题
所有的可执行程序都在 /usr/sbin ,
[root@server1 cfengine]# whereis cfagent
cfagent: /usr/sbin/cfagent /usr/share/man/man8/cfagent.8.gz
所有的配置文件路径 , /var/cfengine
[root@server1 cfengine-2.2.1]# cd /var/cfengine/
[root@server1 cfengine]# ls
bin  inputs  modules  ppkeys  randseed  rpc_in  rpc_out  state
创建一个配置文件
[root@server1 cfengine]# cd inputs/
[root@server1 inputs]# vi cfagent.conf
control:
        actionsequence = ( shellcommands )
shellcommands:
        "/bin/echo Danger, Will Robison!"
 
以详细方式执行
[root@server1 inputs]# cfagent -f ./cfagent.conf -v
Reference time set to Thu Oct 18 16:02:42 2007
GNU Configuration Engine -
2.2.2
Free Software Foundation 1994-
Donated by Mark Burgess, Faculty of Engineering,
Oslo University College , Norway
------------------------------------------------------------------------
Host name is: server1
Operating System Type is linux
Operating System Release is 2.4.20-8smp
Architecture = i686
Using internal soft-class linux for host linux
The time is now Thu Oct 18 16:02:42 2007
------------------------------------------------------------------------
Additional hard class defined as: 32_bit
Additional hard class defined as: linux_2_4_20_8smp
Additional hard class defined as: linux_i686
Additional hard class defined as: linux_i686_2_4_20_8smp
Additional hard class defined as: linux_i686_2_4_20_8smp__1_SMP_Thu_Mar_13_17_45_54_EST_2003
GNU autoconf class from compile time: compiled_on_linux_gnu
Address given by nameserver: 127.0.0.1
Interface 1: lo
Interface 2: eth0
Interface 3: eth0:0
Trying to locate my IPv6 address
Looking for environment from cfenvd...
Unable to detect environment from cfenvd
cfengine:server1: No preconfiguration file
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
 * (Changing context state to: main) *
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
---------------------------------------------------------------------
Loading persistent classes
---------------------------------------------------------------------
---------------------------------------------------------------------
Loaded persistent memory
---------------------------------------------------------------------
Looking for environment from cfenvd...
Unable to detect environment from cfenvd
Manually overidden relative path (./cfagent.conf)
Looking for an input file ./cfagent.conf
Cfengine input file had no explicit version string
Finished with ./cfagent.conf
Defined Classes = ( 192_168_0 192_168_1 32_bit Day18 Hr16 Hr16_Q1 Min00_05 Min02 October Q1 Thursday Yr2007 any cfengine_2 cfengine_2_2 cfengine_2_2_2 compiled_on_linux_gnu i686 ipv4_192 ipv4_192_168 ipv4_192_168_0 ipv4_192_168_0_111 ipv4_192_168_1 ipv4_192_168_1_112 linux linux_2_4_20_8smp linux_i686 linux_i686_2_4_20_8smp linux_i686_2_4_20_8smp__1_SMP_Thu_Mar_13_17_45_54_EST_2003 localhost localhost_localdomain net_iface_eth0 net_iface_eth0_0 net_iface_lo redhat redhat_9 server1 undefined_domain )
Negated Classes = ( )
Installable classes = ( no_default_route )
Global expiry time for locks: 120 minutes
Global anti-spam elapse time: 1 minutes
Extensions which should not be directories = ( )
Suspicious filenames to be warned about = ( )
Accepted domain name: undefined.domain
LogDirectory = /var/cfengine
Loaded /var/cfengine/ppkeys/localhost.priv
Loaded /var/cfengine/ppkeys/localhost.pub
Checksum database is /var/cfengine/checksum_digests.db
Default binary server seems to be server1
Reference time set to Thu Oct 18 16:02:42 2007
*********************************************************************
 Main Tree Sched: shellcommands pass 1 @ Thu Oct 18 16:02:42 2007
*********************************************************************
cfengine:server1:
Executing script /bin/echo Danger, Will Robison!...(timeout=0,uid=-1,gid=-1)
(Setting umask to 77)
cfengine:server1:/bin/echo Dange: Danger, Will Robison!
cfengine:server1: Finished script /bin/echo Danger, Will Robison!
Performance(Exec(/bin/echo Danger, Will Robison!)): time=0.0206 secs, av=0.0206 +/- 0.0316
---------------------------------------------------------------------
Alerts
---------------------------------------------------------------------
++++++++++++++++++++++++++++++++++++++++
Summary of objects involved
++++++++++++++++++++++++++++++++++++++++
    global
    main
cfengine:server1: Outcome of version (not specified): Promises still kept 0%, Promises repaired 100%, Promises not kept 0%
简单方式执行
[root@server1 inputs]# cfagent -f ./cfagent.conf
cfengine:server1:/bin/echo Dange: Danger, Will Robison!
还有一种是模拟执行 , 也就是不真的执行 , 但是输出信息 (-n 参数表示不真实执行 )
cfagent -v -f ./cfagent.conf -n
到上层目录查看 , 发现多了很多文件
[root@server1 inputs]# cd ..
[root@server1 cfengine]# ls
bin            cfengine_lock_db         inputs   performance.db  randseed  rpc_out
cf_classes.db  cfengine.server1.runlog  modules  ppkeys          rpc_in    state
其中有一个是日志文件 , 查看内容
[root@server1 cfengine]# less cfengine.server1.runlog
Thu Oct 18 16:02:42 2007:Lock removed normally :pid=28322:lock.__cfagent_conf.server1.shellcommand._bin_echo_Danger__Will_Robison__4206:
Thu Oct 18 16:04:05 2007:Lock removed normally :pid=28410:lock.__cfagent_conf.server1.shellcommand._bin_echo_Danger__Will_Robison__4206:
state 目录下产生了一些文件 , 其中一个是类文件 , 程序会自动评估出这个主机所属于的
[root@server1 cfengine]# less state/allclasses
192_168_0
192_168_1
32_bit
Day18
Hr16
Hr16_Q1
Min00_05
Min04
October
Q1
Thursday
Yr2007
any
cfengine_2
cfengine_2_2
cfengine_2_2_2
compiled_on_linux_gnu
i686
ipv4_192
ipv4_192_168
ipv4_192_168_0
ipv4_192_168_0_111
ipv4_192_168_1
ipv4_192_168_1_112
linux
linux_2_4_20_8smp
linux_i686
linux_i686_2_4_20_8smp
linux_i686_2_4_20_8smp__1_SMP_Thu_Mar_13_17_45_54_EST_2003
localhost
localhost_localdomain
net_iface_eth0
net_iface_eth0_0
net_iface_lo
redhat
redhat_9
server1
undefined_domain
 
rpm 安装以后 , 自动安装了三个服务 , 并且是开机启动的 , 执行 chkconfig --list|grep cf
cfenvd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
cfexecd         0:off   1:off   2:on    3:on    4:on    5:on    6:off
cfservd         0:off   1:off   2:on    3:on    4:on    5:on    6:off
其功能如下
cfservd   文件共享和远程激活
A file server and remote activation service (optional).
cfexecd   定时执行
A scheduling and report service (recommended).
cfenvd
An anomaly detection service (strongly recommended).
查看当前的进程
[root@dbpi inputs]# ps -ef|grep cf
root      1115     1  0 08:25 ?        00:00:00 cfservd
root      1127     1  0 08:25 ?        00:00:00 cfenvd
root      1146     1  0 08:26 ?        00:00:00 cfexecd
 
默认是每个小时整点执行一次 , 可以在日志中看到运行的情况 less cfengine.server1.runlog
Mon Oct 22 10:00:33 2007:Lock removed normally :pid=4003:lock..server1.cfd.exec_2967:
Mon Oct 22 10:00:34 2007:Lock removed normally :pid=4207:lock.cfagent_conf.server1.shellcommand._bin_echo_Danger__Will_Robison__4206:
 
 
 
 

你可能感兴趣的:(职场,自动,休闲,系统管理,Cfengine)