CentOS 7.5 安装 Openstack Rocky (allinone)

操作系统:CentOS 7.5
服务器:酷睿E8600+8G+SSD128G

一、安装openstack rocky
https://www.rdoproject.org/install/packstack/

systemctl disable firewalld
systemctl stop firewalld
systemctl disable NetworkManager
systemctl stop NetworkManager
systemctl enable network
systemctl start network

yum install -y https://rdoproject.org/repos/rdo-release.rpm
这一步安装好后,最好将相关repo文件中的url修改为国内仓库,速度会快很多,如中科大http://mirrors.ustc.edu.cn/

yum install -y centos-release-openstack-rocky

yum-config-manager –enable openstack-rocky

yum update -y

reboot

yum install -y openstack-packstack

packstack –allinone

安装过程如下:
在Testing if puppet apply is finished这里卡了将近30分钟
===========================================================================
Welcome to the Packstack setup utility

The installation log file is available at: /var/tmp/packstack/20190428-035212-Fi57cy/openstack-setup.log
Packstack changed given value to required value /root/.ssh/id_rsa.pub

Installing:
Clean Up [ DONE ]
Discovering ip protocol version [ DONE ]
Setting up ssh keys [ DONE ]
Preparing servers [ DONE ]
Pre installing Puppet and discovering hosts’ details [ DONE ]
Preparing pre-install entries [ DONE ]
Setting up CACERT [ DONE ]
Preparing AMQP entries [ DONE ]
Preparing MariaDB entries [ DONE ]
Fixing Keystone LDAP config parameters to be undef if empty[ DONE ]
Preparing Keystone entries [ DONE ]
Preparing Glance entries [ DONE ]
Checking if the Cinder server has a cinder-volumes vg[ DONE ]
Preparing Cinder entries [ DONE ]
Preparing Nova API entries [ DONE ]
Creating ssh keys for Nova migration [ DONE ]
Gathering ssh host keys for Nova migration [ DONE ]
Preparing Nova Compute entries [ DONE ]
Preparing Nova Scheduler entries [ DONE ]
Preparing Nova VNC Proxy entries [ DONE ]
Preparing OpenStack Network-related Nova entries [ DONE ]
Preparing Nova Common entries [ DONE ]
Preparing Neutron LBaaS Agent entries [ DONE ]
Preparing Neutron API entries [ DONE ]
Preparing Neutron L3 entries [ DONE ]
Preparing Neutron L2 Agent entries [ DONE ]
Preparing Neutron DHCP Agent entries [ DONE ]
Preparing Neutron Metering Agent entries [ DONE ]
Checking if NetworkManager is enabled and running [ DONE ]
Preparing OpenStack Client entries [ DONE ]
Preparing Horizon entries [ DONE ]
Preparing Swift builder entries [ DONE ]
Preparing Swift proxy entries [ DONE ]
Preparing Swift storage entries [ DONE ]
Preparing Gnocchi entries [ DONE ]
Preparing Redis entries [ DONE ]
Preparing Ceilometer entries [ DONE ]
Preparing Aodh entries [ DONE ]
Preparing Puppet manifests [ DONE ]
Copying Puppet modules and manifests [ DONE ]
Applying 192.168.1.127_controller.pp
192.168.1.127_controller.pp: [ DONE ]
Applying 192.168.1.127_network.pp
192.168.1.127_network.pp: [ DONE ]
Applying 192.168.1.127_compute.pp
192.168.1.127_compute.pp: [ DONE ]
Applying Puppet manifests [ DONE ]
Finalizing [ DONE ]

**** Installation completed successfully ******

Additional information:
* A new answerfile was created in: /root/packstack-answers-20190428-035213.txt
* Time synchronization installation was skipped. Please note that unsynchronized time on server instances might be problem for some OpenStack components.
* File /root/keystonerc_admin has been created on OpenStack client host 192.168.1.127. To use the command line tools you need to source the file.
* To access the OpenStack Dashboard browse to http://192.168.1.127/dashboard .
Please, find your login credentials stored in the keystonerc_admin in your home directory.
* The installation log file is available at: /var/tmp/packstack/20190428-035212-Fi57cy/openstack-setup.log
* The generated manifests are available at: /var/tmp/packstack/20190428-035212-Fi57cy/manifests
===========================================================================

访问http://192.168.1.127/dashboard
用户名admin,密码在 /root/keystonerc_admin

二、使用镜像创建实例

1、自带cirros镜像创建一个实例,

打开控制台报错“failed to connect to server (code: 1006)”

查看日志,有一句 connecting to: dastack:5900,[Errno -2] No address found
[root@dastack ~]# tail -f /var/log/nova/nova-novncproxy.log
2019-04-28 05:15:04.060 13511 INFO nova.console.websocketproxy [req-42a0c3fa-b818-45c9-95e0-deac67116a12 – – – – -] 10: connecting to: dastack:5900
2019-04-28 05:15:04.067 13511 INFO nova.console.websocketproxy [req-42a0c3fa-b818-45c9-95e0-deac67116a12 – – – – -] handler exception: [Errno -2] No address found
2019-04-28 05:15:06.637 13510 INFO nova.console.websocketproxy [-] 192.168.1.188: ignoring socket not ready
2019-04-28 05:17:40.279 14125 INFO nova.console.websocketproxy [-] 192.168.1.188 – – [28/Apr/2019 05:17:40] 192.168.1.188: Plain non-SSL (ws://) WebSocket connection
2019-04-28 05:17:40.280 14125 INFO nova.console.websocketproxy [-] 192.168.1.188 – – [28/Apr/2019 05:17:40] 192.168.1.188: Version hybi-13, base64: ‘False’
2019-04-28 05:17:40.280 14125 INFO nova.console.websocketproxy [-] 192.168.1.188 – – [28/Apr/2019 05:17:40] 192.168.1.188: Path: ‘/websockify’
2019-04-28 05:17:40.640 14125 INFO nova.console.websocketproxy [req-cfe7c45a-2535-4925-8552-f921abeebdf8 – – – – -] 12: connect info: {‘instance_uuid’: u’d9897640-8951-4c71-ae2d-b5bf7fd5ca65′, ‘internal_access_path’: None, ‘console_type’: u’novnc’, ‘host’: u’dastack’, ‘token’: (u’f9e8563f-7508-444e-8382-dbce828b7fb3′,), ‘access_url’: u’http://192.168.1.127:6080/vnc_auto.html?token=f9e8563f-7508-444e-8382-dbce828b7fb3′, ‘port’: 5900}
2019-04-28 05:17:40.641 14125 INFO nova.console.websocketproxy [req-cfe7c45a-2535-4925-8552-f921abeebdf8 – – – – -] 12: connecting to: dastack:5900
2019-04-28 05:17:40.649 14125 INFO nova.console.websocketproxy [req-cfe7c45a-2535-4925-8552-f921abeebdf8 – – – – -] handler exception: [Errno -2] No address found
2019-04-28 05:17:43.125 14123 INFO nova.console.websocketproxy [-] 192.168.1.188: ignoring socket not ready
2019-04-28 05:21:19.722 14686 INFO nova.console.websocketproxy [-] 192.168.1.188 – – [28/Apr/2019 05:21:19] 192.168.1.188: Plain non-SSL (ws://) WebSocket connection
2019-04-28 05:21:19.723 14686 INFO nova.console.websocketproxy [-] 192.168.1.188 – – [28/Apr/2019 05:21:19] 192.168.1.188: Version hybi-13, base64: ‘False’
2019-04-28 05:21:19.724 14686 INFO nova.console.websocketproxy [-] 192.168.1.188 – – [28/Apr/2019 05:21:19] 192.168.1.188: Path: ‘/websockify’
2019-04-28 05:21:20.072 14686 INFO nova.console.websocketproxy [req-372e14a7-b92a-4524-b061-6eda7ca48b58 – – – – -] 18: connect info: {‘instance_uuid’: u’d9897640-8951-4c71-ae2d-b5bf7fd5ca65′, ‘internal_access_path’: None, ‘console_type’: u’novnc’, ‘host’: u’dastack’, ‘token’: (u’226fc0be-8fc7-45e6-8cba-7062dd5c16a1′,), ‘access_url’: u’http://192.168.1.127:6080/vnc_auto.html?token=226fc0be-8fc7-45e6-8cba-7062dd5c16a1′, ‘port’: 5900}
2019-04-28 05:21:20.072 14686 INFO nova.console.websocketproxy [req-372e14a7-b92a-4524-b061-6eda7ca48b58 – – – – -] 18: connecting to: dastack:5900
2019-04-28 05:21:20.081 14686 INFO nova.console.websocketproxy [req-372e14a7-b92a-4524-b061-6eda7ca48b58 – – – – -] handler exception: [Errno -2] No address found
2019-04-28 05:21:22.659 14681 INFO nova.console.websocketproxy [-] 192.168.1.188: ignoring socket not ready
2019-04-28 05:21:22.663 14682 INFO nova.console.websocketproxy [-] 192.168.1.188: ignoring socket not ready
2019-04-28 05:21:22.667 14683 INFO nova.console.websocketproxy [-] 192.168.1.188: ignoring socket not ready
2019-04-28 05:21:22.672 14684 INFO nova.console.websocketproxy [-] 192.168.1.188: ignoring socket not ready
2019-04-28 05:21:22.677 14685 INFO nova.console.websocketproxy [-] 192.168.1.188: ignoring socket not ready

因openstack在安装时已新建了一个内网段172.24.4.0,openstack本身分配到ip是172.124.4.1,增加hosts记录如下:
172.24.4.1 dastack
重新打开控制台连接成功

2、qcow2镜像创建一个实例
找来一个kvm的centos镜像上传到openstack并创建实例,报错如下:
错误: 实例 “da002” 执行所请求操作失败,实例处于错误状态。: 请稍后再试 [错误: Build of instance a9f0cb93-644b-4754-a207-7731051d6725 aborted: Volume 9168c055-446d-4aa5-9e2d-14c770d4f5fd did not finish being created even after we waited 43 seconds or 15 attempts. And its status is error.].

查看日志
vim /var/log/nova/nova-compute.log
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [req-1ceb27a2-4ef3-4fb7-afda-63e09e6be429 35b482a2e75647238ab16fb8016b261f 935a0203e03b4b87995d77b297d43565 – default default] [instance: a9f0cb93-644b-4754-a207-7731051d6725] Instance failed block device setup: VolumeNotCreated: Volume 9168c055-446d-4aa5-9e2d-14c770d4f5fd did not finish being created even after we waited 43 seconds or 15 attempts. And its status is error.
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] Traceback (most recent call last):
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] File “/usr/lib/python2.7/site-packages/nova/compute/manager.py”, line 1685, in _prep_block_device
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] wait_func=self._await_block_device_map_created)
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] File “/usr/lib/python2.7/site-packages/nova/virt/block_device.py”, line 855, in attach_block_devices
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] _log_and_attach(device)
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] File “/usr/lib/python2.7/site-packages/nova/virt/block_device.py”, line 852, in _log_and_attach
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] bdm.attach(*attach_args, **attach_kwargs)
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] File “/usr/lib/python2.7/site-packages/nova/virt/block_device.py”, line 740, in attach
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] self._call_wait_func(context, wait_func, volume_api, vol[‘id’])
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] File “/usr/lib/python2.7/site-packages/nova/virt/block_device.py”, line 697, in _call_wait_func
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] {‘volume_id’: volume_id, ‘exc’: exc})
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] File “/usr/lib/python2.7/site-packages/oslo_utils/excutils.py”, line 220, in __exit__
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] self.force_reraise()
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] File “/usr/lib/python2.7/site-packages/oslo_utils/excutils.py”, line 196, in force_reraise
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] six.reraise(self.type_, self.value, self.tb)
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] File “/usr/lib/python2.7/site-packages/nova/virt/block_device.py”, line 687, in _call_wait_func
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] wait_func(context, volume_id)
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] File “/usr/lib/python2.7/site-packages/nova/compute/manager.py”, line 1345, in _await_block_device_map_created
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] volume_status=volume_status)
2019-04-28 15:51:27.772 5761 ERROR nova.compute.manager [instance: a9f0cb93-644b-4754-a207-7731051d6725] VolumeNotCreated: Volume 9168c055-446d-4aa5-9e2d-14c770d4f5fd did not finish being created even after we waited 43 seconds or 15 attempts. And its status is error.

网上查到是因为本地存储原因导致超时,修改nova的一个参数尝试
vim /etc/nova/nova.conf,增加如下参数:
block_device_allocate_retries=300
block_device_allocate_retries_interval=10

重启相关服务
systemctl restart openstack-nova-compute

=========================================================================
综上所述改了然并卵,还是直接去centos官方拿镜像吧

镜像地址:
http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1811.qcow2

http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1901.qcow2

http://uec-images.ubuntu.com/cosmic/20190419/cosmic-server-cloudimg-amd64.img

其他创建镜像的方法:

openstack image create “CentOS7-image” \
–file CentOS-7-x86_64-GenericCloud-1802.qcow2c \
–disk-format qcow2 –container-format bare \
–public

curl -i -X PUT -H “X-Auth-Token: 94f2b7bf4cee4f2c9d2bbe1f2ca785a2” -H “Content-Type: application/octet-stream”\
–upload-file /home/centos.tar http://192.168.31.147:9292/v2/images/0482eff2-8406-46a7-8bbb-d43e1ca9c14f/file

3、导入环境变量
执行openstack相关命令如openstack image list是需要导入环境变量的,如下:

export OS_USERNAME=admin
export OS_PASSWORD=123456
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_AUTH_URL=http://192.168.1.127:35357/v3
export OS_IDENTITY_API_VERSION=3

4、修改镜像密码

方法一:
适合已经创建实例的

yum -y install libguestfs-tools

[root@dastack ~]# openssl passwd -1 “123”
$1$70O2xDmv$UIjv/9VTvpxxtWUu2O6sM1

[root@dastack ~]# virsh list –all
Id Name State
—————————————————-
2 instance-00000009 running
– instance-00000001 shut off
– instance-00000007 shut off

virt-edit -d instance-00000009 /etc/shadow
root:$1$70O2xDmv$UIjv/9VTvpxxtWUu2O6sM1:17924:0:99999:7:::

方法二:
直接修改qcow2镜像
virt-customize -a CentOS-7-x86_64-GenericCloud-1703.qcow2 –root-password password:hello123

这一步还可以是这样:安装或删除package,甚至同时设置自己的SSH key
sudo virt-customize -a CentOS-7-x86_64-GenericCloud-1703.qcow2 –install epel-release –ssh-inject centos:string:”ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKCqX6EZIrGHoGaMII4QAqr0QC72t+Kg/c5ZIRNTMb6Q+BwzejQgjhBTXeyPnp0rfE9XI4pTxkZqAUOGSK9Bfqg= smiller@bruckner”

方法三:
https://access.redhat.com/discussions/664843