目录
一、安装软件包
二、编辑修改配置文件
三、验证
四、创建启动实例
五、创建实例
六、创建密钥对
七、添加安全组规则
八、启动实例
九、验证
一、安装软件包
[root@controller ~]# yum install openstack-dashboard -y
二、编辑修改配置文件
1.修改配置文件
①.备份配置文件
②.修改配置文件
[root@controller ~]# cp /etc/openstack-dashboard/local_settings /etc/openstack-dashboard/local_settings.backup
[root@controller ~]# vim /etc/openstack-dashboard/local_settings
#配置httpd访问目录、设置登录超时时间
WEBROOT = '/dashboard/'
SESSION_TIMEOUT = 86400
#添加主机名称
OPENSTACK_HOST = "controller"
#允许所有人登录
ALLOWED_HOSTS = ['*', ]
#配置回话存储服务:memcached
SESSION_ENGINE = 'django.contrib.sessions.backends.file'
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': 'controller:11211',
},
}
#启用身份API版本
OPENSTACK_API_VERSIONS = {
"identity": 3,
"image": 2,
"volume": 3,
}
#启用对域的支持:
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True
#配置为通过仪表板创建的用户的默认域:Default
OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "Default"
#配置user为通过仪表板创建的用户的默认角色
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user"
#设置时区为上海
TIME_ZONE = "Asia/Shanghai"
3.修改httpd配置文件
①.如果未包含则添加到
/etc/httpd/conf.d/openstack-dashboard.conf
[root@controller ~]# vim /etc/httpd/conf.d/openstack-dashboard.conf
WSGIApplicationGroup %{GLOBAL}
4.重新启动web服务器和会话存储服务
①.查看是否成功启动
[root@controller ~]# systemctl restart httpd.service memcached.service
[root@controller ~]# systemctl status httpd.service memcached.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─openstack-dashboard.conf
Active: active (running) since Fri 2022-07-22 18:01:40 CST; 9s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 5091 ExecStartPre=/usr/bin/python2 /usr/share/openstack-dashboard/manage.py compress --force -v0 (code=exited, status=0/SUCCESS)
Process: 5059 ExecStartPre=/usr/bin/python2 /usr/share/openstack-dashboard/manage.py collectstatic --noinput --clear -v0 (code=exited, status=0/SUCCESS)
Main PID: 5114 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─5114 /usr/sbin/httpd -DFOREGROUND
├─5116 /usr/sbin/httpd -DFOREGROUND
├─5117 /usr/sbin/httpd -DFOREGROUND
├─5118 /usr/sbin/httpd -DFOREGROUND
├─5119 /usr/sbin/httpd -DFOREGROUND
├─5120 (wsgi:keystone- -DFOREGROUND
├─5121 (wsgi:keystone- -DFOREGROUND
├─5122 (wsgi:keystone- -DFOREGROUND
├─5123 (wsgi:keystone- -DFOREGROUND
├─5124 (wsgi:keystone- -DFOREGROUND
├─5125 /usr/sbin/httpd -DFOREGROUND
├─5126 /usr/sbin/httpd -DFOREGROUND
├─5127 /usr/sbin/httpd -DFOREGROUND
├─5128 /usr/sbin/httpd -DFOREGROUND
└─5129 /usr/sbin/httpd -DFOREGROUND
Jul 22 18:01:19 controller systemd[1]: Starting The Apache HTTP Server...
Jul 22 18:01:40 controller python2[5091]: Compressing... done
Jul 22 18:01:40 controller python2[5091]: Compressed 7 block(s) from 4 template(s) for 2 context(s).
Jul 22 18:01:40 controller systemd[1]: Started The Apache HTTP Server.
● memcached.service - memcached daemon
Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2022-07-22 18:01:19 CST; 31s ago
Main PID: 5058 (memcached)
CGroup: /system.slice/memcached.service
└─5058 /usr/bin/memcached -p 11211 -u memcached -m 64 -c 1024 -l 127.0.0.1,::1,controller
Jul 22 18:01:19 controller systemd[1]: Started memcached daemon.
三、验证
1.在浏览器输入"http://‘控制节点IP地址’/dashboard"访问
出现了下面的页面则dashboard部署成功
四、创建启动实例
1.获取admin凭据访问openstack cli、
[root@controller ~]# . admin-openrc.sh
2.创建网络
[root@controller ~]# openstack network create --share --external \
--provider-physical-network provider \
--provider-network-type flat provider
+---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2022-07-23T09:45:49Z |
| description | |
| dns_domain | None |
| id | c78a3847-5e46-4723-94e2-e06ddc4ab874 |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | None |
| is_vlan_transparent | None |
| location | cloud='', project.domain_id=, project.domain_name='Default', project.id='495f2e77e0ba4614a4812bcd5fd86bb8', project.name='admin', region_name='', zone= |
| mtu | 1500 |
| name | provider |
| port_security_enabled | True |
| project_id | 495f2e77e0ba4614a4812bcd5fd86bb8 |
| provider:network_type | flat |
| provider:physical_network | provider |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 1 |
| router:external | External |
| segments | None |
| shared | True |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2022-07-23T09:45:51Z |
+---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
3.创建子网
#分配地址池范围(10.0.0.40/24~10.0.0.250/24)
#dns服务器地址(8.8.8.8)、网关(10.0.0.2/24)
#子网范围为(10.0.0.0/24)
[root@controller ~]# openstack subnet create --network provider \
--allocation-pool start=10.0.0.40,end=10.0.0.250 \
--dns-nameserver 8.8.8.8 --gateway 10.0.0.2 \
--subnet-range 10.0.0.0/24 provider
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| allocation_pools | 10.0.0.40-10.0.0.250 |
| cidr | 10.0.0.0/24 |
| created_at | 2022-07-23T09:54:45Z |
| description | |
| dns_nameservers | 8.8.8.8 |
| enable_dhcp | True |
| gateway_ip | 10.0.0.2 |
| host_routes | |
| id | b593e744-a460-4ad5-9985-cabd08327cc6 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| location | cloud='', project.domain_id=, project.domain_name='Default', project.id='495f2e77e0ba4614a4812bcd5fd86bb8', project.name='admin', region_name='', zone= |
| name | provider |
| network_id | c78a3847-5e46-4723-94e2-e06ddc4ab874 |
| prefix_length | None |
| project_id | 495f2e77e0ba4614a4812bcd5fd86bb8 |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2022-07-23T09:54:45Z |
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
五、创建实例
1.创建一个flavor
①.运行内存为64M、一个虚拟CPU、一块存储硬盘
[root@controller ~]# openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano
+----------------------------+---------+
| Field | Value |
+----------------------------+---------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 1 |
| id | 0 |
| name | m1.nano |
| os-flavor-access:is_public | True |
| properties | |
| ram | 64 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 1 |
+----------------------------+---------+
六、创建密钥对
1.生成密钥对并添加公钥
①.创建一个demo-openrc.sh的环境脚本、执行环境脚本
②.生成秘钥对并添加
[root@controller ~]# cat >>demo-openrc.sh<<EOF
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=myproject
export OS_USERNAME=myuser
export OS_PASSWORD=123456
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
EOF
[root@controller ~]# . demo-openrc.sh
#生成密钥对
[root@controller ~]# ssh-keygen -q -N ""
Enter file in which to save the key (/root/.ssh/id_rsa): ==>直接回车
#添加密钥对
[root@controller ~]# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
+-------------+-------------------------------------------------+
| Field | Value |
+-------------+-------------------------------------------------+
| fingerprint | 05:50:a0:e4:b2:83:bb:db:c2:30:3b:b7:fd:75:01:3e |
| name | mykey |
| user_id | 1cc3677f95194cb28fb0d7bc4b121fed |
+-------------+-------------------------------------------------+
#验证密钥对是否添加
[root@controller ~]# openstack keypair list
+-------+-------------------------------------------------+
| Name | Fingerprint |
+-------+-------------------------------------------------+
| mykey | 05:50:a0:e4:b2:83:bb:db:c2:30:3b:b7:fd:75:01:3e |
+-------+-------------------------------------------------+
七、添加安全组规则
[root@controller ~]# openstack security group rule create --proto icmp default
+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at | 2022-07-23T10:08:05Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | aef07709-4ed0-489d-8553-f0ee1aac1adf |
| location | cloud='', project.domain_id=, project.domain_name='Default', project.id='9ec36b2a4f4d470380e7c5be0911d1b8', project.name='myproject', region_name='', zone= |
| name | None |
| port_range_max | None |
| port_range_min | None |
| project_id | 9ec36b2a4f4d470380e7c5be0911d1b8 |
| protocol | icmp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | dc8470ea-14ac-44da-9a1f-e8d1f62d3658 |
| tags | [] |
| updated_at | 2022-07-23T10:08:05Z |
+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
[root@controller ~]# openstack security group rule create --proto tcp --dst-port 22 default
+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at | 2022-07-23T10:09:18Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | ff498d76-d9a1-438c-8591-da895c80f967 |
| location | cloud='', project.domain_id=, project.domain_name='Default', project.id='9ec36b2a4f4d470380e7c5be0911d1b8', project.name='myproject', region_name='', zone= |
| name | None |
| port_range_max | 22 |
| port_range_min | 22 |
| project_id | 9ec36b2a4f4d470380e7c5be0911d1b8 |
| protocol | tcp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | dc8470ea-14ac-44da-9a1f-e8d1f62d3658 |
| tags | [] |
| updated_at | 2022-07-23T10:09:18Z |
+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
八、启动实例
1.获取demo账户的环境变量
[root@controller ~]# . demo-openrc.sh
2.列出可用资源
①.列出实例
②.列出可用镜像
③.列出可用网络
④.列出可用安全组
[root@controller ~]# openstack flavor list
+----+---------+-----+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+---------+-----+------+-----------+-------+-----------+
| 0 | m1.nano | 64 | 1 | 0 | 1 | True |
+----+---------+-----+------+-----------+-------+-----------+
[root@controller ~]# openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| e82bb244-644a-4d9c-8739-053f55328634 | cirros | active |
+--------------------------------------+--------+--------+
[root@controller ~]# openstack network list
+--------------------------------------+----------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+----------+--------------------------------------+
| c78a3847-5e46-4723-94e2-e06ddc4ab874 | provider | b593e744-a460-4ad5-9985-cabd08327cc6 |
+--------------------------------------+----------+--------------------------------------+
[root@controller ~]# openstack security group list
+--------------------------------------+---------+------------------------+----------------------------------+------+
| ID | Name | Description | Project | Tags |
+--------------------------------------+---------+------------------------+----------------------------------+------+
| dc8470ea-14ac-44da-9a1f-e8d1f62d3658 | default | Default security group | 9ec36b2a4f4d470380e7c5be0911d1b8 | [] |
+--------------------------------------+---------+------------------------+----------------------------------+------+
3.启动实例
①.net-id修改成"openstack network list"获取的ID
②.test-vm1创建实例的名字
[root@controller ~]# openstack server create --flavor m1.nano --image cirros \
--nic net-id=c78a3847-5e46-4723-94e2-e06ddc4ab874 --security-group default \
--key-name mykey test-vm1
+-----------------------------+-----------------------------------------------+
| Field | Value |
+-----------------------------+-----------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-STS:power_state | NOSTATE |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | None |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | |
| adminPass | Nq6tAmjAYy8T |
| config_drive | |
| created | 2022-07-23T10:19:41Z |
| flavor | m1.nano (0) |
| hostId | |
| id | 6933e9b0-e1e8-4733-b939-16df5e7755b5 |
| image | cirros (e82bb244-644a-4d9c-8739-053f55328634) |
| key_name | mykey |
| name | test-vm1 |
| progress | 0 |
| project_id | 9ec36b2a4f4d470380e7c5be0911d1b8 |
| properties | |
| security_groups | name='dc8470ea-14ac-44da-9a1f-e8d1f62d3658' |
| status | BUILD |
| updated | 2022-07-23T10:19:41Z |
| user_id | 1cc3677f95194cb28fb0d7bc4b121fed |
| volumes_attached | |
+-----------------------------+-----------------------------------------------+
4、查看实例启动状态
[root@controller ~]# openstack server list
+--------------------------------------+----------+--------+---------------------+--------+---------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+----------+--------+---------------------+--------+---------+
| 6933e9b0-e1e8-4733-b939-16df5e7755b5 | test-vm1 | ACTIVE | provider=10.0.0.214 | cirros | m1.nano |
+--------------------------------------+----------+--------+---------------------+--------+---------+
5.查看VNC登录URL
[root@controller ~]# openstack console url show test-vm1
+-------+-------------------------------------------------------------------------------------------+
| Field | Value |
+-------+-------------------------------------------------------------------------------------------+
| type | novnc |
| url | http://controller:6080/vnc_auto.html?path=%3Ftoken%3D2985d954-f70d-4baf-9586-310aed19068d |
+-------+-------------------------------------------------------------------------------------------+
九、验证
1.在浏览器输入URL(每次重启过后要重新使用命令获取URL)
获取的URL的主机名替换成控制节点IP地址
http://10.0.0.20:6080/vnc_auto.html?path=%3Ftoken%3D2985d954-f70d-4baf-9586-310aed19068d
用户名:cirros
密码:gocubsgo
2.测试各网段连通性
#检测各网段的连通性
$ ping 10.0.0.10
PING 10.0.0.10 (10.0.0.10): 56 data bytes
64 bytes from 10.0.0.10: seq=0 ttl=64 time=1.216 ms
64 bytes from 10.0.0.10: seq=1 ttl=64 time=0.308 ms
64 bytes from 10.0.0.10: seq=2 ttl=64 time=0.277 ms
^C
--- 10.0.0.10 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.277/0.600/1.216 ms
$
$ ping 10.0.0.20
PING 10.0.0.20 (10.0.0.20): 56 data bytes
64 bytes from 10.0.0.20: seq=0 ttl=64 time=2.621 ms
64 bytes from 10.0.0.20: seq=1 ttl=64 time=0.656 ms
64 bytes from 10.0.0.20: seq=2 ttl=64 time=0.581 ms
^C
--- 10.0.0.20 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.581/1.286/2.621 ms
$ ping www.baidu.com
PING www.baidu.com (14.215.177.38): 56 data bytes
64 bytes from 14.215.177.38: seq=0 ttl=128 time=32.296 ms
64 bytes from 14.215.177.38: seq=1 ttl=128 time=31.121 ms
64 bytes from 14.215.177.38: seq=2 ttl=128 time=32.011 ms
^C
--- www.baidu.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 31.121/31.809/32.296 ms