likes
comments
collection
share

【部署篇】基于腾讯云虚拟机 Allinone 部署 Cloudpods 搭建多云管理平台

作者站长头像
站长
· 阅读数 4

参考的文档:www.cloudpods.org/zh/docs/qui…

第一步 创建腾讯云的虚拟机

镜像:CentOS 7.9 64位 大小:8核16GB 系统盘:通用型SSD云硬盘 50GB 数据盘:通用型SSD云硬盘 500GB 安全组:入站放通22、80、443

详细配置如下图所示:

【部署篇】基于腾讯云虚拟机 Allinone 部署 Cloudpods 搭建多云管理平台

第二步 登录机器,配置数据盘

根据官方文档建议,把数据盘做 ext4 然后通过 /etc/fstab 挂载到 /opt 目录。

1.格式化数据盘磁盘

[root@VM-0-4-centos ~]# fdisk -l

Disk /dev/vda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x0009ac89

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048   104857566    52427759+  83  Linux

Disk /dev/vdb: 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@VM-0-4-centos ~]# mkfs.ext4 /dev/vdb
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

2.挂载到 /opt

[root@VM-0-4-centos ~]# mount /dev/vdb /opt

3.修改 /etc/fstab 文件,添加挂载记录

[root@VM-0-4-centos ~]# blkid
/dev/sr0: UUID="2023-07-09-14-54-29-00" LABEL="config-2" TYPE="iso9660" 
/dev/vda1: UUID="4b499d76-769a-40a0-93dc-4a31a59add28" TYPE="ext4" 
/dev/vdb: UUID="73db74fe-f616-48c1-9fd4-9b35264a4e1b" TYPE="ext4"
[root@VM-0-4-centos ~]# vim /etc/fstab 
[root@VM-0-4-centos ~]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Thu Mar  7 06:38:37 2019
#
# 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=4b499d76-769a-40a0-93dc-4a31a59add28 /                       ext4    defaults        1 1
UUID=73db74fe-f616-48c1-9fd4-9b35264a4e1b /opt                    ext4    defaults        0 0
[root@VM-0-4-centos ~]# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sr0     11:0    1 203.6M  0 rom  
vda    253:0    0    50G  0 disk 
└─vda1 253:1    0    50G  0 part /
vdb    253:16   0   100G  0 disk /opt

4.重启机器

[root@VM-0-4-centos ~]# reboot

[root@VM-0-4-centos ~]# mount -a

5.确认磁盘挂载情况

[root@VM-0-4-centos ~]# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sr0     11:0    1 203.6M  0 rom  
vda    253:0    0    50G  0 disk 
└─vda1 253:1    0    50G  0 part /
vdb    253:16   0   100G  0 disk /opt
[root@VM-0-4-centos ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        7.6G     0  7.6G   0% /dev
tmpfs           7.6G   24K  7.6G   1% /dev/shm
tmpfs           7.6G  568K  7.6G   1% /run
tmpfs           7.6G     0  7.6G   0% /sys/fs/cgroup
/dev/vda1        50G  2.4G   45G   5% /
/dev/vdb         99G   61M   94G   1% /opt
tmpfs           1.6G     0  1.6G   0% /run/user/0

第三步 配置 SSH 免密登录

[root@VM-0-4-centos ~]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:OtmWeyy8GFTFyWnTHeSAad1G13CSraMStMpnczEjUEc root@VM-0-4-centos
The key's randomart image is:
+---[RSA 2048]----+
|         +oOE=*=+|
|        ..%.oo=+o|
|        .= o ... |
|       .  + + o  |
|      ..S. o = . |
|     . +o.= o    |
|      =.++ +     |
|       =o.o      |
|      . o+       |
+----[SHA256]-----+
[root@VM-0-4-centos ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.19.0.4  netmask 255.255.240.0  broadcast 172.19.15.255
        inet6 fe80::5054:ff:fe67:226e  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:67:22:6e  txqueuelen 1000  (Ethernet)
        RX packets 4972  bytes 5899287 (5.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1715  bytes 194140 (189.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 10  bytes 1360 (1.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 1360 (1.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@VM-0-4-centos ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@172.19.0.4
# 这种方式需要提供 root 密码,也可以使用以下命令,避免提供 root 密码。
# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# chmod 600 ~/.ssh/authorized_keys
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '172.19.0.4 (172.19.0.4)' can't be established.
ECDSA key fingerprint is SHA256:Fkzm7UjC43rVsMZwYYSG+97Bih7QNGVw4Bhz3nfjgvs.
ECDSA key fingerprint is MD5:22:61:5e:9d:9c:5b:42:e4:81:05:3b:9d:d2:78:6e:23.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@172.19.0.4's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@172.19.0.4'"
and check to make sure that only the key(s) you wanted were added.

第四步 安装 ansible 和 git

[root@VM-0-4-centos ~]# yum install -y epel-release git python3-pip
[root@VM-0-4-centos ~]# python3 -m pip install --upgrade pip setuptools wheel
[root@VM-0-4-centos ~]# python3 -m pip install --upgrade ansible

第五步 下载 ocboot 工具

[root@VM-0-4-centos ~]# git clone -b release/3.10 https://github.com/yunionio/ocboot && cd ./ocboot

第六步 快速部署

1.执行脚本安装

[root@VM-0-4-centos ocboot]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.19.0.4  netmask 255.255.240.0  broadcast 172.19.15.255
        inet6 fe80::5054:ff:fe67:226e  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:67:22:6e  txqueuelen 1000  (Ethernet)
        RX packets 58415  bytes 68132158 (64.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 22819  bytes 8228214 (7.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@VM-0-4-centos ocboot]# pwd
/root/ocboot
[root@VM-0-4-centos ocboot]# ./run.py 172.19.0.4
# 特别巧的一件事情是,这次开的腾讯云的虚拟机的IP居然和Azure那台机器的内网IP是一样的。

2.部署完成

在执行过程中,拉取镜像环节有报错,详细解决方法请见文末的拉 ocadm 镜像失败。

大约四十分钟左右,部署完成,并且系统自动重启了。

第七步 登录系统

因为我创建虚拟机的时候,就选择了放通 22、80、443 端口,所以可以直接访问,这一点注意一下,否则可能因为安全规则导致访问不了。

按照文档提示获取登录了登录信息。 web地址:https://43.133.58.89 (公有云上只能通过公网IP访问) 用户名:admin 用户密码:admin@123

【部署篇】基于腾讯云虚拟机 Allinone 部署 Cloudpods 搭建多云管理平台

输入用户名和密码后,顺利进入系统。

可以正常访问页面,不过有提示,我登录系统之后,根据系统的提示,把内网IP设置成了公网IP,提示消失。

【部署篇】基于腾讯云虚拟机 Allinone 部署 Cloudpods 搭建多云管理平台

第八步 配置阿里云云账号信息以及对现有资源进行操作验证

根据文档提示,获取到我自己的阿里云账号的 Access Key Id 和 Access Key Secret 然后填入表单,完成创建。

【部署篇】基于腾讯云虚拟机 Allinone 部署 Cloudpods 搭建多云管理平台

这次等的时间比较长,可能因为机器在海外,连国内的公有云比较慢? 然后同样做了一下机器的开关机的测试,同步查看了一下阿里云控制台的状态,符合预期。

总结

整体安装部署的时间差不多花了5个多小时,可能因为之前部署过一次,熟练了。