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

1,170 阅读7分钟

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

第一步 创建 Azure 的虚拟机

镜像:CentOS-based 7.6 - Gen1
大小:Standard_A8_v2 - 8 vcpu、16 GiB 内存
选择入站端口:22,80,443
数据盘:512 GiB 标准 SSD LRS

详细配置如下图所示

image.png

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

登录机器报错 warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory,请查看文末解决办法。这个问题不解决,后续安装 ansible 也会报错,github.com/yunionio/cl…

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

1.创建分区

[root@cloudpods ~]# fdisk -l
Disk /dev/sdb: 85.9 GB, 85899345920 bytes, 167772160 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x1875287f
Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   167770111    83884032   83  Linux
Disk /dev/sdc: 549.8 GB, 549755813888 bytes, 1073741824 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 /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x000c35bb
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    62914559    30944256   83  Linux
[root@cloudpods ~]# fdsik /dev/sdc
-bash: fdsik: command not found
[root@cloudpods ~]# fdisk /dev/sdc
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 0xea36b899.
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-1073741823, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-1073741823, default 1073741823): 
Using default value 1073741823
Partition 1 of type Linux and of size 512 GiB is set
Command (m for help): p
Disk /dev/sdc: 549.8 GB, 549755813888 bytes, 1073741824 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: 0xea36b899
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048  1073741823   536869888   83  Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@cloudpods ~]# mkfs.ext4 /dev/sdc1
mke2fs 1.42.9 (28-Dec-2013)
Discarding device blocks: done                            
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
33554432 inodes, 134217472 blocks
6710873 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2281701376
4096 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, 71663616, 78675968, 
102400000
Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

2.挂载到 /opt

[root@cloudpods ~]# mount /dev/sdc1 /opt

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

image.png

4.重启机器

[root@cloudpods ~]# reboot

5.确认磁盘挂载情况

[root@cloudpods ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        30G  1.3G   29G   5% /
devtmpfs        7.9G     0  7.9G   0% /dev
tmpfs           7.9G     0  7.9G   0% /dev/shm
tmpfs           7.9G  9.0M  7.9G   1% /run
tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/sda1       497M   65M  433M  13% /boot
/dev/sdc1       504G   73M  479G   1% /opt
/dev/sdb1        79G   57M   75G   1% /mnt/resource
tmpfs           1.6G     0  1.6G   0% /run/user/1000

第三步 配置 ssh 免密登录

注意:allinone 也需要配置,否则会导致后续安装报错 Failed to connect to the host via ssh ,详细可查看 github.com/yunionio/cl…

1.Azure 虚拟机不知道 root 密码,我就直接设置了一下密码

[root@cloudpods ~]# passwd
Changing password for user root.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

2.配置免密登录

[root@cloudpods ~]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
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:F4YeOZ6uYcAEbX2M/HGoDJN3ua/JQqIZEmnZS3CLoP0 root@cloudpods
The key's randomart image is:
+---[RSA 2048]----+
|  .. + o o       |
|.. o* = Bo.      |
|oo*.o= ==+o      |
|++.*  ooo= .     |
|....+   S..      |
|. ..E... ..      |
| . + oo..o       |
|  o  ..o+        |
|      ..         |
+----[SHA256]-----+
[root@cloudpods ~]# ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.19.0.4  netmask 255.255.255.0  broadcast 172.19.0.255
        inet6 fe80::217:faff:fe01:c132  prefixlen 64  scopeid 0x20<link>
        ether 00:17:fa:01:c1:32  txqueuelen 1000  (Ethernet)
        RX packets 2335  bytes 538158 (525.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2725  bytes 729588 (712.4 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 32  bytes 2592 (2.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 32  bytes 2592 (2.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@cloudpods ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@172.19.0.4
/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:YP/RyujaVD6qUXygR47qlVl7nB607AL9H20WHfUVxSs.
ECDSA key fingerprint is MD5:ca:d4:e1:7f:d7:56:f3:de:75:6e:a5:c2:1b:6a:b2:68.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
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

安装 ansible 报 UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 117 请见文末解决办法。

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

第五步 下载 ocboot 工具

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

第六步 快速部署

1.执行脚本安装

[root@cloudpods ocboot]# ./run.py 172.19.0.4

2.部署完成

部署完成后,系统自动重启了。

第七步 登录系统

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

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

image.png

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

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

image.png

第八步 配置阿里云云账号信息以及对现有资源

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

image.png

差不多等了 5 分钟左右的时间,看到了一些资源数据。然后这虚拟机做了一下开关机的测试,也对比了一下阿里云控制台的状态信息,还可以。

image.png

总结

整体安装部署差不多花了 6 个多小时,中间遇到了几个问题,还好在网上和 cloudpods 的 github issue 里面找了解决方式。

其他 安装过程中的问题解决

登录机器报错 warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

参考文档:www.jianshu.com/p/3afd1c622…
解决办法:

[root@cloudpods ~]# echo "LC_ALL=en_US.UTF-8" >> /etc/environment
[root@cloudpods ~]# echo "LANG=en_US.UTF-8" >> /etc/environment