阿里云CentOS 6 EOL如何切换源:https://help.aliyun.com/document_detail/193569.htm
阿里云在线扩容云盘(Linux系统):https://help.aliyun.com/document_detail/113316.html
扩展地内核版本实例的系统盘分区和文件系统:https://help.aliyun.com/document_detail/111738.html?spm=a2c4g.11186623.2.23.3dd46fb4L0bw6r#section-vxq-3tw-dhb
CentOS 6操作系统版本结束了生命周期(EOL),Linux社区已不再维护该操作系统版本。建议您升级操作系统至CentOS 7及以上,如果您的业务过渡期仍需要使用CentOS 6系统中的一些安装包,请根据下文切换CentOS 6的源。
背景信息
2020年11月30日CentOS 6 EOL。按照社区规则,CentOS 6的源地址http://mirror.centos.org/centos-6/内容已移除,目前第三方的镜像站中均已移除CentOS 6的源。阿里云的源http://mirrors.cloud.aliyuncs.com和http://mirrors.aliyun.com也无法同步到CentOS 6的源。当您在阿里云上继续使用默认配置的CentOS 6的源会发生报错。报错示例如下图所示:
您可以通过下文的操作步骤,在CentOS 6操作系统的ECS实例中将源配置按照网络环境不同进行切换。
- yum源
-
- 专有网络VPC类型实例需切换为http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/源。
- 经典网络类型实例需切换为http://mirrors.aliyuncs.com/centos-vault/6.10/源。
- epel源
-
- 专有网络VPC类型实例需切换为http://mirrors.cloud.aliyuncs.com/epel-archive/6/源。
- 经典网络类型实例需切换为http://mirrors.aliyuncs.com/epel-archive/6/源。
说明 本文主要说明ECS实例中的相关操作与配置。如果您的服务器不是ECS实例,需保证服务器具有公网访问能力,并且源地址http://mirrors.cloud.aliyuncs.com需要替换为http://mirrors.aliyun.com。例如,切换yum源为http://mirrors.aliyun.com/centos-vault/6.10/;切换epel源为http://mirrors.aliyun.com/epel-archive/6/。
操作步骤
- 登录CentOS 6系统的ECS实例。
具体操作,请参见连接方式概述。
- 运行以下命令编辑CentOS-Base.repo 文件。
vim /etc/yum.repos.d/CentOS-Base.repo
- 按i进入编辑模式,修改以下内容切换源。
请根据实例不同的网络类型进行修改,具体内容如下:
-
专有网络VPC类型实例
[base]
name=CentOS-6.10
enabled=1
failovermethod=priority
baseurl=http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.cloud.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6
[updates]
name=CentOS-6.10
enabled=1
failovermethod=priority
baseurl=http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.cloud.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6
[extras]
name=CentOS-6.10
enabled=1
failovermethod=priority
baseurl=http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.cloud.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6
-
经典网络类型实例
[base]
name=CentOS-6.10
enabled=1
failovermethod=priority
baseurl=http://mirrors.aliyuncs.com/centos-vault/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6
[updates]
name=CentOS-6.10
enabled=1
failovermethod=priority
baseurl=http://mirrors.aliyuncs.com/centos-vault/6.10/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyuncs.comm/centos-vault/RPM-GPG-KEY-CentOS-6
[extras]
name=CentOS-6.10
enabled=1
failovermethod=priority
baseurl=http://mirrors.aliyuncs.com/centos-vault/6.10/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6
编辑完成后,按Esc键,并输入:wq保存退出文件。
- 运行以下命令编辑epel.repo 文件。
vim /etc/yum.repos.d/epel.repo
- 按i进入编辑模式,修改以下内容切换源。
请根据实例不同的网络类型进行修改,具体内容如下:
-
专有网络VPC类型实例
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
enabled=1
failovermethod=priority
baseurl=http://mirrors.cloud.aliyuncs.com/epel-archive/6/$basearch
gpgcheck=0
gpgkey=http://mirrors.cloud.aliyuncs.com/epel-archive/RPM-GPG-KEY-EPEL-6
-
经典网络类型实例
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
enabled=1
failovermethod=priority
baseurl=http://mirrors.aliyuncs.com/epel-archive/6/$basearch
gpgcheck=0
gpgkey=http://mirrors.aliyuncs.com/epel-archive/RPM-GPG-KEY-EPEL-6
编辑完成后,按Esc键,并输入:wq保存退出文件。
- 切换完成后,您可以使用yum install命令安装需要的软件包。
云盘扩容:https://help.aliyun.com/document_detail/113316.html
扩展低内核版本实例的系统盘分区和文件系统:https://help.aliyun.com/document_detail/111738.html?spm=a2c4g.11186623.2.23.3dd46fb4L0bw6r#section-vxq-3tw-dhb
本节以CentOS 6操作系统为例,说明扩展分区和文件系统的步骤。
- 运行以下命令安装dracut-modules-growroot工具。
yum install -y dracut-modules-growroot
说明 如果您使用的是其他软件包管理器,请将yum修改为对应的命令。
- 运行以下命令覆盖已有的initramfs文件。
dracut -f
- 运行以下命令查看现有云盘大小。
fdisk -l
以下示例返回云盘(/dev/vda1)容量是100GiB。
[root@ecshost ~]# fdisk -l
Disk /dev/vda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003a7b4
Device Boot Start End Blocks Id System
/dev/vda1 * 1 2611 20970496 83 Linux
- 运行以下命令查看云盘分区大小和文件系统类型。
df -Th
以下示例返回分区(/dev/vda1)容量是20 GiB,文件系统类型为ext4。
[root@ecshost ~]# df -h
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 20G 1.1G 18G 6% /
tmpfs tmpfs 7.8G 0 7.8G 0% /dev/shm
- 运行以下命令扩容分区。
growpart <DeviceName> <PartionNumber>
示例命令表示扩容系统盘的第一个分区(/dev/vda1)。
[root@ecshost ~]# growpart /dev/vda 1
CHANGED: partition=1 start=2048 old: size=41940992 end=41943040 new: size=209710462,end=209712510
- 在控制台重启实例。
注意 只能通过控制台重启实例或者调用API RebootInstance重启实例,扩容操作才能生效。具体操作,请参见重启实例和RebootInstance。
- 再次远程连接实例。
- 扩展文件系统。
根据文件系统类型选择以下扩展方式,您可以通过运行df -h如何查看文件系统类型。
- ext*文件系统(例如ext3和ext4):运行以下命令扩展文件系统。
resize2fs <PartitionName>
示例命令表示为扩容系统盘的/dev/vda1分区的文件系统。
[root@ecshost ~]# resize2fs /dev/vda1
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 7
Performing an on-line resize of /dev/vda1 to 26213807 (4k) blocks.
The filesystem on /dev/vda1 is now 26213807 blocks long.
- xfs文件系统:运行以下命令扩展文件系统。
xfs_growfs <mountpoint>
示例命令表示为扩容系统盘的/dev/vda1分区的文件系统。其中根目录(/)为/dev/vda1的挂载点。
[root@ecshost ~]# xfs_growfs /
说明 不同版本的xfs_growfs命令可能存在差异,请运行xfs_growfs --help查看对应的命令。
- 运行以下命令查看云盘分区大小。
df -h
以下示例返回分区(/dev/vda1)容量是100GiB,表示已经成功扩容。
[root@ecshost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 99G 1.1G 93G 2% /
tmpfs 7.8G 0 7.8G 0% /dev/shm