云盘算赛项学习————OpenStack 平台搭建

知者何南  金牌会员 | 2024-6-10 13:05:58 | 来自手机 | 显示全部楼层 | 阅读模式
打印 上一主题 下一主题

主题 777|帖子 777|积分 2331

PS: 原创作品,严禁用于商业目标。如有任何技术问题,欢迎和我交流:w104118078  (微信号)
一、基础环境准备

   OpenStack云平台搭建需要两个节点:controller(控制节点),compute(盘算节点)
  
  控制节点(controller)规划如下:
          一块200G的硬盘。两块网卡,第一块网卡(桥接模式)IP地点利用192.168.100.100,第二块网卡(仅主机模式)IP地点利用192.168.200.100
  
  盘算节点(compute)规划如下:
          一块200G的硬盘和一块100G的硬盘。两块网卡,第一块网卡(桥接模式)IP地点利用192.168.100.200,第二块网卡(仅主机模式)IP地点利用192.168.200.200。
  PS:  在VMware中将仅主机模式的DHCP服务关闭,并将网络分配地点更改为192.168.200.0        255.255.255.0
  
  云平台搭建需要利用centos7.0版本的镜像和chinaskills_cloud_iaas.iso镜像,镜像提供如下:
  centos7.0镜像链接:https://pan.baidu.com/s/1v0xOq7N6WSofosa7AEMb-A?pwd=chjx
  iaas镜像链接:https://pan.baidu.com/s/1stR_BCNPUEYrIrOpzjItAA?pwd=chjx 
  

二、搭建OpenStack云平台

controller节点配置:

  1. ## 1.controller 网络配置
  2. [root@controller ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
  3. TYPE=Ethernet
  4. PROXY_METHOD=none
  5. BROWSER_ONLY=no
  6. BOOTPROTO=static
  7. IPADDR=192.168.100.100
  8. NETMASK=255.255.255.0
  9. GATEWAY=192.168.100.1
  10. DNS1=233.5.5.5
  11. DNS2=114.114.114.114
  12. DEFROUTE=yes
  13. IPV4_FAILURE_FATAL=no
  14. IPV6INIT=yes
  15. IPV6_AUTOCONF=yes
  16. IPV6_DEFROUTE=yes
  17. IPV6_FAILURE_FATAL=no
  18. IPV6_ADDR_GEN_MODE=stable-privacy
  19. NAME=ens33
  20. UUID=4933c159-8fcb-4646-a29f-6b5c8b4e79f
  21. DEVICE=ens33
  22. ONBOOT=yes
  23. [root@controller ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens34
  24. TYPE=Ethernet
  25. PROXY_METHOD=none
  26. BROWSER_ONLY=no
  27. BOOTPROTO=static
  28. IPADDR=192.168.200.100
  29. NETMASK=255.255.255.0
  30. DEFROUTE=yes
  31. IPV4_FAILURE_FATAL=no
  32. IPV6INIT=yes
  33. IPV6_AUTOCONF=yes
  34. IPV6_DEFROUTE=yes
  35. IPV6_FAILURE_FATAL=no
  36. IPV6_ADDR_GEN_MODE=stable-privacy
  37. NAME=ens34
  38. UUID=932fef43-d94a-4a84-9b3f-428a85af8858
  39. DEVICE=ens34
  40. ONBOOT=yes
  41. ## 2.修改主机名
  42. [root@localhost ~]# hostnamectl set-hostname controller
  43. [root@controller ~]# bash
  44. ## 3.修改 hosts 文件将 IP 地址映射为主机名
  45. [root@controller ~] vi /etc/hosts
  46. 192.168.100.100 controller
  47. 192.168.100.200 compute
  48. ## 4.关闭防火墙
  49. [root@controller ~]# systemctl disable firewalld
  50. [root@controller ~]# systemctl stop firewalld
  51. ## 5.设置seLinux
  52. SELinux有两个级别:
  53. 强制、警告
  54. setenforce 0 :表示警告(Permissive)
  55. setenforce 1 :表示强制(Enforcing)
  56. 状态分为以下三种:
  57. SELINUX=enforcing #selinux开启,级别为强制
  58. SELINUX=permissive #selinux开启,级别为警告
  59. SELINUX=disabled #selinux关闭
  60. [root@controller ~]# setenforce 0        # 临时设置等级,重启失效
  61. [root@controller ~]# vi /etc/selinux/conf        #  重启后,永久生效
  62. SELINUX=permissive
  63. ## 6.配置Yum源
  64. 上传 CentOS 7 ISO镜像文件和iaas ISO镜像文件到controller主机root目录下面
  65. [C:\~]$ scp D:\chinaskills_cloud_iaas.iso root@192.168.200.100:/root
  66. [C:\~]$ scp D:\CentOS-7-x86_64-DVD-1804.iso root@192.168.200.100:/root
  67. [root@controller ~]# ls
  68. anaconda-ks.cfg  CentOS-7-x86_64-DVD-1804.iso  chinaskills_cloud_iaas.iso
  69. 挂载镜像到opt目录下(临时挂载,重启失效)
  70. [root@controller ~]# mount -o loop chinaskills_cloud_iaas.iso /opt/iaas/
  71. mount: /dev/loop is write-protected, mounting read-only
  72. [root@controller ~]# mount -o loop CentOS-7-x86_64-DVD-1804.iso /opt/centos/
  73. mount: /dev/loop is write-protected, mounting read-only
  74. ——————————————————————————————————————————————————————————————————————————————————————
  75. [root@controller ~]# vi /etc/fstab       # 永久挂载
  76. /dev/mapper/centos-root /                       xfs     defaults        0 0
  77. UUID=fda6f1d5-b8c5-4401-a68b-b2ab67ed8370 /boot                   xfs     defaults        0 0
  78. /dev/mapper/centos-swap swap                    swap    defaults        0 0
  79. #添加以下内容
  80. #镜像名称                                                                挂载路径                        格式               
  81. /root/CentOS-7-x86_64-DVD-1804.iso      /opt/centos     iso9660 defaults        0 0
  82. /root/chinaskills_cloud_iaas.iso        /opt/iaas       iso9660 defaults        0 0
  83. [root@controller ~]# gzip /etc/yum.repo.d/*        # 使原yum源失效
  84. [root@controller ~]# vi /etc/yum.repo.d/local.repo
  85. [centos]
  86. name=centos
  87. baseurl=file:///opt/centos
  88. gpgcheck=0
  89. enabled=1
  90. [iaas]
  91. name=iaas
  92. baseurl=file:///opt/iaas/iaas-repo
  93. gpgcheck=0
  94. enabled=1
  95. [root@controller ~]# yum clean all        # 清除yum源缓存
  96. [root@controller ~]# yum repolist        # 验证yum源
  97. ## 7.搭建vsftpd
  98. [root@controller ~]# yum install -y vsftpd
  99. [root@controller ~]# echo anon_root=/opt/ >> /etc/vsftpd/vsftpd.conf    # 修改vsftp 共享服务根目录
  100. [root@controller ~]# systemctl enable vsftpd
  101. [root@controller ~]# systemctl start vsftpd
  102. ## 8.时间同步配置
  103. [root@controller ~]# yum -y install chrony
  104. [root@controller ~]# vi /etc/chrony.conf        # 修改配置文件
  105. server controller iburst
  106. driftfile /var/lib/chrony/drift
  107. makestep 1.0 3
  108. rtcsync
  109. allow 192.168.100.0/24
  110. local stratum 10
  111. logdir /var/log/chrony
  112. [root@controller ~]# systemctl restart chronyd        # 重启chrony服务
  113. [root@controller ~]# systemctl enable chronyd         # 设置开机自启动
复制代码
compute节点配置:

  1. ## 1.compute 网络配置
  2. [root@compute ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
  3. TYPE=Ethernet
  4. PROXY_METHOD=none
  5. BROWSER_ONLY=no
  6. BOOTPROTO=static
  7. IPADDR=192.168.100.200
  8. NETMASK=255.255.255.0
  9. GATEWAY=192.168.100.1
  10. DNS1=233.5.5.5
  11. DNS2=114.114.114.114
  12. DEFROUTE=yes
  13. IPV4_FAILURE_FATAL=no
  14. IPV6INIT=yes
  15. IPV6_AUTOCONF=yes
  16. IPV6_DEFROUTE=yes
  17. IPV6_FAILURE_FATAL=no
  18. IPV6_ADDR_GEN_MODE=stable-privacy
  19. NAME=ens33
  20. UUID=4933c159-8fcb-4646-a29f-6b5c8b4e79f8
  21. DEVICE=ens33
  22. ONBOOT=yes
  23. [root@compute ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens34
  24. TYPE=Ethernet
  25. PROXY_METHOD=none
  26. BROWSER_ONLY=no
  27. BOOTPROTO=static
  28. IPADDR=192.168.200.200
  29. NETMASK=255.255.255.0
  30. DEFROUTE=yes
  31. IPV4_FAILURE_FATAL=no
  32. IPV6INIT=yes
  33. IPV6_AUTOCONF=yes
  34. IPV6_DEFROUTE=yes
  35. IPV6_FAILURE_FATAL=no
  36. IPV6_ADDR_GEN_MODE=stable-privacy
  37. NAME=ens34
  38. UUID=932fef43-d94a-4a84-9b3f-428a85af8858
  39. DEVICE=ens34
  40. ONBOOT=yes
  41. ## 2.修改主机名
  42. [root@localhost ~]# hostnamectl set-hostname compute
  43. [root@compute ~]# bash
  44. ## 3.修改 hosts 文件将 IP 地址映射为主机名
  45. [root@compute ~] vi /etc/hosts
  46. 192.168.100.100 compute
  47. 192.168.100.200 compute
  48. ## 4.关闭防火墙
  49. [root@compute ~]# systemctl disable firewalld
  50. [root@compute ~]# systemctl stop firewalld
  51. ## 5.设置seLinux
  52. SELinux有两个级别:
  53. 强制、警告
  54. setenforce 0 :表示警告(Permissive)
  55. setenforce 1 :表示强制(Enforcing)
  56. 状态分为以下三种:
  57. SELINUX=enforcing #selinux开启,级别为强制
  58. SELINUX=permissive #selinux开启,级别为警告
  59. SELINUX=disabled #selinux关闭
  60. [root@compute ~]# setenforce 0        # 临时设置等级,重启失效
  61. [root@compute ~]# vi /etc/selinux/conf        #  重启后,永久生效
  62. SELINUX=permissive
  63. ## 6.配置Yum源
  64. [root@compute ~]# gzip /etc/yum.repo.d/*        # 使原yum源失效
  65. [root@compute ~]# vi /etc/yum.repo.d/local.repo
  66. [centos]
  67. name=centos
  68. baseurl=ftp://controller/centos
  69. gpgcheck=0
  70. enabled=1
  71. [iaas]
  72. name=iaas
  73. baseurl=ftp://controller/iaas/iaas-repo
  74. gpgcheck=0
  75. enabled=1
  76. [root@compute ~]# yum clean all        # 清除yum源缓存
  77. [root@compute ~]# yum repolist        # 验证yum源
  78. ## 7.时间同步设置
  79. [root@compute ~]# yum -y install chrony
  80. [root@compute ~]# vi /etc/chrony.conf
  81. server controller iburst
  82. driftfile /var/lib/chrony/drift
  83. makestep 1.0 3
  84. rtcsync
  85. logdir /var/log/chrony
  86. [root@compute ~]# systemctl restart chronyd        # 重启chrony服务
  87. [root@compute ~]# chronyc sources -v
  88. # 结尾显示为 ^* controller  则是同步成功
  89. ## 8.设置硬盘分区
  90. [root@compute ~]# lsblk
  91. NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
  92. sda               8:0    0   20G  0 disk
  93. ├─sda1            8:1    0    1G  0 part /boot
  94. └─sda2            8:2    0   19G  0 part
  95.   ├─centos-root 253:0    0   17G  0 lvm  /
  96.   └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
  97. sdb               8:16   0  200G  0 disk
  98. sr0              11:0    1  4.2G  0 rom
  99. [root@compute ~]# fdisk /dev/sdb
  100. Command (m for help): n
  101. Select (default p): p
  102. Partition number (1-4, default 1):
  103. First sector (2048-419430399, default 2048):
  104. Using default value 2048
  105. Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399): +25G    # 输入 +25G ,将sdb 硬盘分区1 设置为25G大小
  106. Command (m for help): n
  107. Select (default p): p
  108. Partition number (2-4, default 2):
  109. First sector (52430848-419430399, default 52430848):
  110. Using default value 52430848
  111. Last sector, +sectors or +size{K,M,G} (52430848-419430399, default 419430399): +25G    #
  112. 输入 +20G ,将sdb 硬盘分区2 设置为25G大小
  113. Partition 2 of type Linux and of size 25 GiB is set
  114. Command (m for help): w        # 输入w更新磁盘并退出
  115. The partition table has been altered!
复制代码
三、正式搭建OpenStack云平台

controller节点配置:

  1. [root@controller ~]# yum install -y iaas-xiandian
  2. [root@controller ~]# vi /etc/xiandian/openrc.sh
  3. 命令模式下输入::%s/^#//g                # 将#号去掉
  4. #--------------------system Config--------------------##
  5. #Controller Server Manager IP. example:x.x.x.x
  6. HOST_IP=192.168.100.100        #controller节点的IP地址
  7. #Controller HOST Password. example:000000
  8. HOST_PASS=000000
  9. #Controller Server hostname. example:controller
  10. HOST_NAME=controller
  11. #Compute Node Manager IP. example:x.x.x.x
  12. HOST_IP_NODE=192.168.100.200        #compute节点的IP地址
  13. #Compute HOST Password. example:000000
  14. HOST_PASS_NODE=000000
  15. #Compute Node hostname. example:compute
  16. HOST_NAME_NODE=compute
  17. #--------------------Chrony Config-------------------##
  18. #Controller network segment IP.  example:x.x.0.0/16(x.x.x.0/24)
  19. network_segment_IP=192.168.100.0/24        #controller节点所在的网段
  20. #--------------------Rabbit Config ------------------##
  21. #user for rabbit. example:openstack
  22. RABBIT_USER=openstack
  23. #Password for rabbit user .example:000000
  24. RABBIT_PASS=000000
  25. #--------------------MySQL Config---------------------##
  26. #Password for MySQL root user . exmaple:000000
  27. DB_PASS=000000
  28. #--------------------Keystone Config------------------##
  29. #Password for Keystore admin user. exmaple:000000
  30. DOMAIN_NAME=demo        
  31. ADMIN_PASS=000000
  32. DEMO_PASS=000000
  33. #Password for Mysql keystore user. exmaple:000000
  34. KEYSTONE_DBPASS=000000
  35. #--------------------Glance Config--------------------##
  36. #Password for Mysql glance user. exmaple:000000
  37. GLANCE_DBPASS=000000
  38. #Password for Keystore glance user. exmaple:000000
  39. GLANCE_PASS=000000
  40. #--------------------Nova Config----------------------##
  41. #Password for Mysql nova user. exmaple:000000
  42. NOVA_DBPASS=000000
  43. #Password for Keystore nova user. exmaple:000000
  44. NOVA_PASS=000000
  45. #--------------------Neturon Config-------------------##
  46. #Password for Mysql neutron user. exmaple:000000
  47. NEUTRON_DBPASS=000000
  48. #Password for Keystore neutron user. exmaple:000000
  49. NEUTRON_PASS=000000
  50. #metadata secret for neutron. exmaple:000000
  51. METADATA_SECRET=000000
  52. #Tunnel Network Interface. example:x.x.x.x
  53. INTERFACE_IP=192.168.100.100        #本机IP地址
  54. #External Network Interface. example:eth1
  55. INTERFACE_NAME=ens33
  56. #External Network The Physical Adapter. example:provider
  57. Physical_NAME=provider
  58. #First Vlan ID in VLAN RANGE for VLAN Network. exmaple:101
  59. minvlan=101
  60. #Last Vlan ID in VLAN RANGE for VLAN Network. example:200
  61. maxvlan=200
  62. #--------------------Cinder Config--------------------##
  63. #Password for Mysql cinder user. exmaple:000000
  64. CINDER_DBPASS=000000
  65. #Password for Keystore cinder user. exmaple:000000
  66. CINDER_PASS=000000
  67. #Cinder Block Disk. example:md126p3
  68. BLOCK_DISK=sdb1        #compute节点的存储块
  69. #--------------------Swift Config---------------------##
  70. #Password for Keystore swift user. exmaple:000000
  71. SWIFT_PASS=000000
  72. #The NODE Object Disk for Swift. example:md126p4.
  73. OBJECT_DISK=sdb2        #compute节点的存储块
  74. #The NODE IP for Swift Storage Network. example:x.x.x.x.
  75. STORAGE_LOCAL_NET_IP=192.168.100.200    #compute节点的IP地址
  76. #--------------------Heat Config----------------------##
  77. #Password for Mysql heat user. exmaple:000000
  78. HEAT_DBPASS=000000
  79. #Password for Keystore heat user. exmaple:000000
  80. HEAT_PASS=000000
  81. #--------------------Zun Config-----------------------##
  82. #Password for Mysql Zun user. exmaple:000000
  83. ZUN_DBPASS=000000
  84. #Password for Keystore Zun user. exmaple:000000
  85. ZUN_PASS=000000
  86. #Password for Mysql Kuryr user. exmaple:000000
  87. KURYR_DBPASS=000000
  88. #Password for Keystore Kuryr user. exmaple:000000
  89. KURYR_PASS=000000
  90. #--------------------Ceilometer Config----------------##
  91. #Password for Gnocchi ceilometer user. exmaple:000000
  92. CEILOMETER_DBPASS=000000
  93. #Password for Keystore ceilometer user. exmaple:000000
  94. CEILOMETER_PASS=000000
  95. #--------------------AODH Config----------------##
  96. #Password for Mysql AODH user. exmaple:000000
  97. AODH_DBPASS=000000
  98. #Password for Keystore AODH user. exmaple:000000
  99. AODH_PASS=000000
  100. #--------------------Barbican Config----------------##
  101. #Password for Mysql Barbican user. exmaple:000000
  102. BARBICAN_DBPASS=000000
  103. #Password for Keystore Barbican user. exmaple:000000
  104. BARBICAN_PASS=000000
  105. [root@controller ~]# source /etc/xiandian/openrc.sh        # 环境配置生效
  106. [root@controller ~]# scp /etc/xiandian/openrc.sh root@compute:/etc/xiandian/openrc.sh    # 将controller节点的脚本拷贝到compute节点
复制代码
compute节点配置:

  1. [root@compute ~]# yum install -y iaas-xiandian
  2. [root@compute ~]# vi /etc/xiandian/openrc.sh        # 修改脚本
  3. INTERFACE_IP=192.168.100.200        #本机IP地址
复制代码
 刷脚本:

  1. controller节点:
  2.   安装OpenStack包,配置域名解析,防火墙和Selinux,安装NTP服务等
  3. ​[root@controller ~]# iaas-pre-host.sh         # 刷完脚本后需要重启
  4. PS:注意使用临时挂载的话,controller节点重启后,需要重新挂载yum源
  5.   安装RabbitMQ服务、Mysql、memcahce等
  6. [root@controller ~]# iaas-install-mysql.sh
  7.   安装keystone服务包,创建Keystone数据库,配置数据库连接
  8. [root@controller ~]# iaas-install-keystone.sh
  9.   安装Glance镜像服务包,创建Glance数据库,配置数据库连接
  10. [root@controller ~]# iaas-install-glance.sh
  11.   安装nova
  12. [root@controller ~]# iaas-install-nova-controller.sh
  13.   安装neutron
  14. [root@controller ~]# iaas-install-neutron-controller.sh
  15.   安装Dashboard
  16. [root@controller ~]# iaas-install-dashboard.sh
  17. compute节点:
  18.   安装OpenStack包,配置域名解析,防火墙和Selinux,安装NTP服务等
  19. [root@compute ~]# iaas-pre-host.sh            # 刷完脚本后需要重启
  20.   安装nova
  21. [root@compute ~]# iaas-install-nova-compute.sh
  22.   安装neutron
  23. [root@compute ~]# iaas-install-neutron-compute.sh
复制代码
四、 登录OpenStack云平台

在浏览器界面输入192.168.100.100/dashboard



免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

知者何南

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表