日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

阿里云 yum无法正常使用的解决办法 (转)

發布時間:2025/7/14 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 阿里云 yum无法正常使用的解决办法 (转) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
阿里云 yum無法正常使用的解決辦法?

最近公司剛剛購買了一臺阿里云的RHEL5.4的云主機,

但是在使用過程中發現yum 安裝很多軟件都無法使用,

最后找到很簡單的官方的解決辦法:

?

解決了什么問題:一鍵式更新yum源,省去了復雜的命令和步驟

注:所有執行的腳本都需要root身份來執行,執行方法:以root身執行命令:bash?xxx.sh

功能:更新系統的yum源為163的yum源 適用系統版本:線上centos5/6系列,redhat5系列,兼容32位和64位

執行方法:以root身執行命令,bash update_yum_source.sh

博客不能上傳文件,就把代碼粘貼到下面吧。


#!/bin/bash
#########################################
#Function: ? ?update yum source
#Usage: ? ? ? bash update_yum_source.sh
#Author: ? ? ?Customer service department
#Company: ? ? Alibaba Cloud Computing
#Version: ? ? 2.1
#########################################
check_os_release()
{
? while true
? do
? os_release=$(grep "Red Hat Enterprise Linux Server release" /etc/issue 2>/dev/null)
? os_release_2=$(grep "Red Hat Enterprise Linux Server release" /etc/redhat-release 2>/dev/null)
? if [ "$os_release" ] && [ "$os_release_2" ]
? then
? ? echo "$os_release"
? ? break
? fi
? os_release=$(grep "CentOS release" /etc/issue 2>/dev/null)
? os_release_2=$(grep "CentOS release" /etc/*release 2>/dev/null)
? if [ "$os_release" ] && [ "$os_release_2" ]
? then
? ? echo "$os_release"
? ? break
? fi
? break
? done
}


modify_rhel5_yum()
{
? rpm --import http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
? cd /etc/yum.repos.d/
? wget http://mirrors.163.com/.help/CentOS-Base-163.repo -O CentOS-Base-163.repo
? sed -i '/mirrorlist/d' CentOS-Base-163.repo
? sed -i 's/\$releasever/5/' CentOS-Base-163.repo
? yum clean metadata
? yum makecache
? cd ~
}


modify_rhel6_yum()
{
? rpm --import http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6
? cd /etc/yum.repos.d/
? wget http://mirrors.163.com/.help/CentOS-Base-163.repo -O CentOS-Base-163.repo
? sed -i '/mirrorlist/d' CentOS-Base-163.repo
? sed -i '/\[addons\]/,/^$/d' CentOS-Base-163.repo
? sed -i 's/\$releasever/6/' CentOS-Base-163.repo
? sed -i 's/RPM-GPG-KEY-CentOS-5/RPM-GPG-KEY-CentOS-6/' CentOS-Base-163.repo
? yum clean metadata
? yum makecache
? cd ~
}


##########start######################
#check lock file ,one time only let the script run one time?
LOCKfile=/tmp/.$(basename $0)
if [ -f "$LOCKfile" ]
then
? echo -e "\033[1;40;31mThe script is already exist,please next time to run this script.\n\033[0m"
? exit
else
? echo -e "\033[40;32mStep 1.No lock file,begin to create lock file and continue.\n\033[40;37m"
? touch $LOCKfile
fi


#check user
if [ $(id -u) != "0" ]
then
? echo -e "\033[1;40;31mError: You must be root to run this script, please use root to install this script.\n\033[0m"
? rm -rf $LOCKfile
? exit 1
fi


os_type=$(check_os_release)
if [ "X$os_type" == "X" ]
then
? echo -e "\033[1;40;31mOS type is not RedHat or CentOS,So this script is not executede.\n\033[0m"
? rm -rf $LOCKfile
? exit 0
else
? echo -e "\033[40;32mThis OS is $os_type.\033[40;37m"
? echo "$os_type" |grep 5 >/dev/null
? if [ $? -eq 0 ]
? then
? ? modify_rhel5_yum
? ? rm -rf $LOCKfile
? ? exit 0
? fi
? echo "$os_type"|grep 6 >/dev/null
? if [ $? -eq 0 ]
? then
? ? modify_rhel6_yum
? ? rm -rf $LOCKfile
? ? exit 0
? fi
fi
rm -rf $LOCKfile

轉載于:https://www.cnblogs.com/xiaosheng-aquarius/p/3467473.html

總結

以上是生活随笔為你收集整理的阿里云 yum无法正常使用的解决办法 (转)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。