设为首页 收藏本站
查看: 1576|回复: 0

[经验分享] CentOS6.5+puppet3.7.3 安装、配置及测试

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-1-4 08:46:50 | 显示全部楼层 |阅读模式
OS:CentOS-6.5-x86_64

Puppet 3.7.3

Puppet master: master.fisteam2.com

Puppet clients:node1-5.fisteam2.com


Puppet 要求所有机器有完整的域名(FQDN),如果没有 DNS 服务器提供域名的话,可以在两台机器上设置主机名(注意要先设置主机名再安装 Puppet,因为安装 Puppet 时会把主机名写入证书,客户端和服务端通信需要这个证书),因为我配置了DNS,所以就不用改hosts了,如果没有就需要改hosts文件指定。

1.关闭selinux,iptables,并设置ntp   
采用CentOS-6.5-x86_64.iso进行minimal最小化安装

关闭selinux

[iyunv@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

[iyunv@master ~]# sed -i '/SELINUX/ s/enforcing/disabled/g' /etc/selinux/config

[iyunv@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

[iyunv@master ~]# setenforce 0

停止iptables

[iyunv@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

[iyunv@node1 ~]# chkconfig ip6tables off

[iyunv@node1 ~]# chkconfig iptables off

[iyunv@node1 ~]# service ip6tables stop

ip6tables: Setting chains to policy ACCEPT: filter [ OK ]

ip6tables: Flushing firewall rules: [ OK ]

ip6tables: Unloading modules: [ OK ]

[iyunv@node1 ~]# service iptables stop

iptables: Setting chains to policy ACCEPT: filter [ OK ]

iptables: Flushing firewall rules: [ OK ]

iptables: Unloading modules: [ OK ]

[iyunv@node1 ~]#

设置ntp

[iyunv@master ~]# ntpdate pool.ntp.org

[iyunv@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

[iyunv@master ~]# chkconfig ntpd on

[iyunv@master ~]# service ntpd start

Starting ntpd: [ OK ]

[iyunv@master ~]#

2.安装puppet服务  
puppet不在CentOS的基本源中,需要加入 PuppetLabs 提供的官方源:

[iyunv@master ~]# wget http://yum.puppetlabs.com/el/6/p ... ease-6-7.noarch.rpm

[iyunv@master ~]# rpm -ivh puppetlabs-release-6-7.noarch.rpm

[iyunv@master ~]#yum update

在 master上安装和启用 puppet 服务:

[iyunv@master ~]# yum install puppet-server

[iyunv@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

[iyunv@master ~]# chkconfig puppet on

[iyunv@master ~]# service puppetmaster start

Starting puppetmaster: [ OK ]

[iyunv@master ~]#


在clients上安装puppet客户端

[iyunv@node1 ~]# yum install puppet

[iyunv@node1 ~]# chkconfig --list |grep puppet

puppet 0:off 1:off 2:off 3:off 4:off 5:off 6:off

[iyunv@node1 ~]# chkconfig puppet on

[iyunv@node1 ~]# chkconfig --list |grep puppet

puppet 0:off 1:off 2:on 3:on 4:on 5:on 6:off

[iyunv@node1 ~]# service puppet start

Starting puppet agent: [ OK ]

[iyunv@node1 ~]#


3.配置puppet

对于puppet 客户端,修改/etc/puppet/puppet.conf,指定master服务器

[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


并重启puppet服务

[iyunv@node1 ~]# service puppet restart

Stopping puppet agent: [ OK ]

Starting puppet agent: [ OK ]

[iyunv@node1 ~]#

4.Client申请证书  
服务端自动签发证书设置  
设置master自动签发所有的证书,我们只需要在/etc/puppet 目录下创建 autosign.conf 文件。(不需要修改 /etc/puppet/puppet.conf文件,因为我默认的autosign.conf 文件的位置没有修改)

[iyunv@master ~]# ll /etc/puppet/

total 28

-rw-r--r--. 1 root root 4178 Nov 4 06:24 auth.conf

drwxr-xr-x. 3 root root 4096 Dec 29 15:44 environments

-rw-r--r--. 1 root root 1462 Nov 4 06:23 fileserver.conf

drwxr-xr-x. 2 root root 4096 Nov 4 06:24 manifests

drwxr-xr-x. 2 root root 4096 Nov 4 06:24 modules

-rw-r--r--. 1 root root 853 Nov 4 06:23 puppet.conf

[iyunv@master ~]# cat > /etc/puppet/autosign.conf <<eof

> *.fisteam2.com

> EOF

[iyunv@master ~]# service puppetmaster restart

Stopping puppetmaster: [ OK ]

Starting puppetmaster: [ OK ]

[iyunv@master ~]#


这样就会对所有来自fisteam2.com的机器的请求,都自动签名。  
client需要向服务器端发出请求, 让服务器对客户端进行管理. 这其实是一个证书签发的过程. 第一次运行puppet 客户端的时候会生成一个 SSL 证书并指定发给 Puppet 服务端, 服务器端如果同意管理客户端,就会对这个证书进行签发,可以用这个命令来签发证书,由于我们已经在客户端设置了server地址,因此不需要跟服务端地址

[iyunv@master ~]# puppet agent


为了详细了解注册的过程和日后排错,可以增加参数,因为配置文件里  
–no-daemonize 前台输出日志  
–verbose 输入更加详细的日志  
–debug 更加详细的日志,排错的时候使用  
–test 表示测试,就带一个–test参数就可以

[iyunv@node1 ~]# puppet agent --no-daemonize --onetime --verbose --debug

wKioL1SoEuWQ3uEmAAVIOGoTP0g184.jpg
就可以申请证书了,由于我配置的自动签发证书,所以直接就签发了,在服务端执行
[iyunv@master ~]# puppet cert list --all
wKioL1SoEuahicM7AAKgwQzchvk238.jpg
就可以看到所有客户端已经都已签发证书,前面带”+”号的就是签发成功的,如果没有签名的,可以用
[iyunv@master ~]# puppet cert --sign node1.localdomain
wKioL1SoEufSFOHxAAWgMtKTLoY933.jpg
即可看到证书已经签发  
5.在服务端安装puppet的dashboard  
安装mysql
[iyunv@master ~]# yum install -y mysql mysql-devel mysql-server
优化mysql设置
编辑 /etc/my.cnf, 在[mysqld]字段,增加最后一行
[iyunv@master ~]# vim /etc/my.cnf
wKioL1SoEuiTU2f3AAGpoIFbiRs590.jpg
启动Mysql服务
[iyunv@master ~]# service mysqld start[iyunv@master ~]# chkconfig mysqld on [iyunv@master ~]# chkconfig --list |grep mysqld mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
wKiom1SoEjDDEJLyAAOVNk-LqLA363.jpg
设置mysql密码,我这里使用是密码是123456
[iyunv@master ~]# mysqladmin -u root password '123456'
创建一个dashboard数据库
[iyunv@master ~]# mysql -uroot -p123456 < CREATE DATABASE dashboard CHARACTER SET utf8;> CREATE USER 'dashboard'@'localhost' IDENTIFIED BY '123456';> GRANT ALL PRIVILEGES ON dashboard.* TO 'dashboard'@'localhost';> FLUSH PRIVILEGES;> EOF[iyunv@master ~]#
wKiom1SoEjHR9HESAAEIvk387m4520.jpg
Passenger+Apache+Dashboard
这是让Apache支持ruby,由于Passenger不在centos官方源里,因此要添加epel的源
[iyunv@master ~]# wget http://dl.fedoraproject.org/pub/ ... ease-6-8.noarch.rpm [iyunv@master ~]# rpm -ivh epel-release-6-8.noarch.rpm [iyunv@master ~]# yum install mod_passenger puppet-dashboard
配置Dashboard
[iyunv@master ~]# vim /usr/share/puppet-dashboard/config/database.yml
wKiom1SoEjPhyCitAAIIbxP-d3k863.jpg
修改时区
[iyunv@master ~]# vim /usr/share/puppet-dashboard/config/environment.rb
wKioL1SoEu-yED74AAMNHgRMN-0794.jpg
初始化数据库
[iyunv@master ~]# cd /usr/share/puppet-dashboard/[iyunv@master puppet-dashboard]# rake RAILS_ENV=production db:migrate
wKioL1SoEvChP36QAASaqn_76hw803.jpg
配置Apache  
我们需要整合Passenger和apache
[iyunv@master ~]# cat > /etc/httpd/conf.d/passenger.conf << EOF> LoadModule passenger_module modules/mod_passenger.so> > PassengerRoot /usr/share/rubygems/gems/passenger-3.0.17> PassengerRuby /usr/bin/ruby> PassengerHighPerformance on> PassengerMaxPoolSize 12> PassengerPoolIdleTime 1500> PassengerStatThrottleRate 120> RailsAutoDetect On> > > ServerName master.fisteam2.com> DocumentRoot "/usr/share/puppet-dashboard/public/"> > Options None> AllowOverride AuthConfig> Order allow,deny> allow from all> > ErrorLog /var/log/httpd/master.fisteam2.com_error.log> LogLevel warn> CustomLog /var/log/httpd/master.fisteam2.com_access.log combined> ServerSignature On> > EOF[iyunv@master ~]#
wKiom1SoEjax4Y5hAALpCKeG-lA744.jpg
启动服务
[iyunv@master ~]# service httpd startStarting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using master.fisteam2.com for ServerName[ OK ][iyunv@master ~]# chkconfig httpd on[iyunv@master ~]# chkconfig --list | grep httpdhttpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
wKiom1SoEjfih0u6AAE72QV4N-s717.jpg
配置puppet  
让Dashboard使用Reports,现在默认agent是已经启用Report的功能,所以你就不需要设置agent,你只需要设置Server端就可以
[iyunv@master ~]# vim /etc/puppet/puppet.conf[master]reports = store,httpreporturl = http://master.fisteam2.com:80/reports/upload
wKiom1SoEjeRTRz2AALfDxFS0q0445.jpg
重启puppetmaster 服务
[iyunv@master ~]# service puppetmaster restart
wKiom1SoEjjBKnz9AACNcq0vjNQ630.jpg
这时候就可以直接用 http://ip 访问puppet Dashboard
wKiom1SoEjjyTvMfAAF4vpmwnUA698.jpg
导入报告
[iyunv@master puppet-dashboard]# cd /usr/share/puppet-dashboard/[iyunv@master puppet-dashboard]# rake RAILS_ENV=production reports:import
wKiom1SoEjnzRPmAAAV8tANfZMY313.jpg
这时候你访问Dashboard,可以看到导入的任务.
wKiom1SoEjrQRb7ZAAF4vNP4oLo291.jpg
4. 执行导入的reports
[iyunv@master puppet-dashboard]# cd /usr/share/puppet-dashboard/[iyunv@master puppet-dashboard]# rake jobs:work RAILS_ENV="production"
wKioL1SoEvWCaLswAAVLpqYVVEc944.jpg
wKiom1SoEjuiKIClAAHZ40XbziM568.jpg
一个Master,五个node测试效果
wKioL1SoEveC3FtvAAIb1CGKrzM107.jpg
wKioL1SoEvfSyYTfAAMBXcYZVzM046.jpg
文件同步测试
Puppet master:
[iyunv@master ~]# vim /etc/puppet/fileserver.conf[fisteam2filesync]path /etc/puppetallow *
wKioL1SoEviwDCIaAAO-bCoQzkg388.jpg
在下面加一个配置域,名字叫做fisteam2filesync,路径是/etc/puppet
[iyunv@master ~]# vim /etc/puppet/manifests/site.ppnode default {file {"/tmp/fisteam2_puppet_testfile.txt":content=>"good,test pass!fisteam2_puppet_testing";}}
wKioL1SoEvjB9wmtAAEAr1feFgE248.jpg
上面的代码对默认连入的puppet客户端执行一个操作,在/tmp目录生成一个fisteam2_puppet_testfile.txt文件,内容是good,test pass! 回车换行fisteam2_puppet_testing回车换行.  
初次创建pp文件,需要重启puppetmaster
[iyunv@master ~]# service puppetmaster restartStopping puppetmaster: [ OK ]Starting puppetmaster: [ OK ]
NODE1~5测试
node1:
wKioL1SoEvnDJvWhAAILbkPNQ8A736.jpg
node2:
wKioL1SoEvqQLNAOAAIHkdxfTSA526.jpg
node3:
wKioL1SoEvrAu3X_AAIFKxKjrdU486.jpg
node4:
wKioL1SoEvvwK5r8AAIJZKht17Q693.jpg
node5:
wKioL1SoEvvgKGRsAAIDvmw3gXI913.jpg
===================================================END====================================




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-40078-1-1.html 上篇帖子: puppet安装和配置 下篇帖子: Puppet之DRBD初体验
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表