關於puppet的擴展APACHE2 + PASSENGER

前言: 

本篇博客參考了<puppet實戰>這本書,測試環境爲OpenSuSe13.2+ruby2.1+Apache2.4+Puppet3.7.1 master,Puppet agent爲2.7的版本

在領略了puppet種種神奇後,由於puppet通過catalog來更新內容,期間還可能下載插件,下載file,同步file的內容等,這必然要消耗掉master的諸多性能,在獲取的過程中master和agent說白了是https的通信,agent通過ruby內置的Webrick服務器獲得catalog,而現在流行的webserver肯定對於靜態內容效率與效果要更好,於是對master的擴展的一種方式演變爲webserver的升級


1 準備工作

zypper in ruby apache2  libcurl  libcurl-devel apr apr-devel apache2-devel(yum -y install ruby httpd ...)

gem install rack passenger rails
passenger-install-apache2-module.ruby2.1
...提示...
如果這裏提示你什麼包頭文件沒裝,請不要進行下一步,自己去嘗試安裝devel

cat /etc/apache2/vhost.d/liuliancao.com.conf
LoadModule passenger_module /usr/lib64/ruby/gems/2.1.0/gems/passenger-5.0.22/buildout/apache2/mod_passenger.so
PassengerRoot /usr/lib64/ruby/gems/2.1.0/gems/passenger-5.0.22
PassengerDefaultRuby /usr/bin/ruby.ruby2.1

# And the passenger performance tuning settings:
PassengerHighPerformance On

# now it is on
# PassengerUseGlobalQueue  On

# Set this to about 1.5 times the number of CPU cores in your master:
PassengerMaxPoolSize 3

# Recycle master processes after they service 1000 requests
PassengerMaxRequests 1000

# Stop  processes if they sit idle for 10 minutes
PassengerPoolIdleTime 600

Listen 8140

<VirtualHost *:8140>
    SSLEngine On

    # Only allow high security cryptography, ALter if needed for compatibility
    SSLProtocol ALL -SSLv2
    SSLCipherSuite HIGH:!ADH:RC4+RSA:-MEDIUM:-LOW:-EXP
    SSLCertificateFile /var/lib/puppet/ssl/certs/puppet-master.pem
    SSLCertificateKeyFile /var/lib/puppet/ssl/private_keys/puppet-master.pem
    SSLCertificateChainFile /var/lib/puppet/ssl/ca/ca_crt.pem
    SSLCACertificateFile  /var/lib/puppet/ssl/ca/ca_crt.pem
    SSLCARevocationFile   /var/lib/puppet/ssl/ca/ca_crl.pem
    SSLVerifyCLient optional
    SSLVerifyDepth  1
    SSLOptions      +StdEnvVars  +ExportCertData

# These request headers are used to pass the client certificates
# authentication infomation on to the puppet master process
RequestHeader set X-SSL-Subject %{SSL_CLIENT_S_DN}e
RequestHeader set X-SSL-Subject %{SSL_CLIENT_S_DN}e
RequestHeader set X-Client-DN %{SSL_CLIENT_S_DN}e
RequestHeader set X-Client-Verify %{SSL_CLIENT_VERIFY}e

#RackAutoDetect On
DocumentRoot /usr/share/puppet/rack/puppetmasterd/public/
<Directory /usr/share/puppet/rack/puppetmasterd/>
    Options None
    AllowOverride None
    Order Allow,Deny
    Allow from All
</Directory>
</VirtualHost>

檢查語法錯誤,下面錯誤不是重點就不管了
httpd2 -t
AH00558: httpd2: Could not reliably determine the server's fully qualified domain name, using 172.16.236.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK

systemctl start apache2

netstat -tnlp|grep 8140
tcp        0      0 :::8140                 :::*                    LISTEN      11371/httpd2-prefor


這是apache端已經配置好,還要啓動master才行,否則會報500的錯誤

puppet master start




回到我們的agent端進行測試

puppet agent --server puppet-master --test --noop
...
notice: Class[Nginx]: Would have triggered 'refresh' from 9 events
notice: Stage[main]: Would have triggered 'refresh' from 1 events
notice: Finished catalog run in 13.62 seconds

查看master日誌的情況

tail /var/log/apache2/access_log 
172.16.236.101 - - [20/Dec/2015:21:15:03 +0800] "POST /production/catalog/puppet-agent HTTP/1.1" 200 11044 "-" "-"
172.16.236.101 - - [20/Dec/2015:21:15:04 +0800] "GET /production/file_metadata/modules/user/file_from_module?links=manage HTTP/1.1" 200 303 "-" "-"
172.16.236.101 - - [20/Dec/2015:21:15:18 +0800] "PUT /production/report/puppet-agent HTTP/1.1" 200 9 "-" "-"

就實現了nginx輔助進行catalog的傳遞這個過程

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章