我阿里云的系统是Alibaba Cloud Linux 2.1903 LTS 64位,它是基于Centos7开发的,所以理论上能够安装支持Centos7的软件。
但是却隐含了一个大坑原因:Alibaba Cloud Linux系统的releasever变量是“2.1903”,而不是Centos7的“7”,这导致了安装识别的系统版本不对,造成失败。
所以解决方案很简单,将rpm安装包下载,强制安装,随后将对应yum.repos.d文件中的$releasever替换成数字7即可。1.下载rpm包
wget <下载地址>
2.强制安装
rpm -ivh --force --nodeps
3.修改对应的repos文件
sudo vim /etc/yum.repos.d/<安装后的repo文件>
4.使用vim全局替换命令将$releasever替换掉
先按下:(冒号)进入命令输入模式,随后输入%s/$releasever/7/g
随后保存退出,即可正常安装! 同理,如果是基于Centos8的Alibaba Cloud Linux,将数字更改为8替换即可。实战记录:
本来想给阿里云安装一个PostgreSQL13数据库,到其官网查看文档,安装方法如下:
# Install the repository RPM: sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm # Install PostgreSQL: sudo yum install -y postgresql13-server
然后在第一步安装rpm时报错
Loaded plugins: fastestmirror, langpacks, releasever-adapter, update-motd pgdg-redhat-repo-latest.noarch.rpm | 8.1 kB 00:00:00 Examining /var/tmp/yum-root-X8AgRw/pgdg-redhat-repo-latest.noarch.rpm: pgdg-redhat-repo-42.0-23.noarch /var/tmp/yum-root-X8AgRw/pgdg-redhat-repo-latest.noarch.rpm: does not update installed package. Error: Nothing to do
随后下载rpm
wget https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
强制安装rpm
rpm -ivh --force --nodeps pgdg-redhat-repo-latest.noarch.rpm
再运行安装,失败:
failure: repodata/repomd.xml from pgdg-common: [Errno 256] No more mirrors to try. https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-2.1903-x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
于是修改刚才安装的repo文件
sudo vim /etc/yum.repos.d/pgdg-redhat-all.repo
执行替换,保存退出
%s/$releasever/7/g
再次安装
sudo yum install -y postgresql13-server一切正常!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)