先电openstack平台搭建

openstack平台搭建流程

  1. 准备好两台虚拟机配置如下

    vm1 vm2
    网卡 ens33:192.168.200.10 ens37:192.168.100.10 ens33:192.168.200.20 ens37:192.168.100.20
    vcpu 2vcpu4核 2vcpu4核
    内存 8G 8G
    硬盘 100G 100G

    (注:ens33为外网网卡,ens37为内网网卡不需要配置网关和DNS)

  2. 设置主机名,关闭防火墙,关闭selinux,重新连接使.

    1. 主机名配置
    hostname controller
    
    1. 关闭防火墙
    systemctl stop firewalld
    systemctl disable firewalld
    systemctl status firewalld
    
    1. 关闭selinux
    setenforce 0
    
    1. 断开重连CRT
  3. 设置本地yum源

    1. 挂载镜像文件
    上传CentOS-7-x86_64-DVD-1804.iso 和 XianDian-IaaS-v2.2.iso 到/opt目录下
    mkdir /opt/centos
    mkdir /opt/iaas
    mount -o loop CentOS-7-x86_64-DVD-1804.iso /opt/centos/
    mount -o loop XianDian-IaaS-v2.2.iso /opt/iaas
    
    1. 在controller节点和compute节点分别新建一个目录将/etc/yum.repo.d中的文件备份
    mkdir /opt/repo
    mv /etc/yum.repo.d/*.* /opt/repo
    
    1. 编写controller节点的yum.repo文件
     vim /etc/yum.repos.d/local.repo 
    [centos]
    name=centos
    baseurl=file:///opt/centos
    gpgcheck=0
    enabled=1
    [iaas]
    name=iaas
    baseurl=file:///opt/iaas/iaas-repo
    gpgcheck=0
    enabled=1
    
    1. 安装vsftpd并编写配置文件
    yum install -y vsftpd
    
    vim /etc/vsftpd/vsftpd.conf
    ...
    anon_root=/opt
    
    1. 编写compute节点的额yum.repo文件
    vim /etc/yum.repo.d/ftp.repo
    [centos]
    name=centos
    baseurl=ftp://controller/centos
    gpgcheck=0
    enabled=1
    [iaas]
    name=iaas
    baseurl=ftp://controller/iaas/iaas-repo
    gpgcheck=0
    enabled=1
    
    1. 测试本地yum源是否可用
    yum clean all
    Loaded plugins: fastestmirror
    Cleaning repos: base centos extras iaas updates
    Cleaning up list of fastest mirrors
    yum makecache
    #不出现error即可
    
  4. 配置环境变量

    1. 安装先电包
    yum install -y iaas-xiandian
    
    1. 编写变量文件openrc.sh
    sed -i 's/PASS=/PASS=000000/g' /etc/xiandian/openrc.sh
    sed -i 's/^#//g' /etc/xiandian/openrc.sh
    vim /etc/xiandian/openrc.sh
    #进一步编辑文件将剩下的11行内容补充上
    
    1. 将controller节点的openrc.sh文件同步到compute上
    scp /etc/xiandian/openrc.sh compute:/etc/xiandian/openrc.sh
    
    1. 分别检查两个节点的环境变量
  5. 开始部署openstack各个组件

    controller节点 compute节点
    iaas-pre-host.sh iaas-pre-host.sh
    iaas-install-mysql.sh iaas-install-mysql.sh
    iaas-install-keystone.sh
    iaas-install-glance.sh
    iaas-install-nova-controller.sh iaas-install-nova-compute.sh
    iaas-install-neutron-controller.sh iaas-install-neutron-compute.sh
    iaas-install-neutron-controller-gre.sh iaas-install-neutron-compute-gre.sh
    iaas-install-dashboard.sh

    (注:每次先执行controller节点,在执行compute节点)

  6. 上传 CentOS_7.2_x86_64_XD.qcow2 镜像

openstack image create --file /opt/iaas/image/CentOS_7.2_x86_64_XD.qcow2 --disk-format qcow2 --container-format bare centos7
  1. 创建外网,内网,子网,路由
...
  1. 登录dashboard,创建云主机,并且为云主机绑定浮动IP

  2. 创建网桥(在计算节点上操作)

    1. 查看网桥名称
    ip a
    9: br-ex: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    
    1. 编辑ifcfg-ens37文件
    vi ifcfg-ens37
    DEVICE=ens37
    TYPE=Ethernet
    BOOTPROTO=none
    ONBOOT=yes
    TYPE=OVSPort
    OVS_BRIDGE=br-ex
    
    1. 在/etc/sysconfig/network-scripts目录下创建ifcfg-br-ex文件
    vi ifcfg-br-ex
    DEFROUTE=yes
    PEERDNS=yes
    PEERROUTES=yes
    ONBOOT=yes
    IPADDR=192.168.100.40
    GATEWAY=192.168.100.1
    NETMASK=255.255.255.0
    DEVICE=br-ex
    NAME=br-ex
    DEVICETYPE=ovs
    OVSBOOTPROTO=static
    TYPE=OVSBridge
    
    1. 连接测试
    #ping浮动IP的网关:
    [root@compute ~]# ping 192.168.100.1
    PING 192.168.100.1 (192.168.100.1) 56(84) bytes of data.
    64 bytes from 192.168.100.1: icmp_seq=1 ttl=128 time=1.07 ms
    64 bytes from 192.168.100.1: icmp_seq=2 ttl=128 time=0.939 ms
    ^C
    --- 192.168.100.1 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1002ms
    rtt min/avg/max/mdev = 0.939/1.006/1.074/0.074 ms
    #ping浮动ip地址
    [root@compute ~]# ping 192.168.100.4
    PING 192.168.100.4 (192.168.100.4) 56(84) bytes of data.
    64 bytes from 192.168.100.4: icmp_seq=1 ttl=63 time=1.60 ms
    64 bytes from 192.168.100.4: icmp_seq=2 ttl=63 time=2.16 ms
    64 bytes from 192.168.100.4: icmp_seq=3 ttl=63 time=2.11 ms
    ^C
    --- 192.168.100.4 ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 2003ms
    rtt min/avg/max/mdev = 1.606/1.961/2.164/0.251 ms
    #使用ssh连接
    [root@compute ~]# ssh 192.168.100.4
    root@192.168.100.4's password: 
    Last login: Sat Oct 17 13:23:09 2020 from 192.168.100.40
    
     #########################
     #  Welcome to XianDian  #
     #########################
    
    [root@ecs ~]# 
    
posted @ 2020-10-18 15:27  派大星的脑子  阅读(252)  评论(0)    收藏  举报