字體:  

解決 AWS yum出現Errno 14 HTTP Error 401: Authorization Required 的問題

cuteftp 發表於: 2018-1-31 10:18 來源: ADJ網路控股集團


最近使用 snapshot 生成一台 EC2 後,發現yum 都會出現錯誤無法安裝套件,找了很多問件...才終於知道問題出在那~

問題說明:

QUOTE:


root@ip-**.**.**.** ~# yum install htop
Loaded plugins: amazon-id, fastestmirror, product-id, rhui-lb, security
Loading mirror speeds from cached hostfile
* epel: mirror.itc.virginia.edu
* rhui-us-east-1-client-config-server-5: rhui2-cds01.us-east-1.aws.ce.redhat.com
* rhui-us-east-1-rhel-server: rhui2-cds01.us-east-1.aws.ce.redhat.com
epel | 3.6 kB 00:00
https://rhui2-cds01.us-east-1.aws.ce.redhat.com/pulp/repos//rhui-client-config/rhel/server/5/x86_64/os/repodata/repomd.xml: Errno 14 HTTP Error 401: Authorization Required
Trying other mirror.
https://rhui2-cds02.us-east-1.aws.ce.redhat.com/pulp/repos//rhui-client-config/rhel/server/5/x86_64/os/repodata/repomd.xml: Errno 14 HTTP Error 401: Authorization Required
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: rhui-us-east-1-client-config-server-5. Please verify its path and try again

root@ip-**.**.**.** ~# curl http://169.254.169.254/latest/dynamic/instance-identity/document
{
"instanceId" : "i-ac64a0cf",
"billingProducts" : null,
"version" : "2010-08-31",
"region" : "us-east-1",
"accountId" : "****",
"imageId" : "ami-7cdba915",
"kernelId" : null,
"ramdiskId" : null,
"architecture" : "x86_64",
"pendingTime" : "2013-07-02T16:42:56Z",
"instanceType" : "m1.medium",
"availabilityZone" : "us-east-1b",
"devpayProductCodes" : null,
"privateIp" : "**.**.**.**"


如果 billingProducts 出現 null,就代表這個 EC2 Broken

This is a known issue when you create AMI from snapshot of a Redhat instance volume, the reason is that in this process the "billingProducts" is set to null.

兩種解法如下:
To workaround the issue please try one of these two options:

1- From the modified instance ( if you still have it ) create an AMI directly.

2- If the only source that you have is the snapshot then take these steps:

- Launch a new instance from a good RHEL AMI, stop and detach the root EBS volume.

- Stop the broken instance, detach all EBS volumes and attach to the new instance and restart ( remembering to associate the broken instance's EIP if applicable )

- Alternatively you could snap-shot the broken instance's EBS volumes, and attach volumes created from these snapshots to the new instance.

最簡單的解法就是選第一種: 重新在 EC2 create AMI,再從新建一台EC2 就沒問題了~


參考官方說明:
https://forums.aws.amazon.com/thread.jspa?threadID=128658