youngfan007 发表于 2015-4-13 07:05:47

CentOS6.4安装OpenStack Icehouse controller (二)

  CentOS6.4安装OpenStack Icehouse controller(一)


OpenStack交流群:322596568


*本文介绍Nova、Horizon的安装过程


7.安装配置Nova


7.1.初始化Nova
(1).安装Nova服务:
# yum -y install openstack-nova


(2).创建Nova数据库:
# openstack-db --init --service nova--rootpw passwd


7.2.创建User,定义Services 和 API Endpoints
(1).为nova服务创建一个nova用户:
# keystone user-create --name=nova --pass=service --email=nova@chensh.net

WARNING: Bypassing authentication using a token & endpoint (authentication credentials are being ignored).
+----------+----------------------------------+
| Property |            Value               |
+----------+----------------------------------+
|email   |         nova@chensh.net          |
| enabled|               True               |
|    id    | e2934a26989741ed9a45be58a24f5140 |
|   name   |               nova               |
| username |               nova               |
+----------+----------------------------------+

  # keystone user-role-add --user=nova --tenant=service --role=admin
  WARNING: Bypassing authentication using a token & endpoint (authentication credentials are being ignored).
  (2).为nova创建一个服务:
  # keystone service-create --name=nova --type=compute --description="Nova Compute Service"

WARNING: Bypassing authentication using a token & endpoint (authentication credentials are being ignored).
+-------------+----------------------------------+
|   Property|            Value               |
+-------------+----------------------------------+
| description |       Nova Compute Service       |
|   enabled   |               True               |
|      id   | ceb0357b8e5940f190d705bab12472ef |
|   name    |               nova               |
|   type    |             compute            |
+-------------+----------------------------------+
(3).使用服务ID创建一个endpoint:
# vi /root/config/nova-user.sh


#!/bin/sh
my_ip=0.0.0.0
service=$(keystone service-list | awk '/nova/ {print $2}')
keystone endpoint-create --service-id=$service --publicurl=http://$my_ip:8774/v2/%\(tenant_id\)s --internalurl=http://$my_ip:8774/v2/%\(tenant_id\)s --adminurl=http://$my_ip:8774/v2/%\(tenant_id\)s
# sh /root/config/nova-user.sh

WARNING: Bypassing authentication using a token & endpoint (authentication credentials are being ignored).
+-------------+--------------------------------------+
|   Property|                Value               |
+-------------+--------------------------------------+
|   adminurl| http://0.0.0.0:8774/v2/%(tenant_id)s |
|      id   |   ed1662b608884583bed3873abf8fabeb   |
| internalurl | http://0.0.0.0:8774/v2/%(tenant_id)s |
|publicurl| http://0.0.0.0:8774/v2/%(tenant_id)s |
|    region   |            regionOne               |
|service_id |   ceb0357b8e5940f190d705bab12472ef   |
+-------------+--------------------------------------+
7.3.配置Nova服务
(1).修改nova配置文件
# cp -a /etc/nova/nova.conf /etc/nova/nova.conf_bak
# echo "" > /etc/nova/nova.conf
# vi /etc/nova/nova.conf


my_ip = 192.168.20.200
auth_strategy = keystone
state_path = /openstack/nova                                                   //instance实例存放路径
#auto_assign_floating_ip=True
verbose = True
allow_resize_to_same_host = true
rpc_backend = nova.openstack.common.rpc.impl_qpid
qpid_hostname = 192.168.20.200
libvirt_type = kvm
glance_api_servers = 192.168.20.200:9292
novncproxy_base_url = http://192.168.20.200:6080/vnc_auto.html
vncserver_listen = 192.168.20.200
vncserver_proxyclient_address = 192.168.20.200
vnc_enabled = true
vnc_keymap = en-us
network_manager = nova.network.manager.FlatDHCPManager
firewall_driver = nova.virt.firewall.NoopFirewallDriver
multi_host = True
flat_interface = eth1
flat_network_bridge = br1
public_interface = eth0
instance_usage_audit = True
instance_usage_audit_period = hour
notify_on_state_change = vm_and_task_state
notification_driver = nova.openstack.common.notifier.rpc_notifier
compute_scheduler_driver = nova.scheduler.simple.SimpleScheduler




















auth_host = 127.0.0.1
auth_port = 35357
auth_protocol = http
admin_user = nova
admin_tenant_name = service
admin_password = service
  

  (2).修改instance实例存放路径
  由于上述配置文件修改了instance实例的存放位置,所以要拷贝原nova目录到新路径,并修改权限:

  # cp -av /var/lib/nova /openstack/
  # chown -R nova:nova /openstack/nova
  (3).启动libvirt服务,关闭virbr0接口
  # service libvirtd start
  
  # virsh net-list                            //查看virbr0接口
  名称               状态   自动开始Persistent
  --------------------------------------------------
  default            活动   yes         yes
  

  # virsh net-destroy default            //关闭virbr0网络
  # virsh net-undefine default          //删除virbr0接口
  # service libvirtd restart               //重启libvirtd服务

  # chkconfig libvirtd on                   //设置libvirtd服务开机启动
  7.4.启动Nova相关服务
  
  # service messagebus start
  # chkconfig messagebus on
  # service openstack-nova-api start
  # service openstack-nova-cert start
  # service openstack-nova-consoleauth start
  # service openstack-nova-scheduler start
  # service openstack-nova-conductor start
  # service openstack-nova-novncproxy start
  # service openstack-nova-compute start
  # service openstack-nova-network start
  设置开机启动:
  
  # chkconfig openstack-nova-api on
  # chkconfig openstack-nova-cert on
  # chkconfig openstack-nova-consoleauth on
  # chkconfig openstack-nova-scheduler on
  # chkconfig openstack-nova-conductor on
  # chkconfig openstack-nova-novncproxy on
  # chkconfig openstack-nova-compute on
  # chkconfig openstack-nova-network on
  

  7.5.Nova测试
  (1).创建网络:
  # nova network-create vmnet10 --fixed-range-v4=10.1.1.0/24 --bridge=br1 --bridge-interface=eth1 --multi-host=T --dns1=202.106.0.20 --dns2=202.96.69.38
  
  # nova network-list
  +--------------------------------------+-------+------------------+
  | ID                                 | Label | Cidr             |
  +--------------------------------------+-------+------------------+
  | 5aa4cba3-7227-40b5-9ca2-39e78680411e | vmnet | 10.1.1.0/24      |
  +--------------------------------------+-------+------------------+
  # nova-manage network list
  id    IPv4            IPv6   start address   DNS1               DNS2                VlanID    project   uuid         
  1    10.1.1.0/24None   10.1.1.2            202.106.0.20   202.96.69.38   None      None       5aa4cba3-7227-40b5-9ca2-39e78680411e
  (2).设置安全组:
  
  # nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
  +-------------+-----------+---------+-----------+--------------+
  | IP Protocol | From Port | To Port | IP Range| Source Group |
  +-------------+-----------+---------+-----------+--------------+
  | tcp         | 22      | 22      | 0.0.0.0/0 |            |
  +-------------+-----------+---------+-----------+--------------+
  # nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
  +-------------+-----------+---------+-----------+--------------+
  | IP Protocol | From Port | To Port | IP Range| Source Group |
  +-------------+-----------+---------+-----------+--------------+
  | icmp      | -1      | -1      | 0.0.0.0/0 |            |
  +-------------+-----------+---------+-----------+--------------+
  (3).查看当前可用镜像:
  
  # nova image-list
  +--------------------------------------+---------------+--------+--------+
  | ID                                 | Name          | Status | Server |
  +--------------------------------------+---------------+--------+--------+
  | a7327fef-aa62-4bb5-ab61-d11fb8ff4d65 | centos6.4_20G | ACTIVE |      |
  +--------------------------------------+---------------+--------+--------+
  (4).创建实例:

  
  # nova boot --flavor 2 --image centos6.4_20G vm-00
  +--------------------------------------+------------------------------------------------------+
  | Property                           | Value                                                |
  +--------------------------------------+------------------------------------------------------+
  | OS-DCF:diskConfig                  | MANUAL                                             |
  | OS-EXT-AZ:availability_zone          | nova                                                 |
  | OS-EXT-SRV-ATTR:host               | -                                                    |
  | OS-EXT-SRV-ATTR:hypervisor_hostname| -                                                    |
  | OS-EXT-SRV-ATTR:instance_name      | instance-00000001                                    |
  | OS-EXT-STS:power_state               | 0                                                    |
  | OS-EXT-STS:task_state                | scheduling                                           |
  | OS-EXT-STS:vm_state                  | building                                             |
  | OS-SRV-USG:launched_at               | -                                                    |
  | OS-SRV-USG:terminated_at             | -                                                    |
  | accessIPv4                           |                                                      |
  | accessIPv6                           |                                                      |
  | adminPass                            | VZDpnc6LeSSm                                       |
  | config_drive                         |                                                      |
  | created                              | 2014-05-22T10:03:57Z                                 |
  | flavor                               | m1.small (2)                                       |
  | hostId                               |                                                      |
  | id                                 | f469964e-9700-466d-9845-eeb2ff1ab183               |
  | image                              | centos6.4_20G (a7327fef-aa62-4bb5-ab61-d11fb8ff4d65) |
  | key_name                           | -                                                    |
  | metadata                           | {}                                                   |
  | name                                 | vm-00                                                |
  | os-extended-volumes:volumes_attached | []                                                   |
  | progress                           | 0                                                    |
  | security_groups                      | default                                              |
  | status                               | BUILD                                                |
  | tenant_id                            | 424c9716df1449829b204856d246f924                     |
  | updated                              | 2014-05-22T10:03:57Z                                 |
  | user_id                              | 46c6295334154e259c4fe793ea341986                     |
  +--------------------------------------+------------------------------------------------------+
  
(5).查看实例运行状态:


# nova list
  +--------------------------------------+-------+--------+------------+-------------+---------------------+
  | ID                                 | Name| Status | Task State | Power State | Networks            |
  +--------------------------------------+-------+--------+------------+-------------+---------------------+
  | f469964e-9700-466d-9845-eeb2ff1ab183 | vm-00 | ACTIVE | -          | Running   | vmnet=10.1.1.2      |
  +--------------------------------------+-------+--------+------------+-------------+---------------------+


  8.安装配置Horizon
  8.1.安装Horizon服务
  # yum -y install openstack-dashboard
  8.2.修改配置文件
  (1).修改local_settings文件
  # cp -av /etc/openstack-dashboard/local_settings /etc/openstack-dashboard/local_settings_bak
  # vi /etc/openstack-dashboard/local_settings
  DEBUG = True
  ……………………
  (2).修改httpd.conf文件
  # vi /etc/httpd/conf/httpd.conf
  ……………………

  
  #ServerName www.example.com:80
  ServerName 0.0.0.0:80
  ……………………

(3).启动http服务,设置开机启动
# service httpd start
# chkconfig httpd on
(4).重启api服务
  # service openstack-nova-api restart
  (5).添加iptables规则
  # iptables -I INPUT -p tcp --dport 80 -j ACCEPT
  # iptables -I INPUT -p tcp -m multiport --dports 5900:6000 -j ACCEPT
  # iptables -I INPUT -p tcp --dport 6080 -j ACCEPT
  # service iptables save
  (6).访问dashboard页面

  http://192.168.20.100/dashboard

  用户名:admin
  密码:password
  
http://c.hiphotos.bdimg.com/album/pic/item/a71ea8d3fd1f4134b54fa08b271f95cad0c85ece.jpg
http://a.hiphotos.bdimg.com/album/pic/item/dcc451da81cb39dbfeb6c2a3d2160924aa1830d4.jpg
  创建新用户

  (1).为新用户创建一个tenant:
  # keystone tenant-create --name=manager --description='Manager Tenant'
  
  WARNING: Bypassing authentication using a token & endpoint (authentication credentials are being ignored).
  +-------------+----------------------------------+
  |   Property|            Value               |
  +-------------+----------------------------------+
  | description |          Manager Tenant          |
  |   enabled   |               True               |
  |      id   | abc5551b3e854e27a5c295b6b548e1f6 |
  |   name    |             manager            |
  +-------------+----------------------------------+
  (2).创建新用户:
  # keystone user-create --name=manager --pass=password --email=manager@chensh.net
  
  WARNING: Bypassing authentication using a token & endpoint (authentication credentials are being ignored).
  +----------+----------------------------------+
  | Property |            Value               |
  +----------+----------------------------------+
  |email   |      manager@chensh.net      |
  | enabled|               True               |
  |    id    | 325191b6c6f64e768db7cc098fdeefd8 |
  |   name   |             manager            |
  | username |             manager            |
  +----------+----------------------------------+
  (3).创建一个角色:

  # keystone role-create --name=manager
  
  WARNING: Bypassing authentication using a token & endpoint (authentication credentials are being ignored).
  +----------+----------------------------------+
  | Property |            Value               |
  +----------+----------------------------------+
  |    id    | 1c86f264fe14469d91a26e3b848f2fe4 |
  |   name   |             manager            |
  +----------+----------------------------------+
  (4).关联用户、tenant和角色:
  # keystone user-role-add --user=manager --tenant=manager --role=manager
  WARNING: Bypassing authentication using a token & endpoint (authentication credentials are being ignored).
  (5).将nova用户赋予新角色:
  # keystone user-role-add --user=nova --tenant=service --role=manager
  WARNING: Bypassing authentication using a token & endpoint (authentication credentials are being ignored).
  (6).使用新用户登录:
  
http://192.168.20.100/dashboard

用户名:manager
密码:password
  
http://g.hiphotos.bdimg.com/album/pic/item/8c1001e93901213f5ea2ee2956e736d12e2e95b6.jpg
http://c.hiphotos.bdimg.com/album/pic/item/d788d43f8794a4c247af47de0cf41bd5ac6e39b2.jpg
  CentOS6.4安装OpenStack Icehouse controller (三)

  
页: [1]
查看完整版本: CentOS6.4安装OpenStack Icehouse controller (二)