在CentOS上安裝和配置OpenStack Nova

來源:互聯網
上載者:User

因為 Python 的版本問題,在 CentOS 5.6 上安裝 OpenStack 不是件容易的事情,因為 OpenStack 是 Python 2.6 寫的,CentOS 5.6 上預設的是 Python 2.4 的環境,一些關鍵工具(比如 yum 等)和依賴關係都需要 2.4,不容易直接升級到 2.6,所以要在 CentOS 上安裝 OpenStack 的話簡單的辦法是直接用 CentOS 6.0(預設是 Python 2.6). OpenStack 的基本介紹以及如何在 Ubuntu 上安裝 OpenStack Nova 可以看:在 Ubuntu 上安裝和配置 OpenStack Nova. 對雲端運算平台感興趣的朋友可以看看另一個開源的雲端運算系統:在 CentOS 上安裝和配置 OpenNebula.

安裝和配置基本系統

在安裝完基本的 CentOS 6.0 系統後(迷你安裝)升級和更新整個系統,然後關閉 SELINUX 後重啟,為了簡單方便最好也關閉 iptables:

# yum update# yum upgrade# vi /etc/sysconfig/selinuxSELINUX=disabled# chkconfig iptables off# service iptables stop# shutdown -r now

安裝 OpenStack Nova

下載和安裝 OpenStack 源:

# wget http://yum.griddynamics.net/yum/diablo-3/openstack/openstack-repo-2011.3-0.3.noarch.rpm# rpm -ivh openstack-repo-2011.3-0.3.noarch.rpm

OpenStack Nova 需要在控制結點(Cloud Controller)和計算結點(Cloud Compute)上都安裝和啟用 libvirtd:

# yum install libvirt# chkconfig libvirtd on# service libvirtd start

如果伺服器用來做 Cloud Controller 結點需要安裝(OpenStack Nova 雲裡至少要有一台伺服器作為控制結點):

# yum install euca2ools openstack-nova-node-full unzip

如果伺服器只是做計算結點則需要在每個 Cloud Compute 結點上都安裝(理論上 OpenStack Nova 雲裡可以有無數個計算結點):

# yum install euca2ools openstack-nova-node-full

配置 MySQL 資料庫

OpenStack Nova 需要資料庫的支援,這裡用的是 MySQL:

# service mysqld start# chkconfig mysqld on# service rabbitmq-server start# chkconfig rabbitmq-server on

修改 MySQL 綁定地址,以便其他的節點伺服器也能訪問這個資料庫:

# vi /etc/my.cnf...#bind-address = 127.0.0.1bind-address = 0.0.0.0...# service mysql restart

建立一個名為 nova 的資料庫,並設定 root 從任何 IP 訪問的許可權和密碼:

# mysql -uroot -ppassword -e 'CREATE DATABASE nova;'# mysql -uroot -ppassword -e "GRANT ALL PRIVILEGES ON *.* TO \'root'@'%' WITH GRANT OPTION;"# mysql -uroot -ppassword -e "SET PASSWORD FOR \'root'@'%' = PASSWORD('password');"

配置 Nova:

$ sudo vi /etc/nova/nova.conf--verbose=false--ec2_url=http://172.16.39.111:8773/services/Cloud--s3_host=172.16.39.111--cc_host=172.16.39.111--rabbit_host=172.16.39.111--sql_connection=mysql://nova:nova@172.16.39.111/nova--glance_api_servers=172.16.39.111:9292--use_s3=true--libvirt_type=kvm--use_syslog=false--node_availability_zone=nova--logdir=/var/log/nova--logging_context_format_string=%(asctime)s %(name)s: %(levelname)s [%(request_id)s %(user)s %(project)s] %(message)s--logging_default_format_string=%(asctime)s %(name)s: %(message)s--logging_debug_format_suffix=--use_cow_images=true--auth_driver=nova.auth.dbdriver.DbDriver--network_manager=nova.network.manager.VlanManager--scheduler_driver=nova.scheduler.zone.ZoneScheduler--image_service=nova.image.glance.GlanceImageService--use_ipv6=false--ca_path=/var/lib/nova/CA--keys_path=/var/lib/nova/keys--images_path=/var/lib/nova/images--buckets_path=/var/lib/nova/buckets--instances_path=/var/lib/nova/instances--networks_path=/var/lib/nova/networks--dhcpbridge_flagfile=/etc/nova/nova.conf--dhcpbridge=/usr/bin/nova-dhcpbridge--injected_network_template=/usr/share/nova/interfaces/--libvirt_xml_template=/usr/share/nova/libvirt.xml.template--vpn_client_template=/usr/share/nova/client.ovpn.template--credentials_template=/usr/share/nova/novarc.template--state_path=/var/lib/nova--lock_path=/var/lib/nova/tmp--vnc_enabled=true--vncproxy_url=http://172.16.39.111:6080--vncserver_host=0.0.0.0--vnc_token_ttl=300

每次重啟一堆服務很麻煩,寫個指令碼方便重啟 nova 所有服務:

# vi nova-restart-all.sh#!/bin/bashfor n in api compute network objectstore scheduler vncproxy; do service openstack-nova-$n restart; doneservice openstack-glance-api restartservice openstack-glance-registry restart# chmod +x nova-restart-all.sh# ./nova-restart-all.sh

使用 Nova

接下來的步驟和在 Ubuntu 上安裝和配置 OpenStack Nova 差不多,這裡就不再贅述:

# nova-manage db sync# nova-manage network create 192.168.0.0/24 1 255# nova-manage floating create 10.10.10.2 10.10.10.224/27# nova-manage user admin vpsee# nova-manage project create mycloud vpsee

匯出許可權資訊:

# mkdir /home/vpsee/creds# nova-manage project zipfile mycloud vpsee /home/vpsee/creds/novacreds.zip# cd /home/vpsee/creds# unzip novacreds.zip# chown -R vpsee:vpsee /home/vpsee/creds/# source /home/vpsee/creds/novarc

再次重啟 nova 相關的所有服務:

# ./nova-restart-all.sh

如果一切正常的話,應該可以看到下面的類似資訊,這樣 OpenStack Nova 就成功安裝了:

# euca-describe-availability-zones verboseAVAILABILITYZONE nova availableAVAILABILITYZONE |- node00AVAILABILITYZONE | |- nova-network enabled :-) 2011-08-16 19:28:13AVAILABILITYZONE | |- nova-compute enabled :-) 2011-08-16 19:28:22AVAILABILITYZONE | |- nova-scheduler enabled :-) 2011-08-16 19:28:14

啟動第一個執行個體

啟動執行個體之前需要先上傳一個系統模版(稱之為鏡像 image),自己製作 image 有點麻煩,可以參考:為 OpenStack Nova 製作 Ubuntu 鏡像 和 為 OpenStack Nova 製作 Windows 鏡像。

有了 image 後就可以啟動執行個體了,就像在 C++/Java 等物件導向語言裡面有了類(class)以後可以建立執行個體(instance)一樣,這裡有了 OS image 以後就可以建立 OS instance 了。啟動和訪問執行個體可以看這篇的相關部分。

原文:http://www.vpsee.com/2011/08/install-openstack-nova-on-centos/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.