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

[经验分享] Puppet 3.7 结合Dashboard 1.2

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-12-3 10:00:16 | 显示全部楼层 |阅读模式

1. 环境准备

   OS:CentOS 6.4

   关闭selinux和iptables

   部署Puppet:1.0 Puppet 3.7部署

   安装Puppet源:http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm

   Dashboard是Puppet官方提供的一个简易的Web UI,可以很方便的做Puppet报告的展示和ENC的管理.但是很功能和简易。后面会更新一个更强大的Foreman,敬请期待..

2. 安装Dashboard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#安装dashboard包和mysql数据库
yum install puppet-dashboard mysql-server mysql -y
/etc/init.d/mysqld start
chkconfig mysqld on

#初始化数据库相关...
mysql -e 'CREATE DATABASE dashboard_production CHARACTER SET utf8;'
mysql -e "CREATE USER 'dashboard'@'localhost' IDENTIFIED BY 'dbsa.cn';"
mysql -e "GRANT ALL PRIVILEGES ON dashboard_production.* TO 'dashboard'@'localhost';"
mysql -e 'set GLOBAL max_allowed_packet = 33554432;'

#在/etc/my.cnf中增加以下参数
[mysqld]
max_allowed_packet = 32M

#执行表迁移任务,会生成相关的数据库表..
cd /usr/share/puppet-dashboard/
sed -i 's/UTC/Beijing/' config/environment.rb                                #修改显示时区
sed -ri 's/s+password:.*/  password: dbsa.cn/' config/database.yml          #修改默认的数据库密码..
rake RAILS_ENV=production db:migrate


cp /usr/share/puppet-dashboard/ext/puppet/puppet_dashboard.rb  /usr/lib/ruby/site_ruby/1.8/puppet/reports

#使用默认的WEBrick服务运行dashboard测试以下...
cd /usr/share/puppet-dashboard/
./script/server -e production

#访问dashboard...
http://ip:3000/





3. 配置Puppet
    配置由dashaboard分析Puppet的报告
1
2
3
4
5
#在Puppet Master上配置...
/etc/puppet/puppet.conf
[master]
  reports = store, http
  reporturl = http://localhost:3000/reports/upload               #localhost是发往dashboard的地址




    配置由dashboard管理class和parameters
1
2
3
4
5
6
#在Puppet Master上配置...
/etc/puppet/puppet.conf
[master]
  node_terminus = exec
  #localhost是发往dashboard的地址
  external_nodes = /usr/bin/env PUPPET_DASHBOARD_URL=http://localhost:3000 /usr/share/puppet-dashboard/bin/external_node





4. 配置Nginx替代默认的WEBrick
    安装Ningx和passenger
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
yum install ruby-devel rubygems gcc gcc-c++ make -y
yum install curl-devel openssl-devel zlib-devel pcre-devel -y
gem install rake -v 10.4.0 -V
gem install rack -v 1.5.2 -V
gem install passenger -v 3.0.19 -V

#更换gem 源为淘宝的,国内因为gfw更新可能会失败并且很慢.
gem sources -a  
gem sources --remove http://rubygems.org/
gem sources -l

#安装nginx...
cd /tmp
wget http://mirrors.sohu.com/nginx/nginx-1.6.2.tar.gz
tar xf nginx-1.6.2.tar.gz

#使用passenger编译Nginx
passenger-install-nginx-module

#选择1,在选择2,
然后在分别输入:
  /tmp/nginx-1.6.2
  /usr/local/nginx
  一路回车...

#puppet rack
mkdir -p /etc/puppet/rack/public
cp /usr/share/puppet/ext/rack/config.ru /etc/puppet/rack
chown -R puppet.puppet  /etc/puppet/rack




    Nginx配置文件:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
cat > /usr/local/nginx/conf/nginx.conf <<eof
user root;
worker_processes 1;
events {
    worker_connections 1024;
}
http {
    passenger_root /usr/lib/ruby/gems/1.8/gems/passenger-3.0.19;
    passenger_ruby /usr/bin/ruby;
    passenger_max_pool_size 32;
    include mime.types;
    default_type application/octet-stream;
    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
     '$status  "$http_referer" '
     '"$http_user_agent" "$http_x_forwarded_for"'
     '$upstream_addr $upstream_cache_status $upstream_status';
    sendfile on;
    keepalive_timeout 65;
    include /usr/local/nginx/conf/puppet.conf;          #如果按照 1.0 在本机部署了Puppet这个就不用注释...
    include /usr/local/nginx/conf/dashboard.conf;
}
EOF


cat > /usr/local/nginx/conf/dashboard.conf <<eof
server {
    listen 3000;
    server_name localhost;
    root /usr/share/puppet-dashboard/public;
    passenger_enabled on;
    access_log /usr/local/nginx/logs/access-3000.log main;
}
EOF



#启动dashboard服务
/usr/local/nginx/sbin/nginx -s reload

touch /usr/share/puppet-dashboard/log/production.log
chown -R puppet-dashboard.puppet-dashboard /usr/share/puppet-dashboard/log
chown -R puppet-dashboard.puppet-dashboard /usr/share/puppet-dashboard/tmp
chmod 666 /usr/share/puppet-dashboard/log/production.log

/etc/init.d/puppet-dashboard-workers start




    报告处理过程:
    1. Puppet Master在收到Agent的报告的时候,会通过http往自身的/reports/upload 接口POST一份..
    2. dashboard接收到post来的报告会保存到/usr/share/puppet-dashboard/spool
    3. 启动puppet-dashboard-workers 会开始处理报告..。
       默认puppet-dashboard-workers 启动两个进程处理,如果报告很多, 可以再配置进程数量.
1
2
3
cat >> /etc/sysconfig/puppet-dashboard <<eof
CPUS=`cat /proc/cpuinfo |grep process|wc -l`
EOF



    4. 处理完成的报告会写入数据库
    a8Vpy.jpg


5. 节点管理(ENC)
    在前面的master puppet.conf中配置使用enc。
1
2
3
4
5
#下面是一个测试..
cat > /etc/puppet/manifests/site.pp <<eof
node default {
}
EOF




   1. 在Dashboard 添加一个class。。(base的class在之前的blog中已经创建过,可以查看1.0 Puppet安装)

    oqGQh.jpg

   

    2. 选择一个主机..
    MrSUT.jpg

    3. 给这个主机添加class和parameters
    xB9S.jpg

    14XqH9.jpg

    4. 查看添加的类和参数..
    hWA6.jpg

    5. 通过执行命令,查询配置
1
2
3
4
5
6
7
[iyunv@master ~]# /usr/bin/env PUPPET_DASHBOARD_URL=http://localhost:3000 /usr/share/puppet-dashboard/bin/external_node agent1.dbsa.cn
---
classes:
- base
parameters:
  aa: bb
name: agent1.dbsa.cn






6. 常用维护命令
    导入现有的日志
1
2
cd /usr/share/puppet-dashboard;rake RAILS_ENV=production reports:import
cd /usr/share/puppet-dashboard;rake RAILS_ENV=production reports:import REPORT_DIR=/path/to/your/reports




   当数据量过大时,优化数据库
1
cd /usr/share/puppet-dashboard;rake RAILS_ENV=production db:raw:optimize




    删除一个月之前的日志
1
cd /usr/share/puppet-dashboard;rake RAILS_ENV=production reports:prune upto=1 unit=mon




    删除15天前的日志
1
cd /usr/share/puppet-dashboard;rake RAILS_ENV=production reports:prune upto=15 unit=day




    备份数据库         
1
mysqldump --add-locks --create-options --disable-keys --extended-insert --quick --set-charset --user=dashboard --password=dbsa.cn dashboard > production.sql




    恢复数据库
1
rake RAILS_ENV=production FILE=production.sql db:raw:restore






运维网声明 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-35267-1-1.html 上篇帖子: Puppet 3.7 Mcollective+SSL加密和权限验证 下篇帖子: Puppet 3.7 使用PuppetDB做数据仓库
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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