linux下git安装编译时踩到的坑

问题起因

linux服务器内安装git工具包,下载git-2.28.0.tar.xz并解压成文件夹。

编译git

sudo make prefix=/usr/local/git all

出现以下问题-No.1

make: curl-config: Command not found
    CC http.o
In file included from http.c:2:
http.h:6:10: fatal error: curl/curl.h: No such file or directory
 #include <curl/curl.h>
          ^~~~~~~~~~~~~
compilation terminated.
make: *** [http.o] Error 1

问题分析:curl环境不够完整

解决方案:下载依赖包

sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib=devel perl-ExtUtils-MakeMaker

出现以下问题-No.2

Error Downloading Packages:
  libidn-devel-1.18-2.el6.x86_64: failure: Packages/libidn-devel-1.18-2.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.
  libcurl-7.19.7-54.el6_10.x86_64: failure: Packages/libcurl-7.19.7-54.el6_10.x86_64.rpm from updates: [Errno 256] No more mirrors to try.
  openssl-static-1.0.1e-58.el6_10.x86_64: failure: Packages/openssl-static-1.0.1e-58.el6_10.x86_64.rpm from updates: [Errno 256] No more mirrors to try.
  openssl-1.0.1e-58.el6_10.x86_64: failure: Packages/openssl-1.0.1e-58.el6_10.x86_64.rpm from updates: [Errno 256] No more mirrors to try.
  openssl-devel-1.0.1e-58.el6_10.x86_64: failure: Packages/openssl-devel-1.0.1e-58.el6_10.x86_64.rpm from updates: [Errno 256] No more mirrors to try.
  libcurl-devel-7.19.7-54.el6_10.x86_64: failure: Packages/libcurl-devel-7.19.7-54.el6_10.x86_64.rpm from updates: [Errno 256] No more mirrors to try.
  curl-7.19.7-54.el6_10.x86_64: failure: Packages/curl-7.19.7-54.el6_10.x86_64.rpm from updates: [Errno 256] No more mirrors to try.
  expat-devel-2.0.1-13.el6_8.x86_64: failure: Packages/expat-devel-2.0.1-13.el6_8.x86_64.rpm from base: [Errno 256] No more mirrors to try.

问题分析:yum下载资源失败

解决方案:检查服务器网络是否正常访问公网

ping baidu.com
PING baidu.com (39.156.66.10) 56(84) bytes of data.
64 bytes from 39.156.66.10: icmp_seq=1 ttl=42 time=5.79 ms
64 bytes from 39.156.66.10: icmp_seq=2 ttl=42 time=5.52 ms
64 bytes from 39.156.66.10: icmp_seq=3 ttl=42 time=5.50 ms
64 bytes from 39.156.66.10: icmp_seq=4 ttl=42 time=5.48 ms
64 bytes from 39.156.66.10: icmp_seq=5 ttl=42 time=5.47 ms

清理yum缓存

yum clean all

Loaded plugins: fastestmirror
Cleaning repos: base docker-ce-stable epel erlang-solutions extras mongodb-org-4.0 updates
Cleaning up Everything
Cleaning up list of fastest mirrors

创建新的缓存

yum makecache

Loaded plugins: fastestmirror
Determining fastest mirrors
 * epel: mirrors.aliyun.com
http://mirrors.163.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
To address this issue please refer to the below knowledge base article 

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.

Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again

问题原因:缺少repomd.xml文件-No.3

解决方案:把这个文件给它补上

cd /etc/yum.repos.d
vim CentOS-Base.repo

把这个文件的内容修改成下面这个样子

[base]
name=CentOS-$releasever - Base - 163.com
baseurl=http://mirrors.cloud.aliyuncs.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-7 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/7/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/7/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/7/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#contrib - packages by Centos Users
[contrib]
name=CentOS-7 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/7/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/7/contrib/$basearch/

验证是否解决

yum makecache

出现以下问题

http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirrors.cloud.aliyuncs.com'"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again

问题原因:mirrors.cloud.aliyuncs.com这个域名访问失败-No.4

解决方案:修改DNS

vim/etc/resolv.conf

nameserver 8.8.8.8
nameserver 114.114.114.114

问题没有解决

尝试更换新的repo文件

wget https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo
wget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo

替换域名

sed -i 's/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g'  /etc/yum.repos.d/Centos-vault-8.5.2111.repo 
sed -i 's/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g'  /etc/yum.repos.d/epel-archive-8.repo

清理并重建缓存

yum clean all && yum makecache

问题3+问题4解决,回到问题2

sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib=devel perl-ExtUtils-MakeMaker

新问题:

Error: xz compression not available

问题分析:xz压缩不可用

尝试通过重新安装epel来解决,问题依然存在

rm -rf /var/cache/yum/x86_64/6Server/epel/
rpm -ivh epel-release-6-8.noarch.rpm
wget -O/etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
wget -O /etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-6.repo

尝试重装pyliblzma

sudo dnf reinstall pyliblzma包来解决问题
sudo: dnf: command not found

没有dnf用rpm来安装

sudo wget http://rpmfind.net/linux/centos/7.9.2009/os/x86_64/Packages/pyliblzma-0.5.3-11.el7.x86_64.rpm
sudo rpm -ivh pyliblzma-0.5.3-11.el7.x86_64.rpm --nodeps --force
warning: pyliblzma-0.5.3-11.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                ########################################### [100%]
   1:pyliblzma              ########################################### [100%]

问题依然存在,只能重新安装yum了。。。

时间关系,不详细展示命令了,请看相关参考资料:
http://www.manongjc.com/detail/28-rvjlfqgimoapiro.html

~一个小时后:

重新安装的过程发现问题根源:

1、yum默认关联的是Python2,但是Python在服务器上有两版,一个Python2一个Python3
https://www.cnblogs.com/phpzhou/p/9675099.html
2、yum源要正确更换,yum源要切记centOS6系统不能配置成centOS7的源
可以参考https://blog.csdn.net/Coin_Collecter/article/details/130071493更换yum源

现在回到问题2

sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib=devel perl-ExtUtils-MakeMaker

Error:  Multilib version problems found. This often means that the root
       cause is something else and multilib version checking is just
       pointing out that there is a problem. Eg.:
       
         1. You have an upgrade for nss which is missing some
            dependency that another package requires. Yum is trying to
            solve this by installing an older version of nss of the
            different architecture. If you exclude the bad architecture
            yum will tell you what the root cause is (which package
            requires what). You can try redoing the upgrade with
            --exclude nss.otherarch ... this should give you an error
            message showing the root cause of the problem.
       
         2. You have multiple architectures of nss installed, but
            yum can only see an upgrade for one of those arcitectures.
            If you don't want/need both architectures anymore then you
            can remove the one with the missing update and everything
            will work.
       
         3. You have duplicate versions of nss installed already.
            You can use "yum check" to get yum show these errors.
       
       ...you can also use --setopt=protected_multilib=false to remove
       this checking, however this is almost never the correct thing to
       do as something else is very likely to go wrong (often causing
       much more problems).
       
       Protected multilib versions: nss-3.27.1-13.el6.i686 != nss-3.28.4-4.el6_9.x86_64
Error: Protected multilib versions: nss-util-3.27.1-3.el6.i686 != nss-util-3.28.4-1.el6_9.x86_64
Error: Protected multilib versions: libcurl-7.19.7-52.el6.i686 != libcurl-7.19.7-53.el6_9.x86_64

这次还好,报错完全跟上面不一样了,上面都是找不到资源之类的问题,现在集中在Multilib version problems found这个问题上

问题分析:这里面提示multilib版本有冲突

sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib=devel perl-ExtUtils-MakeMaker --setopt=protected_multilib=false
Error Downloading Packages:
  openssl-1.0.1e-57.el6.i686: failure: Packages/openssl-1.0.1e-57.el6.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  readline-6.0-4.el6.i686: failure: Packages/readline-6.0-4.el6.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  krb5-libs-1.10.3-65.el6.i686: failure: Packages/krb5-libs-1.10.3-65.el6.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  libidn-1.18-2.el6.i686: failure: Packages/libidn-1.18-2.el6.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  libssh2-1.4.2-2.el6_7.1.i686: failure: Packages/libssh2-1.4.2-2.el6_7.1.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  db4-4.7.25-22.el6.i686: failure: Packages/db4-4.7.25-22.el6.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  nss-3.27.1-13.el6.i686: failure: Packages/nss-3.27.1-13.el6.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  nspr-4.13.1-1.el6.i686: failure: Packages/nspr-4.13.1-1.el6.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  nss-softokn-3.14.3-23.3.el6_8.i686: failure: Packages/nss-softokn-3.14.3-23.3.el6_8.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  libcom_err-1.41.12-23.el6.i686: failure: Packages/libcom_err-1.41.12-23.el6.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  cyrus-sasl-lib-2.1.23-15.el6_6.2.i686: failure: Packages/cyrus-sasl-lib-2.1.23-15.el6_6.2.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  sqlite-3.6.20-1.el6_7.2.i686: failure: Packages/sqlite-3.6.20-1.el6_7.2.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  openldap-2.4.40-16.el6.i686: failure: Packages/openldap-2.4.40-16.el6.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  libcurl-7.19.7-52.el6.i686: failure: Packages/libcurl-7.19.7-52.el6.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  nss-util-3.27.1-3.el6.i686: failure: Packages/nss-util-3.27.1-3.el6.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  libselinux-2.0.94-7.el6.i686: failure: Packages/libselinux-2.0.94-7.el6.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  ncurses-libs-5.7-4.20090207.el6.i686: failure: Packages/ncurses-libs-5.7-4.20090207.el6.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.
  keyutils-libs-1.4-5.el6.i686: failure: Packages/keyutils-libs-1.4-5.el6.i686.rpm from CentOS6.9: [Errno 256] No more mirrors to try.

好家伙这么多资源都找不到。。。这个只能一个一个安装了,因为不知道哪个包带来的

sudo yum install curl-devel --setopt=protected_multilib=false

就是它

经过与专业运维沟通,centOS6的rpm资源已经不维护了,如果404了只能手动找安装包,安全性难以保障。没有办法最后只能重装Linux系统了。重装的系统里面自带了git。so,f**k

结论与收获

1、yum,rpm,dnf
2、centos6和7
3、yum源的设置
4、curl

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,686评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,668评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,160评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,736评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,847评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,043评论 1 291
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,129评论 3 410
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,872评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,318评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,645评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,777评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,470评论 4 333
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,126评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,861评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,095评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,589评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,687评论 2 351

推荐阅读更多精彩内容