手机版
你好,游客 登录 注册
背景:
阅读新闻

Puppet自动化高可用集群部署

[日期:2015-09-02] 来源:Linux社区  作者:wgkgood [字体: ]

前言:随着公司应用需求的增加,需要不断的扩展,服务器数量也随之增加,当服务器数量不断增加,我们会发现一台puppetmaster响应很慢,压力大,解析缓慢,有什么优化的方案吗?可以使用Puppetmaster配置多端口,结合Nginx web代理,这样puppetmaster承受能力至少可以提升10倍以上。

一、安装配置mongrel服务:

要使用puppet多端口配置,需要指定mongrel类型,默认没有安装,需要安装。在Puppetmaster服务器端执行如下命令(前提是已经安装了对应版本的epel RedHat源):

rpm -Uvh http://mirrors.sohu.com/Fedora-epel/5/x86_64/epel-release-5-4.noarch.rpm

yum  install  -y  rubygem-mongrel

在vi /etc/sysconfig/puppetmaster文件末尾添加如下两行、

同时注释掉原相同配置项,分别代表多端口、mongrel类型:

PUPPETMASTER_PORTS=(18140 18141 18142 18143 18144)

PUPPETMASTER_EXTRA_OPTS="--servertype=mongrel --ssl_client_header=HTTP_X_SSL_SUBJECT"

二、安装配置Nginx服务器:

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.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;

  }

server{

  listen 8140;

  root /etc/puppet;

  ssl on;

  ssl_session_timeout 5m;

  #如下为Puppetmaster服务器端证书地址

  ssl_certificate /var/lib/puppet/ssl/certs/192-9-117-162-usr/local.com.pem;

  ssl_certificate_key /var/lib/puppet/ssl/private_keys/192-9-117-162-usr/local.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 /usr/locallication/x-raw;

  #主要用于推送文件,定义files别名路径

  alias /etc/puppet/files/;

  }

  # Modules files sections

  location  ~/production/file_content/modules/.+/ {

  root /etc/puppet/modules;

  types { }

  default_type usr/locallication/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;

  }

}

然后重启服务器端/etc/init.d/puppetmaster restart ,重启nginx WEB,在客户端测试即可。

三、Puppet多master主部署:

如果配置多主集群的话,可以共享33.10 master1的证书,然后另外一台master挂载证书即可,192.168.33.10 nfs配置方式如下:

Vi  /etc/exports 内容:

/var/lib/puppet/  *(no_root_squash,rw,sync)

然后在192.168.33.11master2上执行:

mount -t  nfs  192.168.33.10:/var/lib/puppet/ssl  /var/lib/puppet/ssl

然后重启master2puppetmaster服务。

添加多端口服务,同上需要安装:

yum  install -y rubygem-mongrel

同时修改master2/etc/sysconfig/puppet.conf里面:

[main]段添加bind address = 0.0.0.0,使监听端口为0.0.0.0全局所有地址。

这样在master1 nginx可以upstream,最终master1 nginx.conf upstream配置如下:

upstreampuppetmaster {

        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;

        #config add 2014-10-10

        server 192.168.33.11:18140;

        server 192.168.33.11:18141;

        server 192.168.33.11:18142;

        server 192.168.33.11:18143;

        server 192.168.33.11:18144;

  }


如果需要做keepalived高可用集群,其实也不难,大家可以发散思维去搭建一下哦。更多精彩文章,欢迎持续关注!

Puppet 学习系列:

Puppet 学习一:安装及简单实例应用 http://www.linuxidc.com/Linux/2013-08/88710.htm

Puppet学习二:简单模块配置和应用 http://www.linuxidc.com/Linux/2013-08/88711.htm

相关阅读:

有关Puppet agent端三种备份恢复方案探讨研究 http://www.linuxidc.com/Linux/2013-07/87885.htm
选择更安全的方式注册你的Puppet节点 http://www.linuxidc.com/Linux/2013-07/87884.htm
通过配置SSH深刻理解Puppet的语法及工作机制 http://www.linuxidc.com/Linux/2013-07/87882.htm
Puppet利用Nginx多端口实现负载均衡 http://www.linuxidc.com/Linux/2013-02/79794.htm
Puppet集中配置管理系统详解
CentOS(5和6)下Puppet的C/S模式实例 http://www.linuxidc.com/Linux/2011-12/50502.htm

Puppet 的详细介绍请点这里
Puppet 的下载地址请点这里

本文永久更新链接地址http://www.linuxidc.com/Linux/2015-09/122622.htm

linux
相关资讯       Puppet 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款