首页 > 其他分享 >用虚拟机搭建iaas先电私有云平台

用虚拟机搭建iaas先电私有云平台

时间:2023-12-04 16:35:45浏览次数:39  
标签:00 compute ## 虚拟机 192.168 先电 controller iaas root



搭建流程

  • 1.配置网络,主机名(双节点)
  • 2.永久闭防火墙和selinux(双节点)
  • 3.配置YUM源(双节点)
  • 4.写入/etc/fstab,并挂载镜像
  • 5.安装iaas相关软件包
  • 6.划分磁盘作为swift和cinder
  • 7.修改环境变量
  • 8.配置NTP服务
  • 9.通过脚本安装服务
  • 10.通过IP访问云平台
  • 11.测试
  • 12.附录(用xshell连接虚拟机)


1.配置网络,主机名(双节点)

controller:192.168.1.10 192.168.2.10
compute:192.168.1.20 192.168.2.20

controller配置:
[root@controller ~]# hostnamectl set-hostname controller
[root@controller ~]# logout
重连登录
[root@controller ~]# vi /etc/sysconfig/network-scripts/ifcfg-eno16777728 
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777728
UUID=33c092da-748f-4504-b735-d9dff2a49d33
DEVICE=eno16777728
ONBOOT=yes
IPADDR=192.168.1.10
PREFIX=24
GATEWAY=192.168.1.1

[root@controller ~]# cd /etc/sysconfig/network-scripts/
[root@controller network-scripts]# cp -a ifcfg-eno16777728 ifcfg-eno33554960
[root@controller network-scripts]# vi /etc/sysconfig/network-scripts/ifcfg-eno33554960 
DEVICE=eno33554960
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.2.10
PREFIX=24
[root@controller ~]# systemctl restart network
[root@controller ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno16777728: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:01:7e:b7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.10/24 brd 192.168.1.255 scope global eno16777728
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe01:7eb7/64 scope link 
       valid_lft forever preferred_lft forever
3: eno33554960: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP qlen 1000
    link/ether 00:0c:29:01:7e:c1 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.10/24 brd 192.168.2.255 scope global eno33554960
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe01:7ec1/64 scope link 
       valid_lft forever preferred_lft forever

关机直接克隆compute
compute配置:
[root@compute ~]# hostnamectl set-hostname compute
[root@compute ~]# logout
重连登录
[root@compute ~]# vi /etc/sysconfig/network-scripts/ifcfg-eno16777728 
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777728
UUID=33c092da-748f-4504-b735-d9dff2a49d33
DEVICE=eno16777728
ONBOOT=yes
IPADDR=192.168.1.20
PREFIX=24

[root@compute ~]# cd /etc/sysconfig/network-scripts/
[root@compute network-scripts]# cp -a ifcfg-eno16777728 ifcfg-eno33554960
[root@compute network-scripts]# vi /etc/sysconfig/network-scripts/ifcfg-eno33554960 
DEVICE=eno33554960
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.2.20
PREFIX=24
[root@compute ~]# systemctl restart network
[root@compute ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno16777728: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:01:7e:b7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.20/24 brd 192.168.1.255 scope global eno16777728
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe01:7eb7/64 scope link 
       valid_lft forever preferred_lft forever
3: eno33554960: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP qlen 1000
    link/ether 00:0c:29:01:7e:c1 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.20/24 brd 192.168.2.255 scope global eno33554960
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe01:7ec1/64 scope link 
       valid_lft forever preferred_lft forever

记得拉取两个镜像!!!(只需要在controller节点拉取)

2.永久闭防火墙和selinux(双节点)

[root@controller yum.repos.d]# systemctl stop firewalld
[root@controller yum.repos.d]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

[root@controller yum.repos.d]# setenforce 0
[root@controller yum.repos.d]# vi /etc/selinux/config 


# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 








[root@compute yum.repos.d]# systemctl stop firewalld
[root@compute yum.repos.d]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

[root@compute yum.repos.d]# setenforce 0
[root@compute yum.repos.d]# vi /etc/selinux/config 


# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

3.配置YUM源(双节点)

配置主机名映射
[root@controller ~]# vi /etc/hosts
192.168.1.10 controller
192.168.1.20 compute
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

[root@compute ~]# vi /etc/hosts
192.168.1.10 controller
192.168.1.20 compute
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6


[root@controller ~]# cd /etc/yum.repos.d/
[root@controller yum.repos.d]# rm -rf *
[root@controller yum.repos.d]# cat 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


[root@compute ~]# cd /etc/yum.repos.d/
[root@compute yum.repos.d]# rm -rf *
[root@compute yum.repos.d]# cat local.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

4.写入/etc/fstab,并挂载镜像

[root@controller ~]# ls
anaconda-ks.cfg  CentOS-7-x86_64-DVD-1511.iso  XianDian-IaaS-v2.2.iso

[root@controller ~]# mkdir /opt/centos
[root@controller ~]# mkdir /opt/iaas

[root@controller ~]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Thu Oct  1 06:46:45 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=36615874-b25f-4539-b376-8a5c387c0212 /                       xfs     defaults        0 0
UUID=02223747-779a-4b6d-a300-2774ec29a144 /boot                   xfs     defaults        0 0
UUID=01956b4a-500a-4f23-8b60-75b3bb457ded swap                    swap    defaults        0 0
/root/CentOS-7-x86_64-DVD-1511.iso        /opt/centos	          iso9660	defaults 0 0
/root/XianDian-IaaS-v2.2.iso              /opt/iaas	          iso9660	defaults 0 0


[root@controller ~]# mount -a
mount: /dev/loop0 is write-protected, mounting read-only
mount: /dev/loop1 is write-protected, mounting read-only

[root@controller ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        98G  7.6G   90G   8% /
devtmpfs        904M     0  904M   0% /dev
tmpfs           913M     0  913M   0% /dev/shm
tmpfs           913M  8.5M  904M   1% /run
tmpfs           913M     0  913M   0% /sys/fs/cgroup
/dev/sda1       497M  118M  380M  24% /boot
tmpfs           183M     0  183M   0% /run/user/0
/dev/loop0      4.1G  4.1G     0 100% /opt/centos
/dev/loop1      2.7G  2.7G     0 100% /opt/iaas


[root@controller ~]# yum list
[root@controller ~]# yum install -y vim
[root@controller ~]# yum install -y vsftpd
[root@controller ~]# cat /etc/vsftpd/vsftpd.conf (在第一行添加下面内容,点点不用写)
anon_root=/opt/
...
...
[root@controller ~]# systemctl restart vsftpd
[root@controller ~]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.

5.安装iaas相关软件包

[root@controller ~]# yum install -y iaas-xiandian
[root@compute ~]# yum install -y iaas-xiandian

6.划分磁盘作为swift和cinder

[root@computer ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0002f10c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048     4196351     2097152   82  Linux swap / Solaris
/dev/sda2   *     4196352    41943039    18873344   83  Linux

Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@computer ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xa5eb8d25.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
Partition number (1-4, default 1): 
First sector (2048-209715199, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): +30G
Partition 1 of type Linux and of size 30 GiB is set

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): 
Using default response p
Partition number (2-4, default 2): 
First sector (62916608-209715199, default 62916608): 
Using default value 62916608
Last sector, +sectors or +size{K,M,G} (62916608-209715199, default 209715199): +30G
Partition 2 of type Linux and of size 30 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

[root@computer ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0002f10c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048     4196351     2097152   82  Linux swap / Solaris
/dev/sda2   *     4196352    41943039    18873344   83  Linux

Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xa5eb8d25

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    62916607    31457280   83  Linux
/dev/sdb2        62916608   125831167    31457280   83  Linux
[root@compute ~]# mkfs.xfs /dev/sdb1
[root@compute ~]# mkfs.xfs /dev/sdb2

7.修改环境变量

[root@controller ~]# cat /etc/xiandian/openrc.sh
cat /etc/xiandian/openrc.sh
##--------------------system Config--------------------##
##Controller Server Manager IP. example:x.x.x.x
HOST_IP=192.168.1.10

##Controller Server hostname. example:controller
HOST_NAME=controller

##Compute Node Manager IP. example:x.x.x.x
HOST_IP_NODE=192.168.1.20

##Compute Node hostname. example:compute
HOST_NAME_NODE=compute

##--------------------Rabbit Config ------------------##
##user for rabbit. example:openstack
RABBIT_USER=openstack

##Password for rabbit user .example:000000
RABBIT_PASS=a

##--------------------MySQL Config---------------------##
##Password for MySQL root user . exmaple:000000
DB_PASS=a

##--------------------Keystone Config------------------##
##Password for Keystore admin user. exmaple:000000
DOMAIN_NAME=lyb
ADMIN_PASS=a
DEMO_PASS=a

##Password for Mysql keystore user. exmaple:000000
KEYSTONE_DBPASS=a

##--------------------Glance Config--------------------##
##Password for Mysql glance user. exmaple:000000
GLANCE_DBPASS=a

##Password for Keystore glance user. exmaple:000000
GLANCE_PASS=a

##--------------------Nova Config----------------------##
##Password for Mysql nova user. exmaple:000000
NOVA_DBPASS=a

##Password for Keystore nova user. exmaple:000000
NOVA_PASS=a

##--------------------Neturon Config-------------------##
##Password for Mysql neutron user. exmaple:000000
NEUTRON_DBPASS=a

##Password for Keystore neutron user. exmaple:000000
NEUTRON_PASS=a

##metadata secret for neutron. exmaple:000000
METADATA_SECRET=a

##External Network Interface. example:eth1
INTERFACE_NAME=eno33554960

##First Vlan ID in VLAN RANGE for VLAN Network. exmaple:101
#minvlan=

##Last Vlan ID in VLAN RANGE for VLAN Network. example:200
#maxvlan=

##--------------------Cinder Config--------------------##
##Password for Mysql cinder user. exmaple:000000
CINDER_DBPASS=a

##Password for Keystore cinder user. exmaple:000000
CINDER_PASS=a

##Cinder Block Disk. example:md126p3
BLOCK_DISK=/dev/sdb1

##--------------------Trove Config--------------------##
##Password for Mysql Trove User. exmaple:000000
TROVE_DBPASS=a

##Password for Keystore Trove User. exmaple:000000
TROVE_PASS=a

##--------------------Swift Config---------------------##
##Password for Keystore swift user. exmaple:000000
SWIFT_PASS=a

##The NODE Object Disk for Swift. example:md126p4.
OBJECT_DISK=/dev/sdb2

##The NODE IP for Swift Storage Network. example:x.x.x.x.
STORAGE_LOCAL_NET_IP=192.168.1.20

##--------------------Heat Config----------------------##
##Password for Mysql heat user. exmaple:000000
HEAT_DBPASS=a

##Password for Keystore heat user. exmaple:000000
HEAT_PASS=a

##--------------------Ceilometer Config----------------##
##Password for Mysql ceilometer user. exmaple:000000
CEILOMETER_DBPASS=a

##Password for Keystore ceilometer user. exmaple:000000
CEILOMETER_PASS=a

##--------------------AODH Config----------------##
##Password for Mysql AODH user. exmaple:000000
AODH_DBPASS=a

##Password for Keystore AODH user. exmaple:000000
AODH_PASS=a

[root@controller ~]# scp /etc/xiandian/openrc.sh root@compute:/etc/xiandian/openrc.sh

8.配置NTP服务

新版本不用更改

9.通过脚本安装服务

控制节点

iaas-pre-host.sh
reboot
iaas-install-mysql.sh
iaas-install-keystone.sh
iaas-install-glance.sh
iaas-install-nova-controller.sh
iaas-install-neutron-controller.sh
iaas-install-dashboard.sh

计算节点
iaas-pre-host.sh
reboot
iaas-install-nova-compute.sh
iaas-install-neutron-compute.sh

10.通过IP访问云平台

http://192.168.1.10/dashboard

11.测试

用虚拟机搭建iaas先电私有云平台_linux


登录会有点卡

用虚拟机搭建iaas先电私有云平台_IPV6_02

12.附录(用xshell连接虚拟机)

怎么用XSHELL连接虚拟机?

统一用桥接模式

1.查看本地wife属型(可以看出本地wife是192.168.1.0网段)

用虚拟机搭建iaas先电私有云平台_linux_03


我拿controller节点举例子

1.设置网卡模式为桥接模式

用虚拟机搭建iaas先电私有云平台_IPV6_04


2.配置IP和wife网段一致

也就是192.168.1.0网段

用虚拟机搭建iaas先电私有云平台_linux_05


3.用xshell进行连接

用虚拟机搭建iaas先电私有云平台_centos_06


4.连接成功

用虚拟机搭建iaas先电私有云平台_IPV6_07

完成啦,记得一键三连哦!


标签:00,compute,##,虚拟机,192.168,先电,controller,iaas,root
From: https://blog.51cto.com/u_14519396/8679896

相关文章

  • VMware 虚拟机的三种网络工作模式
    目录介绍桥接模式桥接模式网络设置NAT模式实际操作中注意事项Host-Only介绍vmware为我们提供了三种网络工作模式,它们分别是:Bridged(桥接模式)、NAT(网络地址转换模式)、Host-Only(仅主机模式)。默认情况下,当安装完VMware虚拟机软件时,进入vmware,在选项栏的"编辑"下的"虚拟网络......
  • Linux虚拟机配置网络之Xshell远程连接
    一、下载远程连接工具Xshell二、使用Xshell远程连接虚拟机1、查看虚拟机ip命令:ipaddr2、打开Xshell软件,点击新建会话   连接成功3、检查网络状态,开启虚拟机输入命令   pingwww.baidu.com......
  • 如何让你的虚拟机连上网和如何让xshell连到虚拟机 连接虚拟机到互联网 创建虚拟机:
    如何让你的虚拟机连上网和如何让xshell连到虚拟机 连接虚拟机到互联网创建虚拟机:首先,使用虚拟化软件(如VirtualBox、VMware或KVM)创建一个虚拟机。确保在虚拟机设置中启用网络适配器,并选择合适的网络连接方式(通常是“桥接”或“NAT”)。启动虚拟机:启动虚拟机,确保虚拟机......
  • 如何解决Hyper-V中的虚拟机出现“无法连接到虚拟机配置存储”的问题
     上图是借用网上其它友友的图片,由于一直未在网上找到解决方案,后来无意中解决了这个问题后,把解决过程在此记录下来,方便有需要的其它友友。 先来说下我出现上述问题的背景:我的电脑有三个硬盘:Disk0,是固态硬盘,不知道历史上什么原因,2个分区的字母分得太开了。这个对于我这种有强......
  • Linux虚拟机如何配置网络之Xshell远程连接
    一、下载远程连接工具Xshell二、使用Xshell远程连接虚拟机1、查看虚拟机ip命令:ipaddr2、打开Xshell软件,点击新建会话   连接成功3、检查网络状态,开启虚拟机输入命令   pingwww.baidu.com ......
  • MAC系统通过vagrant的安装虚拟机
    brewinstallvagrant#使用brew进行安装brewinstallVirtualBox#安装虚拟机vagrant-v#先检查一下是否安装成功初始化项目文件夹mkdirvagrant_getting_startedcdvagrant_getting_startedvagrantinitcentos/7使用centos7初始化一个虚拟机vagrantup启动虚拟......
  • 阿里云IPV6 创建虚拟机的过程
    阿里云IPV6创建虚拟机的过程背景IPV6已经越来越广泛的应用.想在外网开通一下IPV6,发现还有一些坑.这里总结一下.备忘.开通方式1.登录阿里云的控制台,打开云服务器ECS的管理界面打开想要进行IPV6设置的虚拟机.进入实例详情界面点击配置信息里面的->虚拟......
  • 虚拟机安装详解
    虚拟机安装 1.选择虚拟机软件
在安装虚拟机之前,需要选择一款合适的虚拟机软件。目前市面上有很多虚拟机软件供选择,如VMware、VirtualBox等。根据你的需求和操作系统的支持情况,选择合适的虚拟机软件。2.下载操作系统镜像文件
购买虚拟主机空间后,你会得到一个操作系统镜像文件......
  • 物理机ping不通虚拟机
    把虚拟机的防火墙关掉。 前提:将动态ip改为静态ip参考:点击跳转如果虚拟机的系统是windows系统,那么打开网络连接设置:在任务栏右键点击网络图标。选择"打开网络和Internet设置"。在"更改你的网络设置"部分,点击"更改适配器选项"。找到网络连接:在打开的窗口中,......
  • MacOS 开发51单片机【非虚拟机】
    MacOS开发51单片机【非虚拟机】准备工作一、安装brew因为在Mac上是用brew来安装sdcc的,所以我们首先自己装上homebrew,不然等下安装sdcc的命令是错误的。brew是Mac的包管理管理工具,就和redhat的yum和Ubuntu的apt-get一样。homebrew的安装方法/bin/zsh-c"$(cur......