CentOS 6.2下源代码安装OpenStack图文详解(5)

1.1复制默认配置文件:
[ugyn@cc image]$ cd ~/install/nova-2012.1
[ugyn@cc nova-2012.1]$ sudo cp -R etc/nova /etc/nova
[ugyn@cc nova-2012.1]$ sudo chown -R ugyn:ugyn /etc/nova

1.2创建/etc/nova/nova.conf
将配置内容复制进来并修改相关选项
我的nova.conf内容如下:

[DEFAULT]
# LOGS/STATE
verbose=True

# AUTHENTICATION
auth_strategy=keystone

# SCHEDULER
compute_scheduler_driver=nova.scheduler.filter_scheduler.FilterScheduler

# VOLUMES
volume_group=nova-volumes
volume_name_template=volume-%08x
iscsi_helper=tgtadm

# DATABASE
sql_connection=mysql://nova:nova@10.17.23.95/nova

# COMPUTE
libvirt_type=kvm
connection_type=libvirt
instances_path=/home/ugyn/instances
instance_name_template=instance-%08x
api_paste_config=/etc/nova/api-paste.ini
allow_resize_to_same_host=True

# APIS
osapi_compute_extension=nova.api.openstack.compute.contrib.standard_extensions
ec2_dmz_host=10.17.23.95
s3_host=10.17.23.95

# RABBITMQ
rabbit_host=10.17.23.95
rabbit_userid=guest
rabbit_password=service123

# GLANCE
image_service=nova.image.glance.GlanceImageService
glance_api_servers=10.17.23.95:9292

# NETWORK
network_manager=nova.network.manager.FlatDHCPManager
force_dhcp_release=True
dhcpbridge_flagfile=/etc/nova/nova.conf
firewall_driver=nova.virt.libvirt.firewall.IptablesFirewallDriver
my_ip=10.17.23.95
public_interface=br100
vlan_interface=eth0
flat_network_bridge=br100
flat_interface=eth0
fixed_range=10.0.0.0/24

# NOVNC CONSOLE
novncproxy_base_url=http://10.17.23.95:6080/vnc_auto.html
xvpvncproxy_base_url=http://10.17.23.95:6081/console
vncserver_proxyclient_address=127.0.0.1
vncserver_listen=127.0.0.1

bindir=/usr/bin

除了一般的修改外,我还加了两个参数instances_path我把这个设到我的个人文件夹来了,bindir这个很重要,否则启动nova-network时会有问题。
创建该文件夹:[ugyn@cc nova-2012.1]$ mkdir ~/instances
nova默认采用rabbitmq作为通信服务器,如果要用qpid,请把RABBITMQ相关选项替换成如下:
#QPID
rpc_backend=nova.rpc.impl_qpid
qpid的其它选项我这里保持默认,如果要设置请参考示例配置文件以下内容:

###### (IntOpt) Seconds between connection keepalive heartbeats

# qpid_heartbeat=5

###### (StrOpt) Qpid broker hostname

# qpid_hostname="localhost"

###### (StrOpt) Password for qpid connection

# qpid_password=""

###### (StrOpt) Qpid broker port

# qpid_port="5672"

###### (StrOpt) Transport to use, either 'tcp' or 'ssl'

# qpid_protocol="tcp"

###### (BoolOpt) Automatically reconnect

# qpid_reconnect=true

###### (IntOpt) Equivalent to setting max and min to the same value

# qpid_reconnect_interval=0

###### (IntOpt) Maximum seconds between reconnection attempts

# qpid_reconnect_interval_max=0

###### (IntOpt) Minimum seconds between reconnection attempts

# qpid_reconnect_interval_min=0

###### (IntOpt) Max reconnections before giving up

# qpid_reconnect_limit=0

###### (IntOpt) Reconnection timeout in seconds

# qpid_reconnect_timeout=0

###### (StrOpt) Space separated list of SASL mechanisms to use for auth

# qpid_sasl_mechanisms=""

###### (BoolOpt) Disable Nagle algorithm

# qpid_tcp_nodelay=true

###### (StrOpt) Username for qpid connection

# qpid_username=""



1.3配置nova的keystone认证:

[ugyn@cc nova-2012.1]$ vim /etc/nova/api-paste.ini
修改:
admin_tenant_name = %SERVICE_TENANT_NAME%
admin_user = %SERVICE_USER%
admin_password = %SERVICE_PASSWORD%
为:
admin_tenant_name = service
admin_user = nova
admin_password = service123

1.4创建存储卷:

[ugyn@cc nova-2012.1]$ mkdir /home/ugyn/novaimages
[ugyn@cc nova-2012.1]$ dd if=/dev/zero of=/home/ugyn/novaimages/nova-volumes.img bs=1M seek=100k count=0
[ugyn@cc nova-2012.1]$ sudo vgcreate nova-volumes $(sudo losetup --show -f /home/ugyn/novaimages/nova-volumes.img)

1.5初始化数据库:

[ugyn@cc nova-2012.1]$ nova-manage db sync

1.6解决启动nova-network、nova-volume出现timeout错误:
https://lists.launchpad.net/openstack/msg02565.html


2运行

先在每个新开终端运行nova-api、nova-cert、nova-compute、nova-network、nova-objectstore、nova-scheluder、nova-volume查看各程序是否正常运行,确定正常后可以关闭各程序,通过nova-all启动以上各个程序。

3.测试

3.1查看各服务状态:
[ugyn@cc nova-2012.1]$ nova-manage service list
2012-04-20 17:11:26 DEBUG nova.utils [req-12fde12c-11e2-4861-8e53-03af10832e4b None None] backend <module 'nova.db.sqlalchemy.api' from

'/usr/lib/Python2.6/site-packages/nova-2012.1-py2.6.egg/nova/db/sqlalchemy/api.pyc'> from (pid=1095) __get_backend /usr/lib/python2.6/site-

packages/nova-2012.1-py2.6.egg/nova/utils.py:658
2012-04-20 17:11:26 WARNING nova.utils [req-12fde12c-11e2-4861-8e53-03af10832e4b None None] /usr/lib64/python2.6/site-

packages/sqlalchemy/pool.py:681: SADeprecationWarning: The 'listeners' argument to Pool (and create_engine()) is deprecated.  Use event.listen

().
  Pool.__init__(self, creator, **kw)

2012-04-20 17:11:26 WARNING nova.utils [req-12fde12c-11e2-4861-8e53-03af10832e4b None None] /usr/lib64/python2.6/site-

packages/sqlalchemy/pool.py:159: SADeprecationWarning: Pool.add_listener is deprecated.  Use event.listen()
  self.add_listener(l)

Binary           Host                                 Zone             Status     State Updated_At
nova-cert        cc.sigsit.org                        nova             enabled    :-)   2012-04-20 09:11:24
nova-compute     cc.sigsit.org                        nova             enabled    :-)   2012-04-20 09:11:22
nova-network     cc.sigsit.org                        nova             enabled    :-)   2012-04-20 09:11:23
nova-scheduler   cc.sigsit.org                        nova             enabled    :-)   2012-04-20 09:11:23
nova-volume      cc.sigsit.org                        nova             enabled    :-)   2012-04-20 09:11:21

注意::-)表示正在运行;XXX表示服务启动时出错已停止;如果服务从未正常启动过则不会出现在这里


3.2创建网络:
[ugyn@cc nova-2012.1]$ nova-manage network create private 10.0.0.0/24 1 256 --bridge=br100

3.3查看信息:


更多信息请运行nova help查看相关命令

3.4启动一个实例:

创建密钥:
ugyn@cc nova-2012.1]$ cd
请先关闭selinux,否则无法创建密钥,方法如下:
[ugyn@cc ~]$ sudo vim /etc/sysconfig/selinux
修改:SELINUX=disabled
不想重启执行以下命令:
[ugyn@cc ~]$ sudo setenforce 0

[ugyn@cc ~]$ nova keypair-add mykey > oskey.priv
[ugyn@cc ~]$ chmod 600 oskey.priv
创建实例:
[ugyn@cc ~]$ nova boot myserver --flavor 1 --key_name mykey --image tty-linux


可通过nova show myserver或nova list 查看实例状态,当实例状态为active时可通过ssh连接了。


通过ssh登录实例:
[ugyn@cc ~]$ ssh -i oskey.priv root@10.0.0.2

查看实例日志:
[ugyn@cc ~]$ nova console-log myserver
删除实例:
[ugyn@cc ~]$ nova delete myserver
触认是否删除:
[ugyn@cc ~]$ nova list

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/27cf8aa4b835e702a452c17a79bcdce6.html