*** 作系统:CentOS-6.5-x86_64
木偶3.7.3
木偶大师:master.fisteam2.com
傀儡客户端:node1-5.fisteam2.com
Puppet要求所有机器都有一个完整的域名(FQDN)。如果没有DNS服务器提供域名,可以在两台机器上设置主机名(注意要在安装Puppet之前设置主机名,因为安装Puppet时主机名会被写入证书,客户端和服务器通信需要用到)。因为我配置了DNS,所以不需要换主机。如果没有,我需要更改主机文件的名称。
1。关闭selinux和iptables,设置ntp
采用CentOS-6.5-x86_64.iso进行最小安装。
关闭selinux
[root@master ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=enforcing # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted [root@master ~]# sed -i '/SELINUX/ s/enforcing/disabled/g' /etc/selinux/config [root@master ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted [root@master ~]# setenforce 0停止iptables
[root@node1 ~]# chkconfig --list |grep tables ip6tables 0:off 1:off 2:on 3:on 4:on 5:on 6:off iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@node1 ~]# chkconfig ip6tables off [root@node1 ~]# chkconfig iptables off [root@node1 ~]# service ip6tables stop ip6tables: Setting chains to policy ACCEPT: filter [ OK ] ip6tables: Flushing firewall rules: [ OK ] ip6tables: Unloading modules: [ OK ] [root@node1 ~]# service iptables stop iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] [root@node1 ~]#设置ntp
[root@master ~]# ntpdate pool.ntp.org [root@master ~]# chkconfig --list|grep ntp ntpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off ntpdate 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@master ~]# chkconfig ntpd on [root@master ~]# service ntpd start Starting ntpd: [ OK ] [root@master ~]#2。安装puppet服务
puppet不在CentOS的基础源码中,需要加入PuppetLabs提供的官方源码:
在主服务器上安装并启用puppet服务:
[root@master ~]# yum install puppet-server [root@master ~]# chkconfig --list |grep puppet puppet 0:off 1:off 2:off 3:off 4:off 5:off 6:off puppetmaster 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@master ~]# chkconfig puppet on [root@master ~]# service puppetmaster start Starting puppetmaster: [ OK ] [root@master ~]#在客户端上安装puppet客户端
3。配置puppet
对于puppet客户机,修改/etc/puppet/puppet.conf以指定主服务器。
[main] # The Puppet log directory. # The default value is '$vardir/log'. logdir = /var/log/puppet # Where Puppet PID files are kept. # The default value is '$vardir/run'. rundir = /var/run/puppet # Where SSL certificates are kept. # The default value is '$confdir/ssl'. ssldir = $vardir/ssl [agent] # The file in which puppetd stores a list of the classes # associated with the retrieved configuratiion. Can be loaded in# the separate ``puppet`` executable using the ``--loadclasses`` # option. # The default value is '$confdir/classes.txt'. classfile = $vardir/classes.txt # Where puppetd caches the local configuration. An # extension indicating the cache format is added automatically. # The default value is '$confdir/localconfig'. localconfig = $vardir/localconfig server = master.fisteam2.com并重新启动傀儡服务。
[root@node1 ~]# service puppet restart Stopping puppet agent: [ OK ] Starting puppet agent: [ OK ] [root@node1 ~]#4。客户端申请证书
服务器自动颁发证书设置
设置主机自动颁发所有证书。我们只需要在/etc/puppet目录中创建autosign.conf文件。(不需要修改/etc/puppet/puppet.conf文件,因为我的默认autosign.conf文件的位置没有被修改)
这样,来自fisteam2.com机器的所有请求都将被自动签名。
客户端需要向服务器发送请求来管理客户端。这实际上是一个证书颁发过程。第一次运行puppet客户机时,会生成一个SSL证书并发送给Puppet服务器。如果服务器同意管理客户端,它将颁发证书。您可以使用此命令来颁发证书。因为我们已经在客户机上设置了服务器地址,所以我们不需要为服务器寻址。
为了更好的了解当天之后的注册过程和错误,可以添加参数,因为在配置文件
-no-daemon前端输出日志
-verbose输入更详细的日志
-debug更详细的日志,调试错误的时候用
-test表示测试,只需要取一个–test参数。
你可以申请证书。因为我配置了自动证书颁发,所以是直接在服务器端颁发和执行的。
[root@master ~]# puppet cert list --all可以看到所有客户端都已经颁发了证书,前面带“+”的都是成功的。如果没有签名,可以使用。
[root@master ~]# puppet cert --sign node1.localdomain可以看到证书已经颁发
5。在服务器上安装puppet的dashboard
并安装mysql。
优化mysql设置
编辑/etc/my.cnf并在[mysqld]字段中添加最后一行。
[root@master ~]# vim /etc/my.cnf启动Mysql服务
[root@master ~]# service mysqld start [root@master ~]# chkconfig mysqld on [root@master ~]# chkconfig --list |grep mysqld mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off设置mysql密码。我这里用的密码是123456。
[root@master ~]# mysqladmin -u root password '123456'创建仪表板数据库
[root@master ~]# mysql -uroot -p123456 <<EOF > CREATE DATABASE dashboard CHARACTER SET utf8; > CREATE USER 'dashboard'@'localhost' IDENTIFIED BY '123456'; > GRANT ALL PRIVILEGES ON dashboard.* TO 'dashboard'@'localhost'; > FLUSH PRIVILEGES; > EOF [root@master ~]#乘客+阿帕奇+仪表板
这是为了让Apache支持ruby。由于乘客不在centos的官方来源中,所以有必要添加epel的来源。
[root@master ~]# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm [root@master ~]# rpm -ivh epel-release-6-8.noarch.rpm [root@master ~]# yum install mod_passenger puppet-dashboard配置仪表板
[root@master ~]# vim /usr/share/puppet-dashboard/config/database.yml修改时区
[root@master ~]# vim /usr/share/puppet-dashboard/config/environment.rb初始化数据库
[root@master ~]# cd /usr/share/puppet-dashboard/ [root@master puppet-dashboard]# rake RAILS_ENV=production db:migrate配置apache
我们需要集成Passenger和apache。
启动服务
[root@master ~]# service httpd start Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using master.fisteam2.com for ServerName[ OK ] [root@master ~]# chkconfig httpd on [root@master ~]# chkconfig --list | grep httpd httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off配置puppet
使仪表板使用报告。现在默认代理是报表功能启用,所以不需要设置代理,只需要设置服务器端即可。
重新启动puppetmaster服务
[root@master ~]# service puppetmaster restart此时,您可以使用http://ip直接访问puppetDashboard。
导入报告
[root@master puppet-dashboard]# cd /usr/share/puppet-dashboard/ [root@master puppet-dashboard]# rake RAILS_ENV=production reports:import当您访问Dashboard时,可以看到导入的任务。
4.执行导入的报告
[root@master puppet-dashboard]# cd /usr/share/puppet-dashboard/ [root@master puppet-dashboard]# rake jobs:work RAILS_ENV="production"一主五节点测试效果。
文件同步测试
木偶大师:
[root@master ~]# vim /etc/puppet/fileserver.conf [fisteam2filesync] path /etc/puppet allow *下面添加一个配置域,名称为fisteam2filesync,路径为/etc/puppet。
[root@master ~]# vim /etc/puppet/manifests/site.pp node default { file { "/tmp/fisteam2_puppet_testfile.txt": content=>"good,test pass!\nfisteam2_puppet_testing\n"; } }上面的代码在默认连接的puppet客户端上执行一个 *** 作,在/tmp目录下生成一个文件fisteam2_puppet_testfile.txt,内容为good,testpass!输入行fisteam2_puppet_testing输入行。
要首次创建pp文件,您需要重新启动puppetmaster。
节点1~5测试
节点1:
节点2:
节点3:
节点4:
节点5:
下载地址:http://down.51cto.com/data/1968796
=========================================END====================================
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)