当前位置: 首页 > 工具软件 > puppet-nginx > 使用案例 >

CentOS下部署puppet-dashboard(nginx + passenger启动)

归明诚
2023-12-01

之前安装puppet-dashboard,找到很多相关教程,但基本都是原生的webrick方式运行或者Apache+passenger方式运行,而没有nginx+passenger方式运行,故结合相关教程改编为这篇博文。


1 前期准备工作

Puppet Dashboard(1.2.3)程序目前版本只能安装在 Ruby 1.8.x(Dashboard 还不能工

作在 1.9.x 下或者更新的版本下),只支持 MySQL 作为数据库后端。 

Rake version 0.8.3 or newer 
MySQL database server version 5.x 
Ruby-MySQL bindings version 2.7.x or 2.8.x

更多详细信息请参考:http://docs.puppetlabs.com/dashboard/ 


2 安装相关软件包 

yum install ruby-mysql mysql-server puppet-dashboard 


3 配置 Dashboard(包括与数据库的结合部分) 

3.1 创建管理 Dashboard 的 MySQL 数据库账号并授权

 /etc/rc.d/init.d/mysqld restart 

chkconfig mysqld on
mysqladmin -uroot password 123.com
mysql –p123.com

mysql> create database dashboard character set utf8; 

mysql> grant all on dashboard.* to 'dashboard'@'localhost' identified by "dashboard"; 

mysql> flush privileges;

mysql -udashboard -pdashboard #测试账号是否创建成功


3.2 优化数据库配置文件 my.cnf

[mysqld]
# Allowing 32MB allows an occasional 17MB row with plenty of spare room

max_allowed_packet = 32M

/etc/rc.d/init.d/mysqld restart #重启 MySQL 生效 


3.3 编辑 dashboard YAML 配置文件( )来指定数据库 

vim /usr/share/puppet-dashboard/config/database.yml
production:
database: dashboard
username: dashboard 
password: dashboard
encoding: utf8 
adapter: mysql

 

3.4 填充数据库 

[root@puppetserver ~]# cd /usr/share/puppet-dashboard/
[root@puppetserver puppet-dashboard]# rake gems:refresh_specs
[root@puppetserver puppet-dashboard]# rake RAILS_ENV=production db:migrate #环境变量 RAILS_ENV=production 告诉 Ruby on Rails 我们工作在生产环境。每次你运行一个 rake 命令都需要 使用合适的环境值来设置 RAILS_ENV 环境变量 


3.5 查看是否导入成功 

mysql -udashboard -pdashboard 

>use dashboard;

>show tables;

+------------------------------+
| Tables_in_dashboard |
+------------------------------+
| delayed_job_failures |
| delayed_jobs |
| metrics |
| node_class_memberships |
| node_classes |
| node_group_class_memberships |
| node_group_edges |
| node_group_memberships |
| node_groups |
| nodes |
| old_reports |
| parameters |
| report_logs |
| reports |
| resource_events |
| resource_statuses |
| schema_migrations |
| timeline_events |
+------------------------------+

 

4 启动并运行 Dashboard(Passenger 方式) 

之前配置了nginx+passenger模式运行puppetmaster,这里只需要在nginx配置文件/etc/nginx/conf/nginx.conf里添加一段就行:

server {
listen 8141;
server_name puppet-dashboard puppet-dashboard.chinacache.com;

passenger_enabled on;
passenger_set_cgi_param HTTP_X_CLIENT_DN $ssl_client_s_dn;
passenger_set_cgi_param HTTP_X_CLIENT_VERIFY $ssl_client_verify;

access_log /var/log/nginx/puppet-dashboard_access.log;
error_log /var/log/nginx/puppet-dashboard_error.log;

root /usr/share/puppet-dashboard/public;

#allow puppet master to post reports
allow all;

#deny all else
#deny all;
}

此处监听8141端口。

重启nginx:/etc/nginx/sbin/nginx -s reload

此时可以通过浏览器访问主机的8141端口,展示dashboard

 

5 集成 Puppet Dashboard 

配置实时汇总 puppet 报告 

[root@agent1 ~]# vim /etc/puppet/puppet.conf #配置 agent 节点自动发送报告 [agent]

report=true #从2.7.0版本开始,报告系统会默认开启,不需要配置
...
[root@puppetserver puppet-dashboard]# vim /etc/puppet/puppet.conf [main]

reports=http #定义为http报告处理器,除此之外还有store,log,tagmail,rrdgraph等 报告处理器

reporturl = http://172.16.200.100:8141/reports #http 报告处理器将 puppet 报告发送到一个 HTTP URL 和端口(Dashboard 位置)。Puppet 报告以被转储为 HTTP Poort 形式的 YAML 格式进行发 送。
... 

[root@puppetserver puppet-dashboard]# /etc/nginx/sbin/nginx -s reload


开启后台处理报告进程 

Delayed Job Workers

这个其实就相当于一个脚本,用来分析report

启动delay job:

env RAILS_ENV=production /usr/share/puppet-dashboard/script/delayed_job -p dashboard -n 4 -m start

查看启动的job:

ps -ef|grep delayed_job|grep -v grep

停止delayed job

env RAILS_ENV=production /usr/share/puppet-dashboard/script/delayed_job -p dashboard -n 4 -m stop


修改 dashboard 时区

Dashboard 默认时区为 UTC 格式,我们这里需要更改为 )格式 

[root@puppetserver ~]# vim /usr/share/puppet-dashboard/config/settings.yml time_zone: 'Asia/Shanghai'
...
**备注**:设置的 settings.yml 会覆盖掉 config/environment.rb 中对应的配置项 (config.time_zone = 'UTC') 


显示报告

通过主机8141端口及时查看节点更新的报告信息,可以看到节点信息,默认显示时间为 CST 格式,除此之外还可以看到某一个节点在某一个时刻的更新报告和运行曲线图。 

 

参考文献:

puppet报告系统Dashboard部署及配置详解.pdf  by kisspuppet.com

http://www.chenshake.com/puppet-study-notes/

 类似资料: