CentOS6.4部署OpenStack Havana(Nova-Network版) (下)


CentOS6.4部署OpenStack Havana(Nova-Network版) (上)


7.4.nova測試:


(1).創建網絡:

[root@openstack ~]# nova network-create vmnet --fixed-range-v4=10.1.1.0/24 --bridge-interface=br1 --multi-host=T

[root@openstack ~]#nova network-list

+--------------------------------------+-------+-------------+

| ID                                   | Label | Cidr        |

+--------------------------------------+-------+-------------+

| d3bc4874-2b4b-4abf-b963-0e5ae69b7b31 | vmnet | 10.1.1.0/24 |

+--------------------------------------+-------+-------------+

[root@openstack ~]# nova-manage network list

id    IPv4           IPv6     start address  DNS1      DNS2     VlanID    project    uuid           

1     10.1.1.0/24    None     10.1.1.2       8.8.4.4   None     None      None       d3bc4874-2b4b-4abf-b963-0e5ae69b7b31


(2).設置安全組:

[root@openstack ~]# 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 |              |

+-------------+-----------+---------+-----------+--------------+

[root@openstack ~]# 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).創建虛擬機實例:

查看可用鏡像:

[root@openstack ~]# nova image-list

+--------------------------------------+-----------+--------+--------------------------------------+

| ID                                   | Name      | Status | Server                               |

+--------------------------------------+-----------+--------+--------------------------------------+

| 45456157-9b46-4e40-8ee3-fbb2e40f227b | centos6.4 | ACTIVE |                                      |

+--------------------------------------+-----------+--------+--------------------------------------+

創建虛擬機實例:

[root@openstack ~]# nova boot --flavor 1 --image centos6.4 vm01

+--------------------------------------+--------------------------------------------------+

| 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                            | hZBG4A7eJMdL                                     |

| config_drive                         |                                                  |

| created                              | 2014-03-31T07:12:55Z                             |

| flavor                               | m1.tiny                                          |

| hostId                               |                                                  |

| id                                   | f754afe1-784f-41d0-9139-a05d25eaca20             |

| image                                | centos6.4 (45456157-9b46-4e40-8ee3-fbb2e40f227b) |

| key_name                             | -                                                |

| metadata                             | {}                                               |

| name                                 | vm01                                             |

| os-extended-volumes:volumes_attached | []                                               |

| progress                             | 0                                                |

| security_groups                      | default                                          |

| status                               | BUILD                                            |

| tenant_id                            | 446893f3733b4294a7080f3b0bf1ba61                 |

| updated                              | 2014-03-31T07:12:55Z                             |

| user_id                              | 2d7f8e7ec15c40cfb4209134cb5b30ba                 |

+--------------------------------------+--------------------------------------------------+

查看虛擬機實例運行狀態:

[root@openstack ~]# nova list

+--------------------------------------+-----------------------+--------+------------+-------------+-----------------+

| ID                                   | Name                  | Status | Task State | Power State | Networks        |

+--------------------------------------+-----------------------+--------+------------+-------------+-----------------+

| f754afe1-784f-41d0-9139-a05d25eaca20 | vm01                  | ACTIVE | -          | Running     | vmnet=10.1.1.2  |

+--------------------------------------+-----------------------+--------+------------+-------------+-----------------+

測試虛擬機實例連通性:
[root@openstack ~]# ping 10.1.1.2

PING 10.1.1.2 (10.1.1.2) 56(84) bytes of data.

64 bytes from 10.1.1.2: icmp_seq=1 ttl=64 time=0.057 ms

64 bytes from 10.1.1.2: icmp_seq=2 ttl=64 time=0.037 ms

--- 10.1.1.2 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1639ms

rtt min/avg/max/mdev = 0.037/0.047/0.057/0.010 ms


8.安裝配置Horizon

(1).安裝Horizon

[root@openstack ~]# yum -y install openstack-dashboard


(2).修改local_settings文件,將DEBUG = False修改為DEBUG = True

[root@openstack ~]# vi /etc/openstack-dashboard/local_settings

DEBUG = True

……


(3).修改httpd.conf文件,將#ServerName www.example.com:80修改為ServerName 192.168.10.21:80

[root@openstack ~]# vi /etc/httpd/conf/httpd.conf

#ServerName www.example.com:80

ServerName 192.168.10.21:80


(4).修改local_settings.py文件,將"Member"修改為"admin"

[root@openstack ~]# find / -name local_settings.py

/usr/share/openstack-dashboard/openstack_dashboard/local/local_settings.py
[root@openstack keystone]# cat /usr/share/openstack-dashboard/openstack_dashboard/local/local_settings.py | grep OPENSTACK_KEYSTONE_DEFAULT_ROLE
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "Member"
[root@openstack keystone]# vi /usr/share/openstack-dashboard/openstack_dashboard/local/local_settings.py
#OPENSTACK_KEYSTONE_DEFAULT_ROLE = "Member"
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "admin" 


(5).啟動http服務,設置開機自啟動

[root@openstack ~]# service httpd start

[root@openstack ~]# chkconfig httpd on


(6).重啟nova-api服務

[root@openstack ~]# service openstack-nova-api restart


(7).添加防火牆策略

[root@openstack ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT

[root@openstack ~]# iptables -I INPUT -p tcp -m multiport --dports 5900:6000 -j ACCEPT

[root@openstack ~]# iptables -I INPUT -p tcp --dport 6080 -j ACCEPT

[root@openstack ~]# service iptables save


Horizon安裝完成,使用http://192.168.10.21/dashboard訪問openstack web界面。

用戶名:admin

密碼:password


9.添加新項目

(1).為操作員用戶創建一個tenant:

[root@openstack ~]# keystone tenant-create --name=manager --description='Manager Tenant'


(2).創建操作員用戶:

[root@openstack ~]# keystone user-create --name=manager --pass=password --email=manager@chensh.net


(3).創建一個管理角色manager:

[root@openstack ~]# keystone role-create --name=manager


(4).將manager角色添加到用戶:

[root@openstack ~]# keystone user-role-add --user=manager --tenant=manager --role=manager


(5).將nova角色添加到用戶:

[root@openstack ~]# keystone user-role-add --user=nova --tenant=service --role=manager 


*******************************************************************************************

三、計算節點安裝(Node01)

1.基礎配置

操作系統使用CentOS-6.4-x86_64-minimal.iso,安裝過程省略,本文采用yum源安裝。


(1).導入第三方安裝源

[root@node01 ~]# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

[root@node01 ~]# rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

[root@node01 ~]# yum install http://repos.fedorapeople.org/repos/openstack/openstack-havana/rdo-release-havana-7.noarch.rpm


(2).配置/etc/hosts文件

[root@node01 ~]# vi /etc/hosts


127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.10.21   openstack

192.168.10.22   node01


(3).配置網絡


[root@node01 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 

DEVICE="eth0"

BOOTPROTO="static"

HWADDR="E4:1F:13:45:AB:C1"

ONBOOT="yes"

IPADDR=192.168.10.22

NETMASK=255.255.255.0

GATEWAY=192.168.10.1

TYPE="Ethernet"

[root@openstack ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE="eth1"

BOOTPROTO="none"

HWADDR="E4:1F:13:45:AB:C3"

ONBOOT="yes"

TYPE="Ethernet"


(4).關閉selinux:

[root@node01 ~]# more /etc/selinux/config 

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

#       enforcing - SELinux security policy is enforced.

#       permissive - SELinux prints warnings instead of enforcing.

#       disabled - SELinux is fully disabled.

SELINUX=disabled

# SELINUXTYPE= type of policy in use. Possible values are:

#       targeted - Only targeted network daemons are protected.

#       strict - Full SELinux protection.

SELINUXTYPE=targeted

[root@node01 ~]# setenforce 0


(5).修改/etc/sysctl.conf參數:

[root@node01 ~]# vi /etc/sysctl.conf

……………………

net.ipv4.ip_forward = 1

……………………
[root@node01 ~]#sysctl -p                    #使sysctl.conf配置生效



2.安裝配置NTP客戶端

(1).安裝NTP客戶端服務:

[root@node01 ~]# yum -y install ntpdate


(2).設置時間同步:

[root@node01 ~]# ntpdate 192.168.10.21

31 Mar 16:17:03 ntpdate[5848]: the NTP socket is in use, exiting


(3).設置計划任務:

[root@node01 ~]# crontab -e

插入下行內容:

*/5 * * * * ntpdate 192.168.10.21 >> /var/log/ntpdate.log


3.設置環境變量

修改.bash_profile文件,添加以下參數:

[root@node01 ~]# vi .bash_profile

………………

export OS_USERNAME=admin

export OS_TENANT_NAME=admin

export OS_PASSWORD=password

export OS_AUTH_URL=http://192.168.10.21:5000/v2.0

export SERVICE_ENDPOINT=http://192.168.10.21:35357/v2.0

export SERVICE_TOKEN=12dd70ede7c9d9d3ed3c

………………

執行下面的命令使變量即時生效:

[root@node01 ~]# source .bash_profile



4.安裝配置libvirt服務

(1).安裝libvirt服務:

[root@node01 ~]# yum -y install qemu-kvm libvirt


(2)啟動libvirt服務:

[root@node01 ~]# service libvirtd start


(3)查看net-list,發現default:

[root@node01 ~]# virsh net-list

Name                 State      Autostart     Persistent

--------------------------------------------------

default              active     yes           yes


(4)刪除default,即virbr0:

[root@node01 ~]# virsh net-destroy default

Network default destroyed

[root@node01 ~]# virsh net-undefine default

Network default has been undefined


(5)重啟libvirtd服務,設置開機自啟動:

[root@node01 ~]# service libvirtd restart

[root@node01 ~]# chkconfig libvirtd on


5.安裝MySQL客戶端


(1).安裝mysql客戶端

[root@node01 ~]# yum -y install mysql


(2).檢查mysql數據庫連通性

[root@node01 ~]# mysql -h 192.168.10.21 -unova -pnova

Welcome to the MySQL monitor.  ………………

mysql> quit;

Bye


6.安裝配置Nova服務


(1)安裝nova-compute、nova-network、nova-scheduler

[root@node01 ~]# yum -y install openstack-nova-compute openstack-nova-network openstack-nova-scheduler


(2).修改nova配置文件

[root@node01 ~]# vi /etc/nova/nova.conf

[DEFAULT]

my_ip = 192.168.10.22

auth_strategy = keystone

state_path = /letv/openstack/lib/nova

verbose=True

allow_resize_to_same_host = true

rpc_backend = nova.openstack.common.rpc.impl_qpid

qpid_hostname = 192.168.10.21

libvirt_type = kvm

glance_api_servers = 192.168.10.21:9292

novncproxy_base_url = http://192.168.10.21:6080/vnc_auto.html

vncserver_listen = 192.168.10.22

vncserver_proxyclient_address = 192.168.10.22

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

[hyperv]

[zookeeper]

[osapi_v3]

[conductor]

[keymgr]

[cells]

[database]

sql_connection=mysql://nova:nova@192.168.10.21/nova

[image_file_url]

[baremetal]

[rpc_notifier2]

[matchmaker_redis]

[ssl]

[trusted_computing]

[upgrade_levels]

[matchmaker_ring]

[vmware]

[spice]

[keystone_authtoken]

auth_host = 192.168.10.21

auth_port = 35357

auth_protocol = http

admin_user = nova

admin_tenant_name = service

admin_password = service


因上管理節點nova.conf配置文件中修改了instances實例存放的位置,還需要作一下操作:

修改路徑,設置目錄權限:

[root@node01 ~]# cp -r /var/lib/nova/ /openstack/lib/

[root@node01 ~]# chown -R nova:nova /openstack/lib/nova/


(3).啟動nova相關服務,設置開機自啟動

[root@node01 ~]# service messagebus start

[root@node01 ~]# chkconfig messagebus on

[root@node01 ~]# service openstack-nova-compute start

[root@node01 ~]# service openstack-nova-network start

[root@node01 ~]# chkconfig openstack-nova-compute on

[root@node01 ~]# chkconfig openstack-nova-network on

*******************************************************************************************

OpenStack其他常用命令:

1.list nova服務,包含管理節點和計算節點

[root@openstack ~]# nova service-list

+------------------+-------------+----------+---------+-------+----------------------------+-----------------+

| Binary           | Host        | Zone     | Status  | State | Updated_at                 | Disabled Reason |

+------------------+-------------+----------+---------+-------+----------------------------+-----------------+

| nova-cert        | openstack   | internal | enabled | up    | 2014-03-31T08:59:50.000000 | -               |

| nova-consoleauth | openstack   | internal | enabled | up    | 2014-03-31T08:59:54.000000 | -               |

| nova-scheduler   | openstack   | internal | enabled | up    | 2014-03-31T08:59:48.000000 | -               |

| nova-conductor   | openstack   | internal | enabled | up    | 2014-03-31T08:59:52.000000 | -               |

| nova-compute     | openstack   | nova     | enabled | up    | 2014-03-31T08:59:56.000000 | -               |

| nova-compute     | node01      | nova     | enabled | up    | 2014-03-31T08:59:53.000000 | -               |

| nova-network     | openstack   | internal | enabled | up    | 2014-03-31T08:59:50.000000 | -               |

| nova-network     | node01      | internal | enabled | up    | 2014-03-31T08:59:56.000000 | -               |

| nova-scheduler   | node01      | internal | enabled | up    | 2014-03-31T08:59:52.000000 | -               |


2.查看計算節點:

[root@node01 ~]# nova hypervisor-list

+----+---------------------+

| ID | Hypervisor hostname |

+----+---------------------+

| 1  | openstack           |

| 2  | node01              |

+----+---------------------+


3.查看虛擬機模板配置:

[root@node01 ~]# nova flavor-list

+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+

| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |

+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+

| 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |

| 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      |

| 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      |

| 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      |

| 5  | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      |

+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+




注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2021 ITdaan.com