分类 阿里云 下的文章

无法为 FreeBSD 9.3 Release 的 vm-images 打上阿里云的 VirtIO 补丁

问题描述:无法为 FreeBSD 9.3 Release 的 vm-images 打上阿里云的 VirtIO 补丁。因为业务问题,须使用 FreeBSD 9.3 amd64 系统。我先从 http://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/VM-IMAGES/9.3-RELEASE/amd64/Latest/FreeBSD-9.3-RELEASE-amd64-20140711-r268512.vhd.xz 下载系统镜像。再按照 https://help.aliyun.com/zh/ecs/user-guide/the-freebsd-operating-system-compatibility 这里的操作说明,想为内核打上 0001-virtio.patch 的补丁。但在执行 make -j2 buildkernel KERNCONF=GENERIC 这一步时,出错。提示:cc1: warnings being treated as errors . * [virtio_pci.o] Error code 1

阿里云客服回复:实在抱歉,FreeBSD 9.3 这个系统太老了 ,这边尝试多种方法也找不到的virtio驱动,只能建议您更换其他操作系统进行使用了,谢谢

客户反馈腾讯云的可以安装 FreeBSD 9.3 。

用 fdisk -c=dos 来从63开始分区,而不是2048开始

现象:一个阿里云的数据盘需要从原40GB扩容到60GB,系统是CentOS7。照阿里云文档中的例子操作,创建新分区后,e2fsck检查文件系统错误,Bad magic number in super-block,磁盘扩容失败。

尝试:对比阿里云文档中的例子,原分区的起始位置是63,不是例子中的2048。但默认fdisk的分区是4k对齐的,并不能从63开始,至少是2048。搜索结果中,有人说用参数 -c=dos 来运行fdisk,就可以从63开始分区,保留原分区的数据进行扩容了。

# fdisk -u /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.


Command (m for help): p

Disk /dev/vdb: 64.4 GB, 64424509440 bytes, 125829120 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: 0x4ca57d7e

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1              63    83885759    41942848+  83  Linux

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-125829119, default 2048): 63
Value out of range.
First sector (2048-125829119, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-125829119, default 125829119):
Using default value 125829119
Partition 1 of type Linux and of size 60 GiB is set

# e2fsck -n /dev/vdb1
e2fsck 1.42.9 (28-Dec-2013)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/vdb1

The superblock could not be read or does not describe a correct ext2
filesystem.  If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>

fdisk -c=dos /dev/vdb

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (with command 'c').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.


Command (m for help): p

Disk /dev/vdb: 64.4 GB, 64424509440 bytes, 125829120 sectors
16 heads, 63 sectors/track, 124830 cylinders
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: 0x4ca57d7e

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1              63    83885759    41942848+  83  Linux

Command (m for help): d
Selected partition 1
Partition 1 is deleted

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 (63-125829119, default 63):
Using default value 63
Last sector, +sectors or +size{K,M,G} (63-125829119, default 125829119):
Using default value 125829119
Partition 1 of type Linux and of size 60 GiB is set

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

参考:

通过命令行参数发送阿里云短信 - python

阿里云的“消息服务”产品文档中,提供了python的演示例子。简单替换例子文件中的 REGION 等参数就可以运行,成功发出手机短信了。但每次发送不同内容的短信,大概流程是:打开文件,替换短信内容,保存文件,运行python文件,发出短信。如果短信内容中是固定的几个变量,能否通过参数传入到命令行发送呢?

如果您还没有订购阿里云的产品,可点此链接查看优惠价格喔

过程:

1.修改 demo_sms_send.py 文件内容,在前边添加以下参数设定:

vserver_ip = sys.argv[1]
vserver_expire_time = sys.argv[2]
vclient_phone = sys.argv[3]

ali-sms-python-1.png

2.将设定的参数填写到发送语句中,如:

params = {"server_ip":vserver_ip,"server_expire_time":vserver_expire_time}
print(send_sms(__business_id, vclient_phone, "安群", "SMS_152505789", params))

ali-sms-python-2.png

3.在命令行中,执行如 python demo_sms_send.py 8.8.8.8 2019-08-29 13800138000 来发短信
ali-sms-python-3.png

参考:

在WDCP v3里设置站点通过IP和端口访问

环境:wdCP v3.3.6
目的:新建一个站点,且用IP加端口访问

本例使用阿里云ECS实例测试,如您还没有,可点击此查看相关优惠活动

过程:

1.先在“系统设置”中的“WEB”中添加“Web端口”
wdcp-port-1.png

2.保存设置后,发现apache启动失败。日志中提示:Starting httpd: AH00526: Syntax error on line 1 of /www/wdlinux/httpd-2.4.38/conf/vhost/port.conf
wdcp-port-2.png

3.查看apache配置端口的文件内容,将原来带分号的端口(Listen 80;8081;8082)替换成如下边的:

Listen 8081
Listen 8082

wdcp-port-3.png

4.再在站点的配置文件里,将端口修改为非80的,如8082
wdcp-port-4.png

5.保存后访问测试,成功

参考:https://httpd.apache.org/docs/2.4/bind.html

通过命令行安装magento2

测试机:阿里云ECS实例。如果您还没有ECS,可点此查看优惠价格或订购

如果还没有布置好magento2的运行环境,请参考上一篇。

过程:

1.cd /var/www/html # 假如magento2的文件存放在 /var/www/html

2.php bin/magento setup:install --base-url=http://szt.anqun.org/ \
--db-host=localhost --db-name=magento --db-user=root --db-password= \
--admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com \
--admin-user=admin --admin-password=admin123 --language=en_US \
--currency=USD --timezone=America/Chicago --use-rewrites=1 # 安装命令,其中 base-url 是商城网址,db-name是数据库名,db-user是数据库用户,db-password是密码,admin-user是商城后台管理员登录名,admin-password是商城后台管理员密码
magento-cli-install-1.png

3.如果安装成功,会回显随机生成商城后台登录目录,如/admin_1ma81y
magento-cli-install-2.png

4.chown -R apache:apche /var/www/html # 将magento2所在的目录递归更改属主为web进程用户,如apache

5.成功登录到新站点后台
magento-cli-install-3.png

参考:https://devdocs.magento.com/guides/v2.3/install-gde/install/cli/install-cli-install.html