程序员 apache google java 开源 云计算 编程 Ubuntu Windows wordpress Firefox 微软 linux nginx php mysql Python centos shell Android

實戰Puppet 集中配置管理系統(3)——Puppet dashboard與nginx+passenger安裝配置

1 . Puppet dashboard安裝配置

1)所需軟件包

  puppet-dashboard-1.2.23-1.el6.noarch.rpm

        ruby-mysql-2.8.2-1.el6.x86_64.rpm 

        rubygem-rake-0.8.7-2.1.el6.noarch.rpm

  依賴性:

  * Ruby 1.8.7

  * RubyGems

  * Rake >= 0.8.3

  * MySQL server 5.x

  * Ruby-MySQL bindings 2.7.x or 2.8.x

2)安裝

    #yum install puppet-dashboard-1.2.23-1.el6.noarch.rpm 

       ruby-mysql-2.8.2-1.el6.x86_64.rpm rubygem-rake-0.8.7-2.1.el6.noarch.rpm -y

wKioL1gYa3HhIt_oAAAgaqvr1x8628.png

#

mysql 5.1 遇到的信息包過大問題 用客戶端導入數據的時候,遇到錯誤代碼: 1153 - Got a

packet bigger than 'max_allowed_packet' bytes 終止了數據導入,可以使用如下參數解決:

(rhel6.3 上未遇到)

# vi /etc/my.cnf

[mysqld]

max_allowed_packet = 32M#添加此行

3)配置 mysql 數據庫

# /etc/init.d/mysqld start

# mysql_secure_installation設置root密碼為willis

# cd /usr/share/puppet-dashboard/

# vim config/database.yml//只留下生產環境配置

wKiom1gYbB-CWWAlAAAgiSa2DBg354.png

 

wKiom1gYbB_wBsPvAAAv-Bnu6LU170.png

#vim config/add.sql

CREATE DATABASE dashboard_production CHARACTER set utf8;

CREATE USER 'dashboard'@'localhost' IDENTIFIED BY 'willis';

GRANT ALL PRIVILEGES ON dashboard_production.* TO 'dashboard'@'localhost';

wKiom1gYbK3R4O4XAABPwDVWRH0643.png

# rake RAILS_ENV=production db:migrate

  //建立 dashboard 所需的数据库和表

 

4)修改puppet-dashboard 默认时区

#//查看puppet-dashboard 默认支持的时区

#rake gems:refresh_specs

#rake time:zones:local

# vim /usr/share/puppet-dashboard/config/settings.yml

      //puppet-dashboard 默认时区不正确,需要修改

    time_zone: 'Beijing'

wKioL1gYbR_Bdd67AAAKiVndm08398.png

wKiom1gYbUCQBE8bAABgzb4bqwo461.png

 

5)启动服务

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

 

6)修改日志文件权限

# cd /usr/share/puppet-dashboard/log

#chmod 666 /production.log

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

 

7)修改服务器的配置文件

# vim /etc/puppet/puppet.conf

[main]//添加以下两项

reports = http

reporturl = http://172.25.254.1:3000/reports

wKiom1gYbcDA4whcAAAr_8PA5oA968.png

#/etc/init.d/puppetmaster restart

 

8)设置 client 端

      server2与server3同时设置如下

#vim /etc/puppet/puppet.conf

[agent]//添加以下行

report = true

 

# puppet agent --server server1.example.com --no-daemonize -vt//同步数据

wKiom1gYblDTGd7jAABQpMcA8UY820.png

wKioL1gYbm-T6NhWAABRCAAbWwA264.png

 

9) 浏览器访问 172.25.254.1:3000 

wKioL1gYbsvwr-LrAAEZYUhT1T0178.png

 

10)在客户端安装完 puppet 后,并且认证完后,我们可以看到效果,那怎样让它自动与服务器同步呢?默认多少分钟跟服务器同步呢?怎样修改同步的时间呢,这时候我们需要配置客户端:

<1>配置 puppet 相关参数和同步时间:

# vim /etc/sysconfig/puppet

PUPPET_SERVER=server1.example.com    #puppet master 的地址

PUPPET_PORT=8140    #puppet 监听端口

PUPPET_LOG=/var/log/puppet/puppet.log    #puppet 本地日志

#PUPPET_EXTRA_OPTS=--waitforcert=500 【默认同步的时间,我这里不修改这行参数】

<2>默认配置完毕后,客户端会半个小时跟服务器同步一次,我们可以修改这个时间

# vim /etc/puppet/puppet.conf

[agent]

runinterval = 60//代表 60 秒跟服务器同步一次

 

#/etc/init.d/puppet start

 

2.Nginx+passenger 安装配置

 

Apache 模块,实现对 puppet 的负载均衡。

参考:https://docs.puppetlabs.com/guides/passenger.html

 

1)[root@server1 mnt]# gem list

*** LOCAL GEMS ***

json (1.5.5)

rack (1.6.4)

wKiom1gYcoaw-Fg6AAAWV4DT4Lo998.png

2)不够就下载

# gem install passenger-5.0.15.gem rack-1.6.4.gem

wKioL1gYdtviCFfCAACDWGosQmM410.png

 

wKiom1gYdtrygdr4AAAfaU5B7j8437.png

 

3) # yum install -y gcc gcc-c++ curl-devel zlib-devel openssl-devel ruby-devel

# tar zxf nginx-1.8.0.tar.gz -C /mnt

wKiom1gYebHhbJ3NAABD-b_GrjU102.png

 

4) #passenger-install-nginx-module

  //脚本会自动安装 nginx 支持,按提示操作,其它按Enter就好,编译过程比较慢

 wKioL1gYekrTHr9TAACyAlTC1C4866.png

 

wKiom1gYekmS10AkAAA_a_wFHTY509.png

 

wKiom1gYe6DjHU-mAAD-HEgtb8c210.png

 

wKioL1gYe5-BdxJ-AAAmD9u86iY639.png

 

wKiom1gYe5-ANi82AAAjv2r9Wy4635.png

 

wKioL1gYe57T_8nAAABWFD46_F0638.png

 

wKiom1gYe57yt5-lAABS9Vz8E8E045.png

 

wKiom1gYfQ_gaDNUAAChD_uWI3c328.png

 

5) nginx 默认安装在/opt/nginx 目录:

# cd /opt/nginx/conf/

 

# /etc/init.d/puppetmaster stop

# vim nginx.conf

wKioL1gYfrqj-ghrAACJ2TBDfg0801.png

server {

        listen       8140;

        server_name  server1.example.com;

 

        root    /etc/puppet/rack/public;

        passenger_enabled on;

        passenger_set_header X_CLIENT_DN $ssl_client_s_dn;

        passenger_set_header X_CLIENT_VERIFY $ssl_client_verify;

 

        ssl on;

        ssl_session_timeout 5m;

        ssl_certificate /var/lib/puppet/ssl/certs/server1.example.com.pem;

        ssl_certificate_key /var/lib/puppet/ssl/private_keys/server1.example.com.pem;

        ssl_client_certificate /var/lib/puppet/ssl/ca/ca_crt.pem;

        ssl_crl /var/lib/puppet/ssl/ca/ca_crl.pem;

        ssl_verify_client optional;

        ssl_ciphers SSLv2:-LOW:-export:RC4+RSA;

        ssl_prefer_server_ciphers on;

        ssl_verify_depth 1;

        ssl_session_cache shared:SSL:128m;

}

wKioL1gYhP-zwde-AACT2cDU0Cc102.png

# /opt/nginx/sbin/nginx -t //检测 nginx配置文件是否有错

wKioL1gYgG3TReodAAAiJgVP1cY031.png

 

6)添加目录

# cd /etc/puppet/

# mkdir /etc/puppet/rack/{public,tmp}  -p

# cd rack/

# cp /usr/share/puppet/ext/rack/config.ru /etc/puppet/rack/

# chown puppet.puppet /etc/puppet/rack/config.ru

# /etc/init.d/puppetmaster stop

#chkconfig puppetmaster off

# /opt/nginx/sbin/nginx//启动nginx

    //puppetmaster 不需要启动 , nginx 启动时会自动调用 puppet。

 

7) 测试

# /opt/nginx/sbin/nginx stop   #关闭nginx让客户端获取信息,可以看到获取不到信息

wKioL1gYhYnjDLCoAAEEdhX9LwA162.png

# /opt/nginx/sbin/nginx   ###开启nginx,可以看到客户端可以获取到信息

wKiom1gYhgSCeno0AABVI2jWnmo060.png

#ps -ax   ###查看进程启动情况

wKiom1gYhsaSVzahAABiW6Mazsk626.png

延伸阅读

    评论