puppet 3+Unicorn+Nginx安装配置
2014-08-15 10:58 酒瓶不倒 酒瓶不倒的博客 字号:T | T
一键收藏,随时查看,分享好友!
Unicorn 效率要比 Webrick 高很多,所以决定要用Unicorn 替换 Webrick……
AD:2014WOT全球软件技术峰会北京站 课程视频发布
11月21日-22日 与WOT技术大会相约深圳 现在抢票
puppet server 安装
rpm -ivh http://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-6.noarch.rpm
yum install puppet-server -y
puppet server puppet.conf 配置: cat /etc/puppet/puppet.conf
[main]
# The Puppet log directory.
# The default value is '$vardir/log'.
logdir = /var/log/puppet
# Where Puppet PID files are kept.
# The default value is '$vardir/run'.
rundir = /var/run/puppet
# Where SSL certificates are kept.
# The default value is '$confdir/ssl'.
ssldir = $vardir/ssl
autosign = $confdir/autosign.conf { mode = 664 }
[agent]
# The file in which puppetd stores a list of the classes
# associated with the retrieved configuratiion. Can be loaded in
# the separate ``puppet`` executable using the ``--loadclasses``
# option.
# The default value is '$confdir/classes.txt'.
classfile = $vardir/classes.txt
# Where puppetd caches the local configuration. An
# extension indicating the cache format is added automatically.
# The default value is '$confdir/localconfig'.
localconfig = $vardir/localconfig
[development]
modulepath = /etc/puppet/modules:/usr/share/puppet/modules
config_version =
[production]
modulepath = /etc/puppet/modules:/usr/share/puppet/modules
config_version =
Unicorn 安装配置 yum install ruby-devel make gcc
gem install unicorn rack
cp /usr/share/puppet/ext/rack/config.ru /etc/puppet/
vi /etc/puppet/unicorn.conf
worker_processes 8
working_directory "/etc/puppet"
listen '/var/run/puppet/puppetmaster_unicorn.sock', :backlog => 512
timeout 120
pid "/var/run/puppet/puppetmaster_unicorn.pid"
preload_app true
if GC.respond_to?(:copy_on_write_friendly=)
GC.copy_on_write_friendly = true
end
before_fork do |server, worker|
old_pid = "#{server.config[:pid]}.oldbin"
if File.exists?(old_pid); server.pid != old_pid
begin
Process.kill("QUIT", File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job for us
end
end
end
调试: unicorn -c /etc/puppet/unicorn.conf
I, [2014-08-15T08:55:36.452577 #9031] INFO -- : Refreshing Gem list
I, [2014-08-15T08:55:38.779972 #9031] INFO -- : unlinking existing socket=/var/run/puppet/puppetmaster_unicorn.sock
I, [2014-08-15T08:55:38.780441 #9031] INFO -- : listening on addr=/var/run/puppet/puppetmaster_unicorn.sock fd=6
I, [2014-08-15T08:55:38.787469 #9059] INFO -- : worker=0 spawned pid=9059
I, [2014-08-15T08:55:38.790368 #9059] INFO -- : worker=0 ready
I, [2014-08-15T08:55:38.792410 #9060] INFO -- : worker=1 spawned pid=9060
I, [2014-08-15T08:55:38.795405 #9060] INFO -- : worker=1 ready
I, [2014-08-15T08:55:38.796387 #9061] INFO -- : worker=2 spawned pid=9061
I, [2014-08-15T08:55:38.799071 #9061] INFO -- : worker=2 ready
I, [2014-08-15T08:55:38.801353 #9062] INFO -- : worker=3 spawned pid=9062
I, [2014-08-15T08:55:38.804052 #9062] INFO -- : worker=3 ready
I, [2014-08-15T08:55:38.805570 #9063] INFO -- : worker=4 spawned pid=9063
I, [2014-08-15T08:55:38.808220 #9063] INFO -- : worker=4 ready
I, [2014-08-15T08:55:38.810281 #9064] INFO -- : worker=5 spawned pid=9064
I, [2014-08-15T08:55:38.812904 #9064] INFO -- : worker=5 ready
I, [2014-08-15T08:55:38.814869 #9065] INFO -- : worker=6 spawned pid=9065
I, [2014-08-15T08:55:38.817497 #9065] INFO -- : worker=6 ready
I, [2014-08-15T08:55:38.817731 #9031] INFO -- : master process ready
I, [2014-08-15T08:55:38.819580 #9066] INFO -- : worker=7 spawned pid=9066
I, [2014-08-15T08:55:38.822096 #9066] INFO -- : worker=7 ready
按ctrl+c结束 编写启动脚本 vi /etc/init.d/puppet-unicorn
#!/bin/bash
# unicorn-puppet
# chkconfig: - 98 02
#
# description: Enables periodic system configuration checks through unicorn-puppet.
# processname: unicorn-puppet
# Source function library.
. /etc/rc.d/init.d/functions
lockfile=/var/lock/puppetmaster-unicorn
pidfile=/var/run/puppet/puppetmaster_unicorn.pid
RETVAL=0
DAEMON=/usr/bin/unicorn
DAEMON_OPTS="-D -c /etc/puppet/unicorn.conf"
start() {
echo -n $"Starting puppet unicorn: "
daemon $DAEMON $DAEMON_OPTS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping puppet unicorn: "
kill `cat $pidfile`
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f {$lockfile} {$pidfile}
[ $RETVAL -eq 0 ] && echo_success || echo_failure
echo
return $RETVAL
}
restart() {
stop
start
}
usage() {
echo "Usage: $0 {start|stop|restart}" ;
return 3
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
usage
;;
esac
exit $RETVAL
chmod +x /etc/init.d/puppet-unicorn
chkconfig puppet-unicorn on
配置nginx vi /etc/nginx/conf.d/puppets-unicorn
upstream puppetmaster_unicorn {
server unix:/var/run/puppet/puppetmaster_unicorn.sock fail_timeout=0;
}
server {
listen 8140;
ssl on;
ssl_session_timeout 5m;
ssl_certificate /var/lib/puppet/ssl/certs/puppet.test.com.pem;
ssl_certificate_key /var/lib/puppet/ssl/private_keys/puppet.test.com.pem;
ssl_client_certificate /var/lib/puppet/ssl/ca/ca_crt.pem;
ssl_ciphers SSLv2:-LOW:-EXPORT:RC4+RSA;
ssl_verify_client optional;
root /usr/share/empty;
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-Client-DN $ssl_client_s_dn;
proxy_set_header X-SSL-Issuer $ssl_client_i_dn;
proxy_read_timeout 120;
location / {
proxy_pass http://puppetmaster_unicorn;
proxy_redirect off;
}
}
/etc/init.d/nginx start
chkconfig nginx on
参考网址: https://linuxmoz.com/rhel-centos-install-puppet-nginx-unicorn/ http://projects.puppetlabs.com/projects/1/wiki/using_unicorn 原文链接:http://my.oschina.net/u/142602/blog/301400