Puppet自動化Nginx+Mongrel負載平衡配置

來源:互聯網
上載者:User

Puppet自動化Nginx+Mongrel負載平衡配置  前言 * 隨著公司應用需求的增加,需要不斷的擴充,伺服器數量也隨之增加,當伺服器數量不斷增加,我們會發現一台puppetmaster壓力大,解析緩慢,那這時有什麼最佳化的辦法嗎?答案是有滴!Puppet官網上有類似的解決方案,puppetmaster可以配置多連接埠,結合WEB代理,這樣puppetmaster承受能力至少可以提升10倍以上。  www.2cto.com  一、硬體環境:伺服器系統:CentOS6.0 x86_64  Ruby版本:ruby-1.8.7  Puppet 版本:puppet-2.7.20  Nginx 版本: nginx-1.2.6 二、Mongrel安裝:要使用puppet多連接埠配置,需要指定mongrel類型,預設沒有安裝,需要安裝:在puppetmaster伺服器端執行如下命令(前提是已經安裝了對應版本的epel redhat源):yum install -y rubygem-mongrel 三、配置puppetmaster在/etc/sysconfig/puppetmaster檔案末尾添加如下兩行,分別代表多連接埠、mongrel類型。echo -e "PUPPETMASTER_PORTS=( 18140 18141 18142 18143 18144 )\nPUPPETMASTER_EXTRA_OPTS=\"—servertype=mongrel  --ssl_client_header=HTTP_X_SSL_SUBJECT\"" >>/etc/sysconfig/puppetmaster   www.2cto.com  四、安裝Nginx服務安裝之前請確保系統已經安裝pcre-devel正則庫,然後再編譯安裝Nginx,需要添加SSL模組參數cd /usr/src ;wget -c http://nginx.org/download/nginx-1.2.6.tar.gz ;tar xzf nginx-1.2.6.tgz && cd nginx-1.2.6 &&./configure --prefix=/usr/local/nginx --with-http_ssl_module &&make &&make install 五、配置Nginx:Nginx安裝完畢後,需要配置Nginx來代理本地Puppetmaster多個連接埠,Nginx使用puppetmaster預設8140連接埠,用戶端請求8140連接埠,Nginx自動負載到18140 18141 18142 18143 18144 這幾個連接埠。vi /usr/local/nginx/conf/vhosts.conf 內容如下:server {    listen 8140;    root /etc/puppet;    ssl on;    ssl_session_timeout 5m;    #如下為Puppetmaster伺服器端認證地址    ssl_certificate /var/lib/puppet/ssl/certs/192-9-117-162-app.com.pem;    ssl_certificate_key /var/lib/puppet/ssl/private_keys/192-9-117-162-app.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;    # File sections    location /production/file_content/files/ {    types { }    default_type application/x-raw;    #主要用於推送檔案,定義files別名路徑    alias /etc/puppet/files/;    }    # Modules files sections    location ~ /production/file_content/modules/.+/ {    root /etc/puppet/modules;    types { }    default_type application/x-raw;    rewrite ^/production/file_content/modules/(.+)/(.+)$ /$1/files/$2 break;    }    location / {    #設定跳轉到puppetmaster負載平衡    proxy_pass http://puppetmaster;    proxy_redirect off;    proxy_set_header Host $host;    proxy_set_header X-Real-IP $remote_addr;    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    proxy_set_header X-Client-Verify $ssl_client_verify;    proxy_set_header X-SSL-Subject $ssl_client_s_dn;    proxy_set_header X-SSL-Issuer $ssl_client_i_dn;    proxy_buffer_size 10m;    proxy_buffers 1024 10m;    proxy_busy_buffers_size 10m;    proxy_temp_file_write_size 10m;    proxy_read_timeout 120;     }    } 在Nginx.conf設定檔中添加如下代碼即可。upstream puppetmaster {   server 127.0.0.1:18140;   server 127.0.0.1:18141;   server 127.0.0.1:18142;   server 127.0.0.1:18143;   server 127.0.0.1:18144;   }   include vhosts.conf;  六、驗證配置重啟puppetmaster和nginx服務:[root@192-9-117-162 ~]# /etc/init.d/puppetmaster restart ;/usr/local/nginx/sbin/nginx   停止 puppetmaster:  Port: 18140                                                [失敗]  Port: 18141                                                [失敗]  Port: 18142                                                [失敗]  Port: 18143                                                [失敗]  Port: 18144                                                [失敗]  啟動 puppetmaster:  Port: 18140                                                [確定]  Port: 18141                                                [確定]  Port: 18142                                                [確定]  Port: 18143                                                [確定]  Port: 18144                                                [確定]  在用戶端執行puppet agent --server=192-9-117-162-app.com --test 測試成功即可
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.