next up previous contents
Next: 建立 Instances Up: Nova Compute and Controller Previous: 認識 Nova   Contents

Nova 安裝

  1. 安裝 nova 套件
    [root@kvm4 ~]# yum install -y openstack-nova openstack-nova-novncproxy
    
  2. 載入管理者環境變數。
    [root@kvm4 ~]# source keystonerc_admin 
    [root@kvm4 ~(keystone_admin)]#
    
  3. 改變 nova 管理紀錄檔的用戶與群組為 nova。
    [root@kvm4 ~(keystone_admin)]# chown nova:nova /var/log/nova/nova-manage.log
    
  4. 初使化 nova 資料庫。
    [root@kvm4 ~(keystone_admin)]# openstack-db --init --service nova \
    --password 123qwe --rootpw 123qwe
    Verified connectivity to MySQL.
    Creating 'nova' database.
    Updating 'nova' database password in /etc/nova/nova.conf
    Initializing the nova database, please wait...
    Complete!
    
  5. 產生用戶 nova。
    [root@kvm4 ~(keystone_admin)]# keystone user-create --name nova --pass 123qwe
    +----------+----------------------------------+
    | Property |              Value               |
    +----------+----------------------------------+
    |  email   |                                  |
    | enabled  |               True               |
    |    id    | 490e3d3086dd4b628ca4015014c3face |
    |   name   |               nova               |
    | tenantId |                                  |
    +----------+----------------------------------+
    
  6. 增加用戶 nova 在租戶 services 的角色為 admin。
    [root@kvm4 ~(keystone_admin)]# keystone user-role-add \
    --user nova --role admin --tenant services
    
  7. 增加 nova service,並記其 id,以建立此服務的 endpoint。
    [root@kvm4 ~(keystone_admin)]# keystone service-create \
    --name nova --type compute --description "Openstack Compute Service"
    +-------------+----------------------------------+
    |   Property  |              Value               |
    +-------------+----------------------------------+
    | description |    Openstack Compute Service     |
    |      id     | fa2efe6481eb45898f3b0ce4169584dd |
    |     name    |               nova               |
    |     type    |             compute              |
    +-------------+----------------------------------+
    
  8. 建立 nova service 的 endpoint。
    [root@kvm4 ~(keystone_admin)]# keystone endpoint-create \
    --service-id fa2efe6481eb45898f3b0ce4169584dd \
    --publicurl 'http://kvm4.deyu.wang:8774/v2/%(tenant_id)s' \
    --adminurl 'http://kvm4.deyu.wang:8774/v2/%(tenant_id)s' \
    --internalurl 'http://kvm4.deyu.wang:8774/v2/%(tenant_id)s'
    +-------------+---------------------------------------------+
    |   Property  |                    Value                    |
    +-------------+---------------------------------------------+
    |   adminurl  | http://kvm4.deyu.wang:8774/v2/%(tenant_id)s |
    |      id     |       b460744fb0ba494e8408b5a5bf301f5d      |
    | internalurl | http://kvm4.deyu.wang:8774/v2/%(tenant_id)s |
    |  publicurl  | http://kvm4.deyu.wang:8774/v2/%(tenant_id)s |
    |    region   |                  regionOne                  |
    |  service_id |       fa2efe6481eb45898f3b0ce4169584dd      |
    +-------------+---------------------------------------------+
    
  9. 使用 openstack-config 工具設定 nova。
    [root@kvm4 ~(keystone_admin)]# openstack-config --set /etc/nova/api-paste.ini \
    filter:authtoken admin_tenant_name services
    [root@kvm4 ~(keystone_admin)]# openstack-config --set /etc/nova/api-paste.ini \
    filter:authtoken admin_user nova
    [root@kvm4 ~(keystone_admin)]# openstack-config --set /etc/nova/api-paste.ini \
    filter:authtoken admin_password 123qwe
    [root@kvm4 ~(keystone_admin)]# openstack-config --set /etc/nova/api-paste.ini \
    filter:authtoken admin_host 192.168.122.4
    [root@kvm4 ~(keystone_admin)]# openstack-config --set /etc/nova/nova.conf \
    DEFAULT qpid_username qpidauth
    [root@kvm4 ~(keystone_admin)]# openstack-config --set /etc/nova/nova.conf \
    DEFAULT qpid_password 123qwe
    [root@kvm4 ~(keystone_admin)]# openstack-config --set /etc/nova/nova.conf \
    DEFAULT qpid_protocol ssl
    [root@kvm4 ~(keystone_admin)]# openstack-config --set /etc/nova/nova.conf \
    DEFAULT novncproxy_base_url http://192.168.122.4:6080/vnc_auto.html
    [root@kvm4 ~(keystone_admin)]# openstack-config --set /etc/nova/nova.conf \
    DEFAULT vncserver_listen 192.168.122.4
    [root@kvm4 ~(keystone_admin)]# openstack-config --set /etc/nova/nova.conf \
    DEFAULT vncserver_proxyclient_address 192.168.122.4
    [root@kvm4 ~(keystone_admin)]# openstack-config --set /etc/nova/nova.conf \
    DEFAULT libvirt_vif_driver nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver
    [root@kvm4 ~(keystone_admin)]# openstack-config --set /etc/nova/nova.conf \
    DEFAULT auth_strategy keystone
    [root@kvm4 ~(keystone_admin)]# openstack-config --set /etc/nova/nova.conf \
    DEFAULT libvirt_type qemu
    [root@kvm4 ~(keystone_admin)]# openstack-config --set /etc/nova/nova.conf \
    DEFAULT libvirt_cpu_mode none
    [root@kvm4 ~(keystone_admin)]# openstack-config --set /etc/nova/nova.conf \
    DEFAULT verbose true
    
  10. 啟動並設定開機啟動 nova 相關的服務。
    [root@kvm4 ~(keystone_admin)]# /etc/init.d/libvirtd start
    Starting libvirtd daemon:                          [  OK  ]
    [root@kvm4 ~(keystone_admin)]# /etc/init.d/openstack-nova-scheduler start
    Starting openstack-nova-scheduler:                 [  OK  ]
    [root@kvm4 ~(keystone_admin)]# /etc/init.d/openstack-nova-api start
    Starting openstack-nova-api:                       [  OK  ]
    [root@kvm4 ~(keystone_admin)]# /etc/init.d/openstack-nova-compute start
    Starting openstack-nova-compute:                   [  OK  ]
    [root@kvm4 ~(keystone_admin)]# /etc/init.d/openstack-nova-conductor start
    Starting openstack-nova-conductor:                 [  OK  ]
    [root@kvm4 ~(keystone_admin)]# /etc/init.d/openstack-nova-consoleauth start
    Starting openstack-nova-consoleauth:               [  OK  ]
    [root@kvm4 ~(keystone_admin)]# /etc/init.d/openstack-nova-novncproxy start
    Starting openstack-nova-novncproxy:                [  OK  ]
    [root@kvm4 ~(keystone_admin)]# chkconfig openstack-nova-scheduler on
    [root@kvm4 ~(keystone_admin)]# chkconfig openstack-nova-api on
    [root@kvm4 ~(keystone_admin)]# chkconfig openstack-nova-compute on
    [root@kvm4 ~(keystone_admin)]# chkconfig openstack-nova-conductor on
    [root@kvm4 ~(keystone_admin)]# chkconfig openstack-nova-consoleauth on
    [root@kvm4 ~(keystone_admin)]# chkconfig openstack-nova-novncproxy on
    
  11. 查看 nova 相關服務的錯誤訊息,發現 nova 無法 sudo 執行 nova-rootwrap 指令。
    [root@kvm4 ~(keystone_admin)]# tail /var/log/nova/*
    ==> /var/log/nova/api.log <==
    2014-01-25 15:24:30.710 29372 TRACE nova.service \
        cmd=' '.join(cmd))
    2014-01-25 15:24:30.710 29372 TRACE nova.service \
    ProcessExecutionError: Unexpected error while running command.
    2014-01-25 15:24:30.710 29372 TRACE nova.service \
    Command: sudo nova-rootwrap /etc/nova/rootwrap.conf iptables-save -c
    2014-01-25 15:24:30.710 29372 TRACE nova.service Exit code: 1
    2014-01-25 15:24:30.710 29372 TRACE nova.service Stdout: ''
    2014-01-25 15:24:30.710 29372 TRACE nova.service \
    Stderr: 'sudo: sorry, you must have a tty to run sudo\n'
    2014-01-25 15:24:30.710 29372 TRACE nova.service 
    2014-01-25 15:24:30.718 29372 INFO nova.wsgi [-] \
    Stopping WSGI server.
    2014-01-25 15:24:30.722 28941 INFO nova.service [-] \
    Child 29372 exited with status 2
    2014-01-25 15:24:30.723 28941 INFO nova.service [-] \
    Started child 29397
    
    ==> /var/log/nova/compute.log <==
    2014-01-25 15:23:41.852 28948 AUDIT nova.compute.resource_tracker \
    [-] Free ram (MB): 2504
    2014-01-25 15:23:41.852 28948 AUDIT nova.compute.resource_tracker \
    [-] Free disk (GB): 9
    2014-01-25 15:23:41.852 28948 AUDIT nova.compute.resource_tracker \
    [-] Free VCPUS: 1
    2014-01-25 15:23:42.037 28948 INFO nova.compute.resource_tracker \
    [-] Compute_service record created for kvm4.deyu.wang:kvm4.deyu.wang
    2014-01-25 15:24:12.146 AUDIT nova.compute.resource_tracker \
    [req-961356f1-0cce-4fe4-a55d-f8e08881f5fc None None] \
    Auditing locally available compute resources
    2014-01-25 15:24:12.370 AUDIT nova.compute.resource_tracker \
    [req-961356f1-0cce-4fe4-a55d-f8e08881f5fc None None] Free ram (MB): 2504
    2014-01-25 15:24:12.370 AUDIT nova.compute.resource_tracker \
    [req-961356f1-0cce-4fe4-a55d-f8e08881f5fc None None] Free disk (GB): 9
    2014-01-25 15:24:12.371 AUDIT nova.compute.resource_tracker \
    [req-961356f1-0cce-4fe4-a55d-f8e08881f5fc None None] Free VCPUS: 1
    2014-01-25 15:24:12.653 INFO nova.compute.resource_tracker \
    [req-961356f1-0cce-4fe4-a55d-f8e08881f5fc None None] \
    Compute_service record updated for kvm4.deyu.wang:kvm4.deyu.wang
    2014-01-25 15:24:12.827 INFO nova.compute.manager \
    [req-961356f1-0cce-4fe4-a55d-f8e08881f5fc None None] \
    Updating bandwidth usage cache
    
    ==> /var/log/nova/conductor.log <==
    2014-01-25 15:23:29.171 28955 AUDIT nova.service [-] \
    Starting conductor node (version 2013.1.2-4.el6ost)
    2014-01-25 15:23:31.838 INFO nova.openstack.common.rpc.impl_qpid \
    [req-926940e5-2ea3-488c-bfbf-14b5f0cfeaae None None] \
    Connected to AMQP server on localhost:5672
    2014-01-25 15:23:41.150 INFO nova.openstack.common.rpc.impl_qpid \
    [req-54f88c9d-cfcd-4c77-8aa1-d06f5ddf0e04 None None] \
    Connected to AMQP server on localhost:5672
    2014-01-25 15:24:12.564 INFO nova.openstack.common.rpc.impl_qpid \
    [req-6c8e9e6f-5dc0-4b0e-a0f4-60bd87234d9a None None] \
    Connected to AMQP server on localhost:5672
    2014-01-25 15:24:12.579 INFO nova.openstack.common.rpc.impl_qpid \
    [req-961356f1-0cce-4fe4-a55d-f8e08881f5fc None None] \
    Connected to AMQP server on localhost:5672
    
    ==> /var/log/nova/consoleauth.log <==
    2014-01-25 15:23:29.381 28962 AUDIT nova.service [-] \
    Starting consoleauth node (version 2013.1.2-4.el6ost)
    2014-01-25 15:23:31.974 INFO nova.openstack.common.rpc.impl_qpid \
    [req-4d503f6c-8e85-4f70-9acd-77cea9b42e8d None None] \
    Connected to AMQP server on localhost:5672
    
    ==> /var/log/nova/nova-manage.log <==
    2014-01-25 11:53:27.771 CRITICAL nova \
    [req-cad77826-aa34-4223-a5c7-b23dac8866c9 None None] (OperationalError) \
    (1045, "Access denied for user 'nova'@'localhost' (using password: YES)") None None
    2014-01-25 13:14:06.299 CRITICAL nova \
    [req-bdea1867-ecb2-4ddc-93ad-61e82feabb31 None None] (OperationalError) \
    (1045, "Access denied for user 'nova'@'localhost' (using password: YES)") None None
    
    ==> /var/log/nova/scheduler.log <==
    2014-01-25 15:23:29.241 28934 AUDIT nova.service [-] \
    Starting scheduler node (version 2013.1.2-4.el6ost)
    2014-01-25 15:23:31.917 INFO nova.openstack.common.rpc.impl_qpid \
    [req-d0bd6e4c-1a3e-4cc8-abcc-68bbb4c14661 None None] \
    Connected to AMQP server on localhost:5672
    2014-01-25 15:23:32.064 INFO nova.openstack.common.rpc.impl_qpid \
    [req-d0bd6e4c-1a3e-4cc8-abcc-68bbb4c14661 None None] \
    Connected to AMQP server on localhost:5672
    
  12. 以上錯誤訊息為用戶 cinder 無法使用 sudo 執行 cinder-rootwrap,必須 visudo 增加其權限。
    [root@kvm4 ~(keystone_admin)]# visudo
    Defaults:cinder !requiretty
    cinder ALL = (root) NOPASSWD: /usr/bin/cinder-rootwrap /etc/cinder/rootwrap.conf *
    
  13. cinder, nova, quantum 等套件安裝時,已將必須以 sudo 執行的命令權限寫在 /etc/sudoers.d 目錄下,但因 /etc/sudoers 沒有將此目錄包含進去,造成執行失敗。執行 visudo 加入 #includedir /etc/sudoers.d,注意最前面的符號 #不是註解,一定要存在。
    [root@kvm4 ~(keystone_admin)]# ll /etc/sudoers.d/
    total 12
    -r--r-----. 1 root root 111 Jan 25 15:36 cinder
    -r--r-----. 1 root root 103 Jan 25 15:39 nova
    -r--r-----. 1 root root  95 Jul  4  2013 quantum
    
    [root@kvm4 ~(keystone_admin)]# visudo
    [root@kvm4 ~(keystone_admin)]# grep includedir /etc/sudoers
    #includedir /etc/sudoers.d
    
  14. 刪除紀錄檔,再重新啟動 nova 相關服務。
    [root@kvm4 ~(keystone_admin)]# rm /var/log/nova/* -f
    [root@kvm4 ~(keystone_admin)]# /etc/init.d/openstack-nova-scheduler restart
    Stopping openstack-nova-scheduler:                 [  OK  ]
    Starting openstack-nova-scheduler:                 [  OK  ]
    [root@kvm4 ~(keystone_admin)]# /etc/init.d/openstack-nova-api restart
    Stopping openstack-nova-api:                       [  OK  ]
    Starting openstack-nova-api:                       [  OK  ]
    [root@kvm4 ~(keystone_admin)]# /etc/init.d/openstack-nova-compute restart
    Stopping openstack-nova-compute:                   [  OK  ]
    Starting openstack-nova-compute:                   [  OK  ]
    [root@kvm4 ~(keystone_admin)]# /etc/init.d/openstack-nova-conductor restart
    Stopping openstack-nova-conductor:                 [  OK  ]
    Starting openstack-nova-conductor:                 [  OK  ]
    [root@kvm4 ~(keystone_admin)]# /etc/init.d/openstack-nova-consoleauth restart
    Stopping openstack-nova-consoleauth:               [  OK  ]
    Starting openstack-nova-consoleauth:               [  OK  ]
    [root@kvm4 ~(keystone_admin)]# /etc/init.d/openstack-nova-novncproxy restart
    Stopping openstack-nova-novncproxy:                [  OK  ]
    Starting openstack-nova-novncproxy:                [  OK  ]
    
  15. 再查看 cinder 服務的紀錄,已無錯誤訊息。
    [root@kvm4 ~(keystone_admin)]# tail /var/log/nova/*
    ==> /var/log/nova/api.log <==
    2014-01-25 15:56:42.384 6973 INFO nova.service [-] Starting 1 workers
    2014-01-25 15:56:42.386 6973 INFO nova.service [-] Started child 6988
    2014-01-25 15:56:42.388 6973 INFO nova.network.driver \
    [-] Loading network driver 'nova.network.linux_net'
    2014-01-25 15:56:42.395 6988 INFO nova.osapi_compute.wsgi.server \
    [-] (6988) wsgi starting up on http://0.0.0.0:8774/
    
    ==> /var/log/nova/compute.log <==
    2014-01-25 15:56:41.279 5087 INFO nova.service \
    [-] Caught SIGTERM, exiting
    2014-01-25 15:56:43.436 6995 INFO nova.manager \
    [-] Skipping periodic task _periodic_update_dns because its interval is negative
    2014-01-25 15:56:43.516 6995 INFO nova.virt.driver \
    [-] Loading compute driver 'libvirt.LibvirtDriver'
    2014-01-25 15:56:43.660 INFO nova.openstack.common.rpc.impl_qpid \
    [req-9df6f81e-414c-4943-b8cb-6cbf8f5fe73c None None] \
    Connected to AMQP server on localhost:5672
    2014-01-25 15:56:43.705 INFO nova.openstack.common.rpc.impl_qpid \
    [req-9df6f81e-414c-4943-b8cb-6cbf8f5fe73c None None] \
    Connected to AMQP server on localhost:5672
    
    ==> /var/log/nova/conductor.log <==
    2014-01-25 15:56:42.464 5109 INFO nova.service \
    [-] Caught SIGTERM, exiting
    2014-01-25 15:56:44.182 7017 AUDIT nova.service \
    [-] Starting conductor node (version 2013.1.2-4.el6ost)
    2014-01-25 15:56:44.814 INFO nova.openstack.common.rpc.impl_qpid \
    [req-b127355e-0058-488f-a851-20fd40e9bc7a None None] \
    Connected to AMQP server on localhost:5672
    
    ==> /var/log/nova/consoleauth.log <==
    2014-01-25 15:56:43.652 5133 INFO nova.service \
    [-] Caught SIGTERM, exiting
    2014-01-25 15:56:46.108 7039 AUDIT nova.service \
    [-] Starting consoleauth node (version 2013.1.2-4.el6ost)
    2014-01-25 15:56:46.565 INFO nova.openstack.common.rpc.impl_qpid \
    [req-17daa1bf-db06-49a0-84f9-c208dbc9a5f7 None None] \
    Connected to AMQP server on localhost:5672
    
    ==> /var/log/nova/scheduler.log <==
    2014-01-25 15:56:38.924 5059 INFO nova.service \
    [-] Caught SIGTERM, exiting
    2014-01-25 15:56:40.998 6951 AUDIT nova.service \
    [-] Starting scheduler node (version 2013.1.2-4.el6ost)
    2014-01-25 15:56:41.838 INFO nova.openstack.common.rpc.impl_qpid \
    [req-07ec083e-5763-4910-b111-23489a6a3f49 None None] \
    Connected to AMQP server on localhost:5672
    2014-01-25 15:56:41.881 INFO nova.openstack.common.rpc.impl_qpid \
    [req-07ec083e-5763-4910-b111-23489a6a3f49 None None] \
    Connected to AMQP server on localhost:5672
    
  16. 檢查 openstack 中 nova 相關服務的狀態。
    [root@kvm4 ~(keystone_admin)]# openstack-status 
    == Nova services ==
    openstack-nova-api:           active
    openstack-nova-cert:          inactive (disabled on boot)
    openstack-nova-compute:       active
    openstack-nova-network:       inactive (disabled on boot)
    openstack-nova-scheduler:     active
    openstack-nova-volume:        dead (disabled on boot)
    openstack-nova-conductor:     active
    .....
    == Support services ==
    mysqld:                       active
    libvirtd:                     active
    tgtd:                         active
    qpidd:                        active
    memcached:                    active
    



2015-12-29