2011年使用2大开源软件:
puppet
zabbix
Tagged: puppet RSS
-
bixuan
-
bixuan
对话 UNIX: 高效管理大量计算机
云在根本上是由硬件和软件组成的,这些组件需要经常细心地维护。出现故障的硬件需要修理或更换;软件需要应用补丁、更新和升级;必须根据需求和潜在的安全威胁提前配置系统。应用程序开发人员可能觉得计算云很方便、很灵活,但是云管理员要应对艰巨的任务。
不只是云的管理有这些问题。LAN(小型服务器群)和计算集群也有同样的系统管理难题。在管理大量计算机时,Secure Shell (ssh)、scp 和 sftp 等常用工具用起来非常麻烦。本期 对话 UNIX 讨论从命令行有效地管理大量计算机的技术,先从少量系统开始,然后扩大规模。更多见:http://www.ibm.com/developerworks/cn/aix/library/au-spunix_remoteserver/index.html?ca=drs-
-
bixuan
如何检查puppet的class文件语法:
puppet –parseonly –ignoreimport
#e.g. ruby-server.pp
err: Could not parse for environment development: Syntax error at ‘;’; expected ‘]’
at /etc/puppet/manifests/classes/ruby-server.pp:2 -
bixuan
puppet的一些例子:
-
bixuan
puppet终于启用了,先在小范围使用,熟练了再推广~
-
bixuan
puppet tidyt用法
先占位置 -
bixuan
puppet mount用法
先占位置 -
bixuan
puppet 主机(host)用法:
语法:host { 'xx.com': alias => ['absent'], ip => 'absent', target => '', ensure => 'absent' }如果忘了host的语法,那么可以执行ralsh获取,比如:
ralsh host xx.com host:表示类别,其他诸如file,cron xx.com:就是host里的主机头
ip
主机的IP地址,ipv4或ipv6name
主机名称
资源类型的命名变量ensure
确定该主机是否启用,有效值present 和 absent
ensure => ‘present’:表示启用在该条记录,如果没有则添加
ensure => ‘absent’:表示去启用该条记录,如果已经存在则会删除target
这个用法不清楚例子:
host { 'test.ourlinux.net': ip => '192.168.1.121', alias=> [ "1.ourlinux.net", "2.ourlinux.net" ], ensure => 'present', #ensure => 'absent', }查看/etc/hosts结果增加了如下一行:
192.168.1.121 test.ourlinux.net 1.ourlinux.net 2.ourlinux.net -
bixuan
puppet 定义(definitions)用法:
定义使用define关键词建立,支持参数,但不支持继承。可以将定义想象为一个可用参数多次调用的配置段。
当设计为重复调用时,不包含资源,仅有一个实例,象包或者服务。
使用关键词define,指定定义名,然后是由括号包围的参数列表,用花括号封闭定义段。先占位置
-
bixuan
puppet 安装
1、服务端安装
需要安装puppet-server,当然相关ruby的依赖包也会自动安装:yum -y install puppet-server puppet
2、客户端安装
只要安装puppet即可:yum -y install puppet
3、编译安装
正在测试,比较麻烦以后补上~ -
bixuan
puppet 组和用户(group/user)用法:
user常见语法
user { 'bixuan': home => '/home/bixuan', shell => '/bin/bash', uid => '500', comment => 'test', gid => '100', groups => ['users'], ensure => 'absent', #absent:存在则删除;present:不存在则闯进 }user的基本属性:
name: OS specified limits apply. (namevar)
shell: 用户的shell类型,比如:/bin/bash
uid: 用户uid
comment: 用户信息描述
ensure: 设置用户的基本状态资源. 有2个值:absent(不启用,设置此值时会删除用户), present(启用该用户,不存在则自动创建).
gid: 用户的所属的基本组。可以指定数值或的名字。
groups: 用户附属组,多个组需要用数组来定义。
home: 用户目录
managehome: Whether to manage the home directory when managing the user. Valid values are
true, false. -
bixuan
-
bixuan
puppet 服务(service)用法:
service常见语法
service {‘sshd’:
enable => true,
ensure => running,
hasstatus => true,
hasrestart => true,
}
service的基本属性:name: The name of the service as understood on the underlying services subsystem. (namevar) enable: If a service should be started at boot. Can be true or false. ensure: If the resource should currently be running. Can be true, false, running, or stopped. hasrestart: Specifies that your service has a restart command. Can be true or false. hasstatus: Specifies that your service has a status command. Can be true or false. pattern: The pattern to search for in the process table. restart: Specify a restart command. start: Specify a start command. status: Specify a status command. stop: Specify a stop command.
-
bixuan
puppet 模板(template)用法:
先占位置~ -
bixuan
puppet 文件(file)用法:
file常见语法
file {"/tmp/bixuan/etc": ensure => file, source =>"puppet://$puppetserver/files/etc", owner =>"root", group =>"root", mode =>"744" }file的基本属性:
path: Specifies the target location for file. (namevar) ensure: Accepts absent, present, file, and directory. Any other value will be treated as a symlink. owner: 文件所属用户. group: 文件所属组. mode: 文件权限,比如:755 content: 指定文件的内容,作为字符串返回。 source: 指定源文件 force: Force replacement of directories with a link. Valid values (true, false). ignore: 忽略指定文件,比如.svn, .git. Omits files matching specified patterns during recursion (Ex: .svn, .git). recurse: 递归检索文件,同步目录时设为true purge: 清除已删除的文件。Whether or not to purge unmanaged file resources within a directory. Valid values (true,false)例子
1、同步目录:file {"/tmp/bixuan/etc": source =>"puppet://$puppetserver/files/etc", recurse =>"true", #递归检索文件,同步目录时设为true owner =>"root", group =>"root", mode =>"744", purge =>"true", #保持和source完全一致。类似rsync的 --delete参数 }2、同步文件:
file { "/etc/sysctl.conf": source => "puppet://$puppetserver/files/etc/sysctl.conf", owner => "root", group => "root", mode => 0644, }操作文件往往和命令相关联,具体查看:puppet exec用法
网络帅哥 11:54 on 2010 年 12 月 12 日 链接地址
不错不错 解决我的问题了 ^_^