实验环境
由于安装的是 Victoria 版本,计算节点要使用 Ubuntu 20.04 。
Ubuntu 18.04 控制节点
Ubuntu 20.04 计算节点
各使用两块网卡
NAT Network 虚拟机组网
Host-Only 宿主机 ssh 连接
修改主机名称,控制节点 controller
、计算节点 compute
1 sudo hostnamectl set-hostname controller
配置静态 ip
1 2 sudo vim /etc/netplan/00-installer-config.yaml sudo netplan apply
配置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 network: ethernets: enp0s3: dhcp4: false addresses: [10.0 .2 .28 /24 ] gateway4: 10.0 .2 .1 nameservers: addresses: [8.8 .8 .8 ] enp0s8: dhcp4: false addresses: [192.168 .56 .115 /24 ] routes: - to: 192.168 .56 .1 /24 via: 192.168 .56 .1 metric: 100 version: 2
修改 hosts 文件
每个主机的用户都是 jck ,最后的网络配置如下:
1 2 3 4 5 6 7 10.0.2.28 192.168.56.115 10.0.2.29 192.168.56.116
控制节点
Keystone
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 git clone https://github.com/openstack/keystone.git -b stable/victoria --single-branch cd keystonepip install bindep sudo apt install $(bindep -b) -y pip install -r requirements.txt pip install -r test-requirements.txt pip install tox git init tox -e genconfig sudo mysql_secure_installation sudo mysql -u root -p sudo mkdir /etc/keystone sudo cp etc/keystone.conf.sample /etc/keystone/keystone.conf sudo vim /etc/keystone/keystone.conf sudo python setup.py install keystone-manage db_sync sudo mkdir -p /etc/keystone/fernet-keys sudo keystone-manage fernet_setup --keystone-user jck --keystone-group jck sudo keystone-manage credential_setup --keystone-user jck --keystone-group jck keystone-manage bootstrap --bootstrap-password ADMIN_PASS \ --bootstrap-admin-url http://controller:5000/v3/ \ --bootstrap-internal-url http://controller:5000/v3/ \ --bootstrap-public-url http://controller:5000/v3/ \ --bootstrap-region-id RegionOne sudo apt install apache2 libapache2-mod-wsgi-py3 -y sudo cp httpd/wsgi-keystone.conf /etc/apache2/conf-available/wsgi-keystone.conf sudo vim /etc/apache2/conf-available/wsgi-keystone.conf sudo ln -s /etc/apache2/conf-available/wsgi-keystone.conf /etc/apache2/conf-enabled/wsgi-keystone.conf sudo service apache2 restart
验证
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 pip install python-openstackclient cat <<EOF>> admin-openrc export OS_USERNAME=admin export OS_PASSWORD=ADMIN_PASS export OS_PROJECT_NAME=admin export OS_USER_DOMAIN_NAME=Default export OS_PROJECT_DOMAIN_NAME=Default export OS_AUTH_URL=http://controller:5000/v3 export OS_IDENTITY_API_VERSION=3 EOF . admin-openrc openstack user list
Glance
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 sudo mysql -u root -p . admin-openrc openstack project create --domain default --description "Service Project" service openstack user create --domain default --password-prompt glance openstack role add --project service --user glance admin openstack service create --name glance --description "OpenStack Image" image openstack endpoint create --region RegionOne image public http://controller:9292 openstack endpoint create --region RegionOne image internal http://controller:9292 openstack endpoint create --region RegionOne image admin http://controller:9292 git clone https://github.com/openstack/glance.git --branch stable/victoria --single-branch cd glancesudo apt install $(bindep -b) -y pip install -r requirements.txt pip install -r test-requirements.txt .tox/genconfig/bin/pip3 install opentracing tox -e genconfig sudo python setup.py install sudo mkdir /etc/glance sudo cp etc/glance-api.conf /etc/glance/glance-api.conf sudo cp etc/glance-api-paste.ini /etc/glance/glance-api-paste.ini sudo vim /etc/glance/glance-api.conf
配置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [database] connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance[keystone_authtoken] www_authenticate_uri = http://controller:5000 /v3auth_url = http://controller:5000 /v3auth_type = passwordproject_domain_name = Defaultuser_domain_name = Defaultproject_name = serviceusername = glancepassword = glance[paste_deploy] flavor = keystone[glance_store] stores = file,httpdefault_store = filefilesystem_store_datadir = /var/lib/glance/images/
启用服务
1 2 3 4 5 .tox/genconfig/bin/glance-manage db_sync sudo glance-api --config-file=/etc/glance/glance-api.conf --config-file=/etc/glance/glance-api-paste.ini --debug
测试
1 2 3 4 5 6 7 8 9 10 11 wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img openstack image create "cirros" \ --file cirros-0.4.0-x86_64-disk.img \ --disk-format qcow2 --container-format bare \ --public openstack image list
Placement
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 sudo mysql -u root -p . admin-openrc openstack user create --domain default --password-prompt placement openstack role add --project service --user placement admin openstack service create --name placement --description "Placement API" placement openstack endpoint create --region RegionOne placement public http://controller:8778 openstack endpoint create --region RegionOne placement internal http://controller:8778 openstack endpoint create --region RegionOne placement admin http://controller:8778 git clone https://github.com/openstack/placement.git --branch stable/victoria --single-branch cd placementsudo apt install $(bindep -b) -y pip install -r requirements.txt pip install -r test-requirements.txt tox -e genconfig sudo python setup.py install
配置文件 /etc/placement/placement.conf
1 2 3 4 5 6 7 8 sudo mkdir /etc/placement sudo cp etc/placement/placement.conf.sample /etc/placement/placement.conf sudo vim /etc/placement/placement.conf
配置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [placement_database] connection = mysql+pymysql://placement:PLACEMENT_DBPASS@controller/placement[api] auth_strategy = keystone[keystone_authtoken] auth_url = http://controller:5000 /v3auth_type = passwordproject_domain_name = Defaultuser_domain_name = Defaultproject_name = serviceusername = placementpassword = placement
启用服务
1 2 3 4 5 6 .tox/shared/bin/placement-manage db sync sudo service apache2 restart sudo placement-api --port 8778
验证
1 2 . admin-openrc placement-status upgrade check
Nova
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 sudo apt install rabbitmq-server -y sudo rabbitmqctl add_user openstack RABBIT_PASS sudo rabbitmqctl set_permissions openstack ".*" ".*" ".*" sudo mysql -u root -p . admin-openrc openstack user create --domain default --password-prompt nova openstack role add --project service --user nova admin openstack service create --name nova --description "OpenStack Compute" compute openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1 openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1 openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1 git clone https://github.com/openstack/nova.git --branch stable/victoria --single-branch cd novasudo apt install $(bindep -b) -y pip install -r requirements.txt pip install -r test-requirements.txt tox -e genconfig sudo python setup.py install sudo mkdir /etc/nova sudo cp etc/nova/nova.conf.sample /etc/nova/nova.conf sudo cp etc/nova/api-paste.ini /etc/nova/api-paste.ini sudo vim /etc/nova/nova.conf
配置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 [api_database] connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova_api[database] connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova[DEFAULT] transport_url = rabbit://openstack:RABBIT_PASS@controller:5672 /my_ip = 10.0 .2.28 [api] auth_strategy = keystone[keystone_authtoken] www_authenticate_uri = http://controller:5000 /auth_url = http://controller:5000 /auth_type = passwordproject_domain_name = Defaultuser_domain_name = Defaultproject_name = serviceusername = novapassword = nova[vnc] enabled = true server_listen = $my_ip server_proxyclient_address = $my_ip novncproxy_base_url = http://controller:6080 /vnc_auto.html[glance] api_servers = http://controller:9292 [oslo_concurrency] lock_path = /var/lib/nova/tmp[placement] region_name = RegionOneproject_domain_name = Defaultproject_name = serviceauth_type = passworduser_domain_name = Defaultauth_url = http://controller:5000 /v3username = placementpassword = placement
启用服务
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 sudo git clone https://github.com/novnc/noVNC.git /usr/share/novnc/ .tox/shared/bin/nova-manage --config-file /etc/nova/nova.conf api_db sync .tox/shared/bin/nova-manage --config-file /etc/nova/nova.conf cell_v2 map_cell0 .tox/shared/bin/nova-manage --config-file /etc/nova/nova.conf cell_v2 create_cell --name=cell1 --verbose .tox/shared/bin/nova-manage --config-file /etc/nova/nova.conf db sync .tox/shared/bin/nova-manage --config-file /etc/nova/nova.conf cell_v2 list_cells sudo nova-api --config-file=/etc/nova/nova.conf --config-file=/etc/nova/api-paste.ini --debug sudo nova-scheduler --config-file=/etc/nova/nova.conf --debug sudo nova-conductor --config-file=/etc/nova/nova.conf --debug
验证
1 2 3 4 5 6 7 . admin-openrc openstack compute service list nova-status upgrade check
计算节点
PS:这里连 mysql 都装了,其实没必要。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 git clone https://github.com/openstack/nova.git --branch stable/victoria --single-branch cd novapip install bindep sudo apt install $(bindep -b) -y pip install -r requirements.txt pip install -r test-requirements.txt pip install tox tox -e genconfig sudo python setup.py install
编辑配置文件 /etc/nova/nova.conf
1 2 3 4 5 6 7 8 9 sudo mkdir /etc/nova sudo cp etc/nova/nova.conf.sample /etc/nova/nova.conf sudo vim /etc/nova/nova.conf
配置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 [DEFAULT] transport_url = rabbit://openstack:RABBIT_PASS@controllermy_ip = 10.0 .2.29 compute_driver =libvirt.LibvirtDriver[api] auth_strategy = keystone[keystone_authtoken] www_authenticate_uri = http://controller:5000 /auth_url = http://controller:5000 /auth_type = passwordproject_domain_name = Defaultuser_domain_name = Defaultproject_name = serviceusername = novapassword = nova[vnc] enabled = true server_listen = 0.0 .0.0 server_proxyclient_address = $my_ip novncproxy_base_url = http://controller:6080 /vnc_auto.html[glance] api_servers = http://controller:9292 [oslo_concurrency] lock_path = /var/lib/nova/tmp[placement] region_name = RegionOneproject_domain_name = Defaultproject_name = serviceauth_type = passworduser_domain_name = Defaultauth_url = http://controller:5000 /v3username = placementpassword = placement[libvirt] virt_type = qemu
计算主机本身不支持虚拟化,按照官方教程应该配置 virt_type=qemu
,但提示需要配置 compute_driver
查阅 nova 文档 (p322)找到支持的虚拟化驱动
libvirt.LibvirtDriver
ironic.IronicDriver
vmwareapi.VMwareVCDriver
hyperv.HyperVDriver
powervm.PowerVMDriver
zvm.ZVMDriver
fake.FakeDriver
1 2 3 4 5 6 7 8 9 10 sudo apt update sudo apt install qemu-kvm libvirt-daemon-system -y virsh version sudo nova-compute --config-file=/etc/nova/nova.conf --debug
控制节点
添加到 cell
1 2 3 4 5 6 7 8 9 . admin-openrc openstack compute service list --service nova-compute ~/nova/.tox/shared/bin/nova-manage --config-file /etc/nova/nova.conf cell_v2 discover_hosts --verbose
验证
1 2 3 4 5 6 7 8 openstack compute service list openstack image list nova-status upgrade check
参阅