当前位置:   article > 正文

OpenStack Dashboard部署\提供商网络创建启动实例(8)_dashboard 创建内部网络

dashboard 创建内部网络

目录

一、安装软件包

二、编辑修改配置文件

三、验证

 四、创建启动实例

五、创建实例

六、创建密钥对

七、添加安全组规则

八、启动实例

九、验证


一、安装软件包

 [root@controller ~]# yum install openstack-dashboard -y

二、编辑修改配置文件

1.修改配置文件

①.备份配置文件

②.修改配置文件

  1. [root@controller ~]# cp /etc/openstack-dashboard/local_settings /etc/openstack-dashboard/local_settings.backup
  2. [root@controller ~]# vim /etc/openstack-dashboard/local_settings
  3. #配置httpd访问目录、设置登录超时时间
  4. WEBROOT = '/dashboard/'
  5. SESSION_TIMEOUT = 86400
  6. #添加主机名称
  7. OPENSTACK_HOST = "controller"
  8. #允许所有人登录
  9. ALLOWED_HOSTS = ['*', ]
  10. #配置回话存储服务:memcached
  11. SESSION_ENGINE = 'django.contrib.sessions.backends.file'
  12. CACHES = {
  13. 'default': {
  14. 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
  15. 'LOCATION': 'controller:11211',
  16. },
  17. }
  18. #启用身份API版本
  19. OPENSTACK_API_VERSIONS = {
  20. "identity": 3,
  21. "image": 2,
  22. "volume": 3,
  23. }
  24. #启用对域的支持:
  25. OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True
  26. #配置为通过仪表板创建的用户的默认域:Default
  27. OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "Default"
  28. #配置user为通过仪表板创建的用户的默认角色
  29. OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user"
  30. #设置时区为上海
  31. TIME_ZONE = "Asia/Shanghai"

3.修改httpd配置文件

①.如果未包含则添加到

/etc/httpd/conf.d/openstack-dashboard.conf

  1. [root@controller ~]# vim /etc/httpd/conf.d/openstack-dashboard.conf
  2. WSGIApplicationGroup %{GLOBAL}

4.重新启动web服务器和会话存储服务

①.查看是否成功启动

  1. [root@controller ~]# systemctl restart httpd.service memcached.service
  2. [root@controller ~]# systemctl status httpd.service memcached.service
  3. ● httpd.service - The Apache HTTP Server
  4. Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
  5. Drop-In: /usr/lib/systemd/system/httpd.service.d
  6. └─openstack-dashboard.conf
  7. Active: active (running) since Fri 2022-07-22 18:01:40 CST; 9s ago
  8. Docs: man:httpd(8)
  9. man:apachectl(8)
  10. Process: 5091 ExecStartPre=/usr/bin/python2 /usr/share/openstack-dashboard/manage.py compress --force -v0 (code=exited, status=0/SUCCESS)
  11. Process: 5059 ExecStartPre=/usr/bin/python2 /usr/share/openstack-dashboard/manage.py collectstatic --noinput --clear -v0 (code=exited, status=0/SUCCESS)
  12. Main PID: 5114 (httpd)
  13. Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
  14. CGroup: /system.slice/httpd.service
  15. ├─5114 /usr/sbin/httpd -DFOREGROUND
  16. ├─5116 /usr/sbin/httpd -DFOREGROUND
  17. ├─5117 /usr/sbin/httpd -DFOREGROUND
  18. ├─5118 /usr/sbin/httpd -DFOREGROUND
  19. ├─5119 /usr/sbin/httpd -DFOREGROUND
  20. ├─5120 (wsgi:keystone- -DFOREGROUND
  21. ├─5121 (wsgi:keystone- -DFOREGROUND
  22. ├─5122 (wsgi:keystone- -DFOREGROUND
  23. ├─5123 (wsgi:keystone- -DFOREGROUND
  24. ├─5124 (wsgi:keystone- -DFOREGROUND
  25. ├─5125 /usr/sbin/httpd -DFOREGROUND
  26. ├─5126 /usr/sbin/httpd -DFOREGROUND
  27. ├─5127 /usr/sbin/httpd -DFOREGROUND
  28. ├─5128 /usr/sbin/httpd -DFOREGROUND
  29. └─5129 /usr/sbin/httpd -DFOREGROUND
  30. Jul 22 18:01:19 controller systemd[1]: Starting The Apache HTTP Server...
  31. Jul 22 18:01:40 controller python2[5091]: Compressing... done
  32. Jul 22 18:01:40 controller python2[5091]: Compressed 7 block(s) from 4 template(s) for 2 context(s).
  33. Jul 22 18:01:40 controller systemd[1]: Started The Apache HTTP Server.
  34. ● memcached.service - memcached daemon
  35. Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled; vendor preset: disabled)
  36. Active: active (running) since Fri 2022-07-22 18:01:19 CST; 31s ago
  37. Main PID: 5058 (memcached)
  38. CGroup: /system.slice/memcached.service
  39. └─5058 /usr/bin/memcached -p 11211 -u memcached -m 64 -c 1024 -l 127.0.0.1,::1,controller
  40. 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.创建网络

  1. [root@controller ~]# openstack network create --share --external \
  2. --provider-physical-network provider \
  3. --provider-network-type flat provider
  4. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
  5. | Field | Value |
  6. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
  7. | admin_state_up | UP |
  8. | availability_zone_hints | |
  9. | availability_zones | |
  10. | created_at | 2022-07-23T09:45:49Z |
  11. | description | |
  12. | dns_domain | None |
  13. | id | c78a3847-5e46-4723-94e2-e06ddc4ab874 |
  14. | ipv4_address_scope | None |
  15. | ipv6_address_scope | None |
  16. | is_default | None |
  17. | is_vlan_transparent | None |
  18. | location | cloud='', project.domain_id=, project.domain_name='Default', project.id='495f2e77e0ba4614a4812bcd5fd86bb8', project.name='admin', region_name='', zone= |
  19. | mtu | 1500 |
  20. | name | provider |
  21. | port_security_enabled | True |
  22. | project_id | 495f2e77e0ba4614a4812bcd5fd86bb8 |
  23. | provider:network_type | flat |
  24. | provider:physical_network | provider |
  25. | provider:segmentation_id | None |
  26. | qos_policy_id | None |
  27. | revision_number | 1 |
  28. | router:external | External |
  29. | segments | None |
  30. | shared | True |
  31. | status | ACTIVE |
  32. | subnets | |
  33. | tags | |
  34. | updated_at | 2022-07-23T09:45:51Z |
  35. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+

3.创建子网

  1. #分配地址池范围(10.0.0.40/24~10.0.0.250/24)
  2. #dns服务器地址(8.8.8.8)、网关(10.0.0.2/24)
  3. #子网范围为(10.0.0.0/24)
  4. [root@controller ~]# openstack subnet create --network provider \
  5. --allocation-pool start=10.0.0.40,end=10.0.0.250 \
  6. --dns-nameserver 8.8.8.8 --gateway 10.0.0.2 \
  7. --subnet-range 10.0.0.0/24 provider
  8. +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
  9. | Field | Value |
  10. +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
  11. | allocation_pools | 10.0.0.40-10.0.0.250 |
  12. | cidr | 10.0.0.0/24 |
  13. | created_at | 2022-07-23T09:54:45Z |
  14. | description | |
  15. | dns_nameservers | 8.8.8.8 |
  16. | enable_dhcp | True |
  17. | gateway_ip | 10.0.0.2 |
  18. | host_routes | |
  19. | id | b593e744-a460-4ad5-9985-cabd08327cc6 |
  20. | ip_version | 4 |
  21. | ipv6_address_mode | None |
  22. | ipv6_ra_mode | None |
  23. | location | cloud='', project.domain_id=, project.domain_name='Default', project.id='495f2e77e0ba4614a4812bcd5fd86bb8', project.name='admin', region_name='', zone= |
  24. | name | provider |
  25. | network_id | c78a3847-5e46-4723-94e2-e06ddc4ab874 |
  26. | prefix_length | None |
  27. | project_id | 495f2e77e0ba4614a4812bcd5fd86bb8 |
  28. | revision_number | 0 |
  29. | segment_id | None |
  30. | service_types | |
  31. | subnetpool_id | None |
  32. | tags | |
  33. | updated_at | 2022-07-23T09:54:45Z |
  34. +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+

五、创建实例

1.创建一个flavor

①.运行内存为64M、一个虚拟CPU、一块存储硬盘

  1. [root@controller ~]# openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano
  2. +----------------------------+---------+
  3. | Field | Value |
  4. +----------------------------+---------+
  5. | OS-FLV-DISABLED:disabled | False |
  6. | OS-FLV-EXT-DATA:ephemeral | 0 |
  7. | disk | 1 |
  8. | id | 0 |
  9. | name | m1.nano |
  10. | os-flavor-access:is_public | True |
  11. | properties | |
  12. | ram | 64 |
  13. | rxtx_factor | 1.0 |
  14. | swap | |
  15. | vcpus | 1 |
  16. +----------------------------+---------+

六、创建密钥对

1.生成密钥对并添加公钥

①.创建一个demo-openrc.sh的环境脚本、执行环境脚本

②.生成秘钥对并添加

  1. [root@controller ~]# cat >>demo-openrc.sh<<EOF
  2. export OS_PROJECT_DOMAIN_NAME=Default
  3. export OS_USER_DOMAIN_NAME=Default
  4. export OS_PROJECT_NAME=myproject
  5. export OS_USERNAME=myuser
  6. export OS_PASSWORD=123456
  7. export OS_AUTH_URL=http://controller:5000/v3
  8. export OS_IDENTITY_API_VERSION=3
  9. export OS_IMAGE_API_VERSION=2
  10. EOF
  11. [root@controller ~]# . demo-openrc.sh
  12. #生成密钥对
  13. [root@controller ~]# ssh-keygen -q -N ""
  14. Enter file in which to save the key (/root/.ssh/id_rsa): ==>直接回车
  15. #添加密钥对
  16. [root@controller ~]# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
  17. +-------------+-------------------------------------------------+
  18. | Field | Value |
  19. +-------------+-------------------------------------------------+
  20. | fingerprint | 05:50:a0:e4:b2:83:bb:db:c2:30:3b:b7:fd:75:01:3e |
  21. | name | mykey |
  22. | user_id | 1cc3677f95194cb28fb0d7bc4b121fed |
  23. +-------------+-------------------------------------------------+
  24. #验证密钥对是否添加
  25. [root@controller ~]# openstack keypair list
  26. +-------+-------------------------------------------------+
  27. | Name | Fingerprint |
  28. +-------+-------------------------------------------------+
  29. | mykey | 05:50:a0:e4:b2:83:bb:db:c2:30:3b:b7:fd:75:01:3e |
  30. +-------+-------------------------------------------------+

七、添加安全组规则

  1. [root@controller ~]# openstack security group rule create --proto icmp default
  2. +-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  3. | Field | Value |
  4. +-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  5. | created_at | 2022-07-23T10:08:05Z |
  6. | description | |
  7. | direction | ingress |
  8. | ether_type | IPv4 |
  9. | id | aef07709-4ed0-489d-8553-f0ee1aac1adf |
  10. | location | cloud='', project.domain_id=, project.domain_name='Default', project.id='9ec36b2a4f4d470380e7c5be0911d1b8', project.name='myproject', region_name='', zone= |
  11. | name | None |
  12. | port_range_max | None |
  13. | port_range_min | None |
  14. | project_id | 9ec36b2a4f4d470380e7c5be0911d1b8 |
  15. | protocol | icmp |
  16. | remote_group_id | None |
  17. | remote_ip_prefix | 0.0.0.0/0 |
  18. | revision_number | 0 |
  19. | security_group_id | dc8470ea-14ac-44da-9a1f-e8d1f62d3658 |
  20. | tags | [] |
  21. | updated_at | 2022-07-23T10:08:05Z |
  22. +-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. [root@controller ~]# openstack security group rule create --proto tcp --dst-port 22 default
  24. +-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | Field | Value |
  26. +-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | created_at | 2022-07-23T10:09:18Z |
  28. | description | |
  29. | direction | ingress |
  30. | ether_type | IPv4 |
  31. | id | ff498d76-d9a1-438c-8591-da895c80f967 |
  32. | location | cloud='', project.domain_id=, project.domain_name='Default', project.id='9ec36b2a4f4d470380e7c5be0911d1b8', project.name='myproject', region_name='', zone= |
  33. | name | None |
  34. | port_range_max | 22 |
  35. | port_range_min | 22 |
  36. | project_id | 9ec36b2a4f4d470380e7c5be0911d1b8 |
  37. | protocol | tcp |
  38. | remote_group_id | None |
  39. | remote_ip_prefix | 0.0.0.0/0 |
  40. | revision_number | 0 |
  41. | security_group_id | dc8470ea-14ac-44da-9a1f-e8d1f62d3658 |
  42. | tags | [] |
  43. | updated_at | 2022-07-23T10:09:18Z |
  44. +-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+

八、启动实例

1.获取demo账户的环境变量

[root@controller ~]# . demo-openrc.sh

2.列出可用资源

①.列出实例

②.列出可用镜像

③.列出可用网络

④.列出可用安全组

  1. [root@controller ~]# openstack flavor list
  2. +----+---------+-----+------+-----------+-------+-----------+
  3. | ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
  4. +----+---------+-----+------+-----------+-------+-----------+
  5. | 0 | m1.nano | 64 | 1 | 0 | 1 | True |
  6. +----+---------+-----+------+-----------+-------+-----------+
  7. [root@controller ~]# openstack image list
  8. +--------------------------------------+--------+--------+
  9. | ID | Name | Status |
  10. +--------------------------------------+--------+--------+
  11. | e82bb244-644a-4d9c-8739-053f55328634 | cirros | active |
  12. +--------------------------------------+--------+--------+
  13. [root@controller ~]# openstack network list
  14. +--------------------------------------+----------+--------------------------------------+
  15. | ID | Name | Subnets |
  16. +--------------------------------------+----------+--------------------------------------+
  17. | c78a3847-5e46-4723-94e2-e06ddc4ab874 | provider | b593e744-a460-4ad5-9985-cabd08327cc6 |
  18. +--------------------------------------+----------+--------------------------------------+
  19. [root@controller ~]# openstack security group list
  20. +--------------------------------------+---------+------------------------+----------------------------------+------+
  21. | ID | Name | Description | Project | Tags |
  22. +--------------------------------------+---------+------------------------+----------------------------------+------+
  23. | dc8470ea-14ac-44da-9a1f-e8d1f62d3658 | default | Default security group | 9ec36b2a4f4d470380e7c5be0911d1b8 | [] |
  24. +--------------------------------------+---------+------------------------+----------------------------------+------+

3.启动实例

①.net-id修改成"openstack network list"获取的ID

②.test-vm1创建实例的名字

  1. [root@controller ~]# openstack server create --flavor m1.nano --image cirros \
  2. --nic net-id=c78a3847-5e46-4723-94e2-e06ddc4ab874 --security-group default \
  3. --key-name mykey test-vm1
  4. +-----------------------------+-----------------------------------------------+
  5. | Field | Value |
  6. +-----------------------------+-----------------------------------------------+
  7. | OS-DCF:diskConfig | MANUAL |
  8. | OS-EXT-AZ:availability_zone | |
  9. | OS-EXT-STS:power_state | NOSTATE |
  10. | OS-EXT-STS:task_state | scheduling |
  11. | OS-EXT-STS:vm_state | building |
  12. | OS-SRV-USG:launched_at | None |
  13. | OS-SRV-USG:terminated_at | None |
  14. | accessIPv4 | |
  15. | accessIPv6 | |
  16. | addresses | |
  17. | adminPass | Nq6tAmjAYy8T |
  18. | config_drive | |
  19. | created | 2022-07-23T10:19:41Z |
  20. | flavor | m1.nano (0) |
  21. | hostId | |
  22. | id | 6933e9b0-e1e8-4733-b939-16df5e7755b5 |
  23. | image | cirros (e82bb244-644a-4d9c-8739-053f55328634) |
  24. | key_name | mykey |
  25. | name | test-vm1 |
  26. | progress | 0 |
  27. | project_id | 9ec36b2a4f4d470380e7c5be0911d1b8 |
  28. | properties | |
  29. | security_groups | name='dc8470ea-14ac-44da-9a1f-e8d1f62d3658' |
  30. | status | BUILD |
  31. | updated | 2022-07-23T10:19:41Z |
  32. | user_id | 1cc3677f95194cb28fb0d7bc4b121fed |
  33. | volumes_attached | |
  34. +-----------------------------+-----------------------------------------------+

4、查看实例启动状态

  1. [root@controller ~]# openstack server list
  2. +--------------------------------------+----------+--------+---------------------+--------+---------+
  3. | ID | Name | Status | Networks | Image | Flavor |
  4. +--------------------------------------+----------+--------+---------------------+--------+---------+
  5. | 6933e9b0-e1e8-4733-b939-16df5e7755b5 | test-vm1 | ACTIVE | provider=10.0.0.214 | cirros | m1.nano |
  6. +--------------------------------------+----------+--------+---------------------+--------+---------+

5.查看VNC登录URL

  1. [root@controller ~]# openstack console url show test-vm1
  2. +-------+-------------------------------------------------------------------------------------------+
  3. | Field | Value |
  4. +-------+-------------------------------------------------------------------------------------------+
  5. | type | novnc |
  6. | url | http://controller:6080/vnc_auto.html?path=%3Ftoken%3D2985d954-f70d-4baf-9586-310aed19068d |
  7. +-------+-------------------------------------------------------------------------------------------+

九、验证

1.在浏览器输入URL(每次重启过后要重新使用命令获取URL)

获取的URL的主机名替换成控制节点IP地址

http://10.0.0.20:6080/vnc_auto.html?path=%3Ftoken%3D2985d954-f70d-4baf-9586-310aed19068d

用户名:cirros

密码:gocubsgo

 2.测试各网段连通性

  1. #检测各网段的连通性
  2. $ ping 10.0.0.10
  3. PING 10.0.0.10 (10.0.0.10): 56 data bytes
  4. 64 bytes from 10.0.0.10: seq=0 ttl=64 time=1.216 ms
  5. 64 bytes from 10.0.0.10: seq=1 ttl=64 time=0.308 ms
  6. 64 bytes from 10.0.0.10: seq=2 ttl=64 time=0.277 ms
  7. ^C
  8. --- 10.0.0.10 ping statistics ---
  9. 3 packets transmitted, 3 packets received, 0% packet loss
  10. round-trip min/avg/max = 0.277/0.600/1.216 ms
  11. $
  12. $ ping 10.0.0.20
  13. PING 10.0.0.20 (10.0.0.20): 56 data bytes
  14. 64 bytes from 10.0.0.20: seq=0 ttl=64 time=2.621 ms
  15. 64 bytes from 10.0.0.20: seq=1 ttl=64 time=0.656 ms
  16. 64 bytes from 10.0.0.20: seq=2 ttl=64 time=0.581 ms
  17. ^C
  18. --- 10.0.0.20 ping statistics ---
  19. 3 packets transmitted, 3 packets received, 0% packet loss
  20. round-trip min/avg/max = 0.581/1.286/2.621 ms
  21. $ ping www.baidu.com
  22. PING www.baidu.com (14.215.177.38): 56 data bytes
  23. 64 bytes from 14.215.177.38: seq=0 ttl=128 time=32.296 ms
  24. 64 bytes from 14.215.177.38: seq=1 ttl=128 time=31.121 ms
  25. 64 bytes from 14.215.177.38: seq=2 ttl=128 time=32.011 ms
  26. ^C
  27. --- www.baidu.com ping statistics ---
  28. 3 packets transmitted, 3 packets received, 0% packet loss
  29. round-trip min/avg/max = 31.121/31.809/32.296 ms

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号