企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
#redhat7.2改变yum源为阿里云 ## 一、 改变yum源 ###1. 卸载redhat的yum程序 ``` rpm -qa | grep yum rpm -qa | grep yum|xargs rpm -e --nodeps rpm -qa | grep python-urlgrabber|xargs rpm -e --nodeps ``` ###2. 下载aliyun中的centos的yum相关程序 ####1) 上传wget的rpm包并安装 略`[wget-1.12-10.el6.x86_64.rpm]` ####2) 然后下载相关安装包 ``` wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-45.el7.noarch.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm ``` ###3. 安装pathon扩展和yum包 ``` rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm \ yum-3.4.3-158.el7.centos.noarch.rpm \ yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm \ yum-utils-1.1.31-45.el7.noarch.rpm --nodeps ``` 至此修改yum源完成,可直接用yum在线安装 ###4. 备份并新增yum源 ``` mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo sed -i 's#\$releasever#7#g' /etc/yum.repos.d/CentOS-Base.repo ``` ##二、 开启rpm包缓存(如果需要) ###1. 开启缓存 ``` mkdir -p /server/tools sed -i 's#^cachedir.*#cachedir=/server/tools#g' /etc/yum.conf sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf ``` ###2. 安装软件(以nginx为例) `yum install nginx -y` 安装之前,最好对虚拟机做快照,每次安装新软件之前,都恢复快照后用干净的系统进行缓存 ###3. 打包安装包 相关包缓存路径 /server/tools下,将里面的所有rpm包转移到一个目录下,然后重命名,再用tar打包(注明软件名.系统版本,软件版本),便于在其他环境离线安装 ###4. 离线安装方法 ``` tar xf xxx.tar.gz cd xxx yum localinstall *或主文件名[如: nginx-1.12.2-2.el7.x86_64.rpm] localinstall是进行yum本地安装,会解决依赖关系(前提是安装包中有该依赖包的离线文件) ```