赞
踩
【摘要】 什么是弹性云服务器ECS?ECS的产品架构是什么?它有哪些优势和有应用场景?弹性云服务器ECS的使用流程是怎样的?如何运用弹性云服务器ECS搭建微信公众号后台并收发文本消息?让我们带着这些疑问,去弹性云服务器ECS的世界里一探究竟,玩转ECS!!
















(A)使用 CloudShell 登录云服务器

(B)使用 PuTTY 工具登录 ECS

(A)使用 fdisk 分区工具初始化数据盘
划分分区并挂载磁盘
fdisk -l
- [root@ecs-test-0001 ~]# fdisk -l
-
- Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 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: 0x000bcb4e
-
- Device Boot Start End Blocks Id System
- /dev/vda1 * 2048 83886079 41942016 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

- fdisk 新增数据盘
-
- // 以新挂载的数据盘“/dev/vdb”为例:
- fdisk /dev/vdb
- [root@ecs-test-0001 ~]# fdisk /dev/vdb
- 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 0x38717fc1.
-
- Command (m for help):
- // 表示磁盘有两种分区类型:p 表示主分区,e 表示扩展分区
- Command (m for help): n
- Partition type:
- p primary (0 primary, 0 extended, 4 free)
- e extended
- // Partition number 表示主分区编号,可以选择 1-4
- Select (default p): p
- Partition number (1-4, default 1):
- // First sector 表示起始磁柱值,可以选择 2048-209715199,默认为 2048
- Partition number (1-4, default 1): 1
- First sector (2048-209715199, default 2048):
- // Last sector 表示截止磁柱值,可以选择 2048-209715199,默认为209715199
- First sector (2048-209715199, default 2048):
- Using default value 2048
- Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
- // 表示分区完成,即为数据盘新建 1 个分区
- Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
- Using default value 209715199
- Partition 1 of type Linux and of size 100 GiB is set
-
- Command (m for help):
- Command (m for help): p
-
- 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
- Disk label type: dos
- Disk identifier: 0x38717fc1
-
- Device Boot Start End Blocks Id System
- /dev/vdb1 2048 209715199 104856576 83 Linux
-
- Command (m for help):
- Command (m for help): w
- The partition table has been altered!
-
- Calling ioctl() to re-read partition table.
- Syncing disks.
partprobe
- mkfs -t 文件系统格式 /dev/vdb1
- // 以设置文件系统为“ext4”为例:
- mkfs -t ext4 /dev/vdb1
- [root@ecs-test-0001 ~]# mkfs -t ext4 /dev/vdb1
- 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, 26214144 blocks
- 1310707 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

- mkdir 挂载目录
- // 以新建挂载目录“/mnt/sdc”为例:
- mkdir /mnt/sdc
- mount 磁盘分区 挂载目录
- // 以挂载新建分区“/dev/vdb1”至“/mnt/sdc”为例:
- mount /dev/vdb1 /mnt/sdc
- df -TH
-
- [root@ecs-test-0001 ~]# df -TH
- Filesystem Type Size Used Avail Use% Mounted on
- /dev/vda1 ext4 43G 1.9G 39G 5% /
- devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev
- tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
- tmpfs tmpfs 2.0G 9.1M 2.0G 1% /run
- tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
- tmpfs tmpfs 398M 0 398M 0% /run/user/0
- /dev/vdb1 ext4 106G 63M 101G 1% /mnt/sdc
设置开机自动挂载磁盘分区
- blkid 磁盘分区
- // 以查询磁盘分区 “/dev/vdb1” 的 UUID 为例:
- blkid /dev/vdb1
- [root@ecs-test-0001 ~]# blkid /dev/vdb1
- /dev/vdb1: UUID="0b3040e2-1367-4abb-841d-ddb0b92693df" TYPE="ext4"
vi /etc/fstab
UUID=0b3040e2-1367-4abb-841d-ddb0b92693df /mnt/sdc ext4 defaults 0 2
- umount 磁盘分区
- // 命令示例
- umount /dev/vdb1
mount -a
- mount | grep 挂载目录
- // 命令示例
- mount | grep /mnt/sdc
- root@ecs-test-0001 ~]# mount | grep /mnt/sdc
- /dev/vdb1 on /mnt/sdc type ext4 (rw,relatime,data=ordered)
(B)使用脚本初始化新挂载的磁盘
wget https://ecs-instance-driver.obs.cn-north-1.myhuaweicloud.com/datadisk/LinuxVMDataDiskAutoInitialize.sh
chmod +x LinuxVMDataDiskAutoInitialize.sh
./LinuxVMDataDiskAutoInitialize.sh




(C)使用脚本初始化已使用的磁盘
wget https://ecs-instance-driver.obs.cn-north-1.myhuaweicloud.com/datadisk/LinuxVMDataDiskAutoInitialize.sh
chmod -x LinuxVMDataDiskAutoInitialize.sh
sh LinuxVMDataDiskAutoInitialize.sh







(A)升级默认 Python 版本
python --version

wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0a1.tar.xz

tar xvf Python-3.6.0a1.tar.xz
- cd Python-3.6.0a1
- ./configure

sudo yum install gcc-c++
- # -*- coding: utf-8 -*-
- # filename: main.py
- import web
- from handle import Handle
-
- urls = (
- '/wx', 'Handle',
- )
-
- if __name__ == '__main__':
- app = web.application(urls, globals())
- app.run()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。