Puppet3在CentOS6.5集羣下的安裝

環境:3臺主機,

IP分別爲10.211.55.11、12、13

puppet master安裝在10.211.55.11

puppet agent安裝在10.211.55.11、12、13

 

1、安裝EPEL庫 後面安裝puppet Dashboard需要

1
2
3
yum install yum-priorities
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm 
rpm —import https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6

其中源可以替換爲國內鏡像

1
2
http://mirrors.ustc.edu.cn/fedora/epel/epel-release-latest-6.noarch.rpm
http://mirrors.ustc.edu.cn/fedora/epel/RPM-GPG-KEY-EPEL-6

修改/etc/yum.repos.d/epel.repo文件

在[epel]最後添加一條屬性

1
priority=11

意思是yum先去官方源查,官方沒有再去epel的源找

 

2、在10.211.55.11上安裝dnsmasq域名解析服務

1
2
3
4
5
yum install dnsmasq
chkconfig dnsmasq on
service dnsmasq start
lokkit -p 53:udp(打開iptables 53端口)
echo "10.211.55.11 node01.myhost.com" >> /etc/hosts 

修改dnsmasq.conf

1
2
3
4
5
interface=eth0
listen-address=10.211.55.11
bind-interfaces
resolv-file=/etc/resolv.conf
addn-hosts=/etc/hosts

三臺主機上分別輸入

1
echo “nameserver 10.211.55.11” >> /etc/resolv.conf

改主機名

1
2
vi /etc/sysconfig/network 
分別改爲node01.myhost.com、node02.myhost.com、node03.myhost.com

驗證DNS是否成功

1
2
netstat -tunlp|grep 53
dig node02.myhost.com

 

3、在10.211.55.11安裝時間同步服務器

1
2
3
yum install ntp
chkconfig ntpd on
service ntpd start

(待完善)

 

4、安裝Puppet

安裝官方源

1
rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm

導入GPG密鑰(驗證包的完整性)

1
rpm --import http://yum.puppetlabs.com/RPM-GPG-KEY-puppetlabs

 

安裝

1
2
3
4
5
yum install puppet-server
service puppetmaster start
service puppet start
chkconfig puppetmaster on
chkconfig puppet on

編輯/etc/puppet/puppet.conf

1
2
[agent]
server = node01.myhost.com

自動簽名

1
cat > /etc/puppet/autosign.conf <

測試連接

1
puppet agent -t

刪除證書

1
find /var/lib/puppet/ssl -name localhost.pem -delete

常用信息

1
2
3
4
5
6
7
puppet cert list -all(查看所有證書)
cat /etc/sysconfig/puppet(默認配置)
/var/lib/puppet (agent證書位置)
/etc/puppet/puppet.conf (配置文件)
/usr/share/puppet (安裝位置)
puppet config print modulepath(查看模塊位置)
puppet agent -t --summarize(查看報告)

 

5、安裝Dashboard 安裝

1
yum install -y mysql mysql-devel mysql-server httpd mod_passenger puppet-dashboard

mod_passenger是讓apache支持ruby

配置:

/etc/my.cnf,

在[mysqld]字段,增加最後一行

1
2
# Allowing 32MB allows an occasional 17MB row with plenty of spare room
max_allowed_packet = 32M
1
2
3
4
5
/etc/init.d/mysqld start
chkconfig mysqld on
chkconfig httpd  on
service httpd start
mysqladmin -u root password 'password'

創建一個dashboard數據庫

1
mysql -uroot -ppassword <

編輯 /usr/share/puppet-dashboard/config/database.yml

1
2
3
4
5
6
production:
  database: dashboard
  username: dashboard
  password: password
  encoding: utf8
  adapter: mysql

修改時區 /usr/share/puppet-dashboard/config/environment.rb

1
2
#config.time_zone = 'UTC'
  config.time_zone = 'Beijing'

初始化數據庫

1
2
cd /usr/share/puppet-dashboard/
rake RAILS_ENV=production db:migrate

配置Apache

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
cat > /etc/httpd/conf.d/passenger.conf << EOF
LoadModule passenger_module modules/mod_passenger.so
 
   PassengerRoot /usr/share/rubygems/gems/passenger-3.0.17
   PassengerRuby /usr/bin/ruby
 
   PassengerHighPerformance on
   PassengerMaxPoolSize 12
   PassengerPoolIdleTime 1500
   PassengerStatThrottleRate 120
   RailsAutoDetect On
 
     
       ServerName node01.myhost.com
       DocumentRoot "/usr/share/puppet-dashboard/public/"
       <Directory "/usr/share/puppet-dashboard/public/">
          Options None
          AllowOverride AuthConfig
          Order allow,deny
                  allow from all
        
       ErrorLog /var/log/httpd/node01.myhost.com_error.log
       LogLevel warn
       CustomLog /var/log/httpd/node06.chenshake.com_access.log combined
       ServerSignature On
     
EOF
 
/etc/init.d/httpd start
chkconfig httpd on
lokkit -p 80:tcp

配置puppet

1
2
3
4
# puppet.conf (on puppet master)
  [master]
    reports = store, http
    reporturl = http://node06.chenshake.com:80/reports/upload

/etc/init.d/puppetmaster restart

 

導入報告

1
2
3
4
5
6
7
8
cd /usr/share/puppet-dashboard
rake gems:refresh_specs
rake RAILS_ENV=production reports:import
 
Delayed Job Workers
env RAILS_ENV=production /usr/share/puppet-dashboard/script/delayed_job -p dashboard -n 4 -m start
ps -ef|grep delayed_job|grep -v grep
env RAILS_ENV=production /usr/share/puppet-dashboard/script/delayed_job -p dashboard -n 4 -m stop

這個時候你才能在Dashbaord裏看到數據

 

6、安裝Foreman (待完善)

 

參考: 

http://www.chenshake.com/puppet-study-notes/

http://acooly.iteye.com/blog/1993484

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