AnolisOS 私有YUM源部署
介绍
CentOS7 将于24年停止维护,AnolisOS成为国内迁移的的优先选项之一。此篇是基于 AnolisOS8.8 系统的私有源部署教程
1. 安装源管理工具
$ yum install yum-utils
2. 下载官方源到本地
$ reposync -np /data/repos/anolis/x86_64/8
3. 生成RPM包索引数据
3.1 安装创建索引工具
$ yum install -y createrepo
3.2 生成包索引
$ createrepo --update /data/repos/anolis/x86_64/8/AppStream
$ createrepo --update /data/repos/anolis/x86_64/8/BaseOS
$ createrepo --update /data/repos/anolis/x86_64/8/Extras
$ createrepo --update /data/repos/anolis/x86_64/8/PowerTools
4. 部署Web站点对外提供服务
4.1 安装nginx
$ yum install nginx -y
4.2 编辑nginx配置文件
$ vim /etc/nginx/conf.d/detalut.conf
server {
listen 80;
server_name repo.yum.d;
root /data/repos/; #这里是yum源存放目录
location / {
autoindex on; #打开目录浏览功能
autoindex_exact_size off; # off:以可读的方式显示文件大小
autoindex_localtime on; # on、off:是否以服务器的文件时间作为显示的时间
charset utf-8,gbk; #展示中文文件名
index index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
4.3 启动nginx,开机自启
$ systemctl start nginx
$ systemctl enable nginx
5. 客户机配置本地源
5.1 备份默认源
$ mv /etc/yum.repos.d /etc/yum.repos.d_bak
$ mkdir /etc/yum.repos.d
5.2 配置私有源
$ vim /etc/yum.repos.d/AnolisOS-8.repo
[AppStream]
name=AnolisOS8 - AppStream
baseurl=http://私有源IP/anolis/x86_64/8/AppStream
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ANOLIS
gpgcheck=1
[BaseOS]
name=AnolisOS8 - BaseOS
baseurl=http://私有源IP/anolis/x86_64/8/BaseOS
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ANOLIS
gpgcheck=1
[Extras]
name=AnolisOS8 - Extras
baseurl=http://私有源IP/anolis/x86_64/8/Extras
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ANOLIS
gpgcheck=1
[PowerTools]
name=AnolisOS8 - PowerTools
baseurl=http://私有源IP/anolis/x86_64/8/PowerTools
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ANOLIS
gpgcheck=1
5.3 清理缓存,建立私有源缓存
$ yum clean all && yum makecache
# 检查仓库是否启用
$ yum repolist all
6. 定时更新私有源
6.1 新建源同步脚本
$ vim /data/shell/repos/repos_update.sh
#!/bin/bash
# 本地源文件路径
repo_path=/data/repos/anolis/x86_64/8
# 同步的源类型
repos=(AppStream BaseOS Extras PowerTools)
for repo in $repos
do
cd $repo_path/$repo
rm -f index.html
wget https://mirrors.openanolis.cn/anolis/8.8/$repo/x86_64/os/Packages/
cd Packages
for rpm in `cat ../index.html |awk -F'"' '{if($2~/.*.rpm/) print $2}'`
do
wget -nc https://mirrors.openanolis.cn/anolis//8.8/$repo/x86_64/os/Packages/$rpm
done
createrepo --update /data/repos/anolis/x86_64/8/$repo
done
6.2 授权
$ chmod 755 /data/shell/repos/repos_update.sh
6.3 设置定时任务
# 添加自动任务
$ crontab -e
# 每周六凌晨一点更新私有源
0 1 * * 6 root /bin/bash /data/shell/repos/repos_update.sh
版权声明:
本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
运维小记!
喜欢就支持一下吧
打赏
微信
支付宝