为了这个特意买了刘宇的PUPPET实战,没想到真是坑爹,按他写的步骤安装怎么都不成功,对于刚入门的人来说简直一头雾水,不过下面这个兄弟的文档很不错哦,拿来一用。
转载自:http://www.chenshake.com/ubuntu-12-04-puppet-deployment-openstack/
这个题目实在太牛逼。我也没想到,我对puppet都还没怎么了解的情况下,居然对着文档用puppet把openstack装好。而且是多节点,还用上multi_host。nova volume也搞定了。
其实还是人家的文档写的好。Openstack Essex Deploy by Puppet on Ubuntu 12.04 HOWTO
我也是使用3台机器做实验
node15.chenshake.com puppet master和控制节点,同时还是计算节点:10.1.199.15/24,
node16.chenshake.com 计算节点,10.1.199.16/24
node17.chenshake.com 计算节点,10.1.199.17/24
对于puppet,一定要把hostname搞定。他是依赖FQDN name。下面就一步一步来。
一:准备
1:设置网络
root@node15:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 10.1.199.15
hwaddress ether 00:25:90:67:ce:28
netmask 255.255.255.0
network 10.1.199.0
gateway 10.1.199.1
auto eth1
iface eth1 inet manual
up ifconfig eth1 up
3台机器都需要设置,把eth1 up 起来。
root@node15:~# mii-tool eth0: negotiated 1000baseT-FD flow-control, link ok eth1: negotiated 1000baseT-FD flow-control, link ok
2:设置hostname
root@node15:~# cat /etc/hosts
127.0.0.1 localhost
10.1.199.15 node15.chenshake.com node15
10.1.199.16 node16.chenshake.com node16
10.1.199.17 node17.chenshake.com node17
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
3: 设置nova-volume (可选)
这个就需要你硬盘里有单独的分区,我的机器上是有专门一个分区给nova-volume使用。
二:Puppet
1:安装puppet agent
我们希望puppet也可以管理自己,所以3台机器都需要安装agent
aptitude -y install puppet augeas-tools
2:安装puppet master (控制节点)
这个是在node15上安装就可以
apt-get update
aptitude -y install puppetmaster sqlite3 libsqlite3-ruby libactiverecord-ruby git rake
gem install puppetlabs_spec_helper
第二条命令时间比较长,确保网络是通的。
3:启用插件pluginsync
3台机器都需要运行,注意下面的 node15.chenshake.com, 指向控制节点的机器名。
augtool << EOF
set /files/etc/puppet/puppet.conf/agent/pluginsync true
set /files/etc/puppet/puppet.conf/agent/server node15.chenshake.com
save
EOF
4: 配置数据库(控制节点)
这个就只需要在控制节点操作就可以
augtool << EOF
set /files/etc/puppet/puppet.conf/master/storeconfigs true
set /files/etc/puppet/puppet.conf/master/dbadapter sqlite3
set /files/etc/puppet/puppet.conf/master/dblocation /var/lib/puppet/server_data/storeconfigs.sqlite
save
EOF
5:创建第一个manifest (控制节点)
这是为了测试使用
cat > /etc/puppet/manifests/site.pp << EOF node default { notify { "Hey ! It works !": } } EOF
6:重启服务(控制节点)
/etc/init.d/puppetmaster restart
7:注册节点
我们需要把3个节点都注册到puppet上。需要在3台机器都运行
puppet agent -vt --waitforcert 60
8:签发证书(控制节点)
puppetca sign –a
在各个节点,会看到类似下面的信息
info: Caching catalog for node15.chenshake.com info: Applying configuration version '1340077073' notice: Hey ! It works !
这个时候,重启所有节点的机器. 准备Openstack的安装
三:Openstack
1:下载puppet的openstack模块 (控制节点)
cd /etc/puppet/modules
git clone git://github.com/puppetlabs/puppetlabs-openstack openstack
cd openstack
rake modules:clone
2:修改openstack部署模块
大家最好读一下下面的内容,并不太难懂, 可以根据自己的情况进行修改
cat > /tmp/puppetlabs-openstack.patch << EOF diff --git examples/site.pp examples/site.pp index 879d8fa..fd38d4e 100644 --- examples/site.pp +++ examples/site.pp @@ -4,7 +4,9 @@ # # deploy a script that can be used to test nova -class { 'openstack::test_file': } +class { 'openstack::test_file': + p_w_picpath_type => 'ubuntu', +} ####### shared variables ################## @@ -21,17 +23,17 @@ \$public_interface = 'eth0' \$private_interface = 'eth1' # credentials \$admin_email = 'root@localhost' -\$admin_password = 'keystone_admin' -\$keystone_db_password = 'keystone_db_pass' -\$keystone_admin_token = 'keystone_admin_token' -\$nova_db_password = 'nova_pass' -\$nova_user_password = 'nova_pass' -\$glance_db_password = 'glance_pass' -\$glance_user_password = 'glance_pass' -\$rabbit_password = 'openstack_rabbit_password' -\$rabbit_user = 'openstack_rabbit_user' -\$fixed_network_range = '10.0.0.0/24' -\$floating_network_range = '192.168.101.64/28' +\$admin_password = 'openstack' +\$keystone_db_password = 'openstack' +\$keystone_admin_token = 'bdbb8df712625fa7d1e0ff1e049e8aab' +\$nova_db_password = 'openstack' +\$nova_user_password = 'openstack' +\$glance_db_password = 'openstack' +\$glance_user_password = 'openstack' +\$rabbit_password = 'openstack' +\$rabbit_user = 'openstack' +\$fixed_network_range = '10.1.0.0/16' +\$floating_network_range = '10.1.199.32/27' # switchthis to true to have all service log at verbose \$verbose = false # by default it does not enable atomatically adding floating IPs @@ -75,7 +77,7 @@ node /openstack_all/ { # multi-node specific parameters -\$controller_node_address = '192.168.101.11' +\$controller_node_address = '10.1.199.15' \$controller_node_public = \$controller_node_address \$controller_node_internal = \$controller_node_address @@ -83,9 +85,9 @@ \$sql_connection = "mysql://nova:\${nova_db_password}@\${controller_node_in node /openstack_controller/ { -# class { 'nova::volume': enabled => true } + class { 'nova::volume': enabled => true } -# class { 'nova::volume::iscsi': } + class { 'nova::volume::iscsi': } class { 'openstack::controller': public_address => \$controller_node_public, @@ -142,7 +144,7 @@ node /openstack_compute/ { vncproxy_host => \$controller_node_public, vnc_enabled => true, verbose => \$verbose, - manage_volumes => true, + manage_volumes => false, nova_volume => 'nova-volumes' } EOF cd /etc/puppet/modules/openstack patch -p0 < /tmp/puppetlabs-openstack.patch
运行下面命令
rm -rf /etc/puppet/manifests/site.pp ln -s /etc/puppet/modules/openstack/examples/site.pp /etc/puppet/manifests/site.pp
3:安装Openstack nova 控制节点
puppet agent -vt --waitforcert 60 --certname openstack_controller
这个时候,你需要另开一个ssh,去签发证书
puppetca sign -a
大概等待5分钟,你就可以通过 http://10.1.199.15 user:admin pass:openstack
4:安装多节点
需要在3台机器安装nova的计算节点。分别运行
puppet agent -vt --waitforcert 60 --certname openstack_compute_node15 puppet agent -vt --waitforcert 60 --certname openstack_compute_node16 puppet agent -vt --waitforcert 60 --certname openstack_compute_node17
在控制节点上,再开一个ssh,签发证书
puppetca sign -a
等10分钟吧,就可以把3个计算节点都装完。
5; 上传p_w_picpath
编辑/root/openrc ,默认的auth_url 是使用IP地址,这有问题,你运行glance index会报错。
root@node15:~# cat /root/openrc
export OS_TENANT_NAME=openstack
export OS_USERNAME=admin
export OS_PASSWORD=openstack
export OS_AUTH_URL="http://localhost:5000/v2.0/"
export OS_AUTH_STRATEGY=keystone
export SERVICE_TOKEN=bdbb8df712625fa7d1e0ff1e049e8aab
export SERVICE_ENDPOINT=http://10.1.199.15:35357/v2.0/
设置环境变量
source /root/openrc
这个时候,你运行
glance index
就不会有问题。
Ubuntu官方p_w_picpath
下载p_w_picpath
wget http://cloud-p_w_picpaths.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img
上传p_w_picpath
glance add name="Ubuntu 12.04 cloudimg amd64" is_public=true container_format=ovf \ disk_format=qcow2 < /root/precise-server-cloudimg-amd64-disk1.img
6:设置安全组
nova secgroup-add-rule default tcp 1 65535 0.0.0.0/0 nova secgroup-add-rule default udp 1 65535 0.0.0.0/0 nova secgroup-add-rule default icmp -1 255 0.0.0.0/0
7:检查所有节点的服务
root@node15:~# nova-manage service list Binary Host Zone Status State Updated_At nova-volume node15 nova enabled 2012-07-18 12:52:55 nova-consoleauth node15 nova enabled 2012-07-18 12:52:53 nova-scheduler node15 nova enabled 2012-07-18 12:52:55 nova-cert node15 nova enabled 2012-07-18 12:52:55 nova-network node15 nova enabled 2012-07-18 12:52:55 nova-compute node15 nova enabled 2012-07-18 12:52:52 nova-network node16 nova enabled 2012-07-18 12:52:57 nova-compute node16 nova enabled 2012-07-18 12:52:51 nova-network node17 nova enabled 2012-07-18 12:52:56 nova-compute node17 nova enabled 2012-07-18 12:52:50
计算节点都跑 nova-compute 和nova-network
8:登陆创建虚拟机
我已经全部测试了一遍,在计算节点的创建的虚拟机,都是可以登陆,访问外网。好好看看设置。我以前的文档,估计也要修改修改。