Centos 7 部署YUM仓库
Centos 7
Centos 7 局域网部署 YUM 源仓库
1. 关闭 SELinux
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
Bash
2. 配置 DNS
echo nameserver 8.8.4.4 >> /etc/resolv.conf
echo nameserver 8.8.8.8 >> /etc/resolv.conf
echo nameserver 1.1.1.1 >> /etc/resolv.conf
echo nameserver 223.5.5.5 >> /etc/resolv.conf
echo nameserver 223.6.6.6 >> /etc/resolv.conf
Bash
3. 配置源
rm -rf /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
curl -o /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
rpm --import http://pkg.jenkins-ci.org/redhat-stable/jenkins-ci.org.key
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install -y epel-release
Bash
4. 安装 createrepo
yum -y install createrepo
yum -y install yum-utils
Bash
5. 创建目录
mkdir /YUM
Bash
6. 安装 Apache
yum -y install httpd
Bash
7. 配置仓库路径
ln -s /YUM /var/www/html/Centos
Bash
8. 启动 vsftpd
systemctl start httpd
systemctl enable httpd
Bash
9. 配置防火墙
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --reload
Bash
10. 配置 repo
(
cat <<EOF
[base]
name=Local YUM base
baseurl=http://192.168.65.253/Centos/base
gpgcheck=0
enabled=1
[epel]
name=Local YUM epel
baseurl=http://192.168.65.253/Centos/epel
gpgcheck=0
enabled=1
[extras]
name=Local YUM extras
baseurl=http://192.168.65.253/Centos/extras
gpgcheck=0
enabled=1
[updates]
name=Local YUM updates
baseurl=http://192.168.65.253/Centos/updates
gpgcheck=0
enabled=1
[jenkins]
name=Local YUM jenkins
baseurl=http://192.168.65.253/Centos/jenkins
gpgcheck=0
enabled=1
[webtatic]
name=Local YUM webtatic
baseurl=http://192.168.65.253/Centos/webtatic
gpgcheck=0
enabled=1
EOF
) > /YUM/CentOS7.repo
Bash
11. 同步源
cd /YUM
reposync -n -d -r extras
reposync -n -d -r updates
reposync -n -d -r base
reposync -n -d -r epel
reposync -n -d -r jenkins
reposync -n -d -r webtatic
Bash
12. 创建 repo 库
mkdir /YUM/base/repodata/
mkdir /YUM/epel/repodata/
mkdir /YUM/extras/repodata/
mkdir /YUM/updates/repodata/
mkdir /YUM/jenkins/repodata/
mkdir /YUM/webtatic/repodata/
yum clean all
yum makecache
/bin/cp -f /var/cache/yum/x86_64/7/base/*.* /YUM/base/repodata/
/bin/cp -f /var/cache/yum/x86_64/7/epel/*.* /YUM/epel/repodata/
/bin/cp -f /var/cache/yum/x86_64/7/extras/*.* /YUM/extras/repodata/
/bin/cp -f /var/cache/yum/x86_64/7/updates/*.* /YUM/updates/repodata/
/bin/cp -f /var/cache/yum/x86_64/7/jenkins/*.* /YUM/jenkins/repodata/
/bin/cp -f /var/cache/yum/x86_64/7/webtatic/*.* /YUM/webtatic/repodata/
Bash
13. 下载 rpm 包及依赖到 packages
yumdownloader -y --resolve --destdir=/YUM/packages nginx mariadb-server mariadb php56w php56w-mysql php56w-gd php56w-imap php56w-ldap php56w-odbc php56w-pear php56w-xml php56w-xmlrpc php56w-mbstring php56w-mcrypt php56w-bcmath php56w-mhash php56w-fpm php56w-opcache jenkins zlib zlib-devel libffi-devel openssl-devel glibc make binutils gcc libaio bc flex bash-completion httpd subversion mod_dav_svn java autoconf automake curl gcc git libmnl-devel libuuid-devel lm_sensors make MySQL-python nc pkgconfig python python-psycopg2 PyYAML zlib-devel '@Development Tools'
Bash
14. 创建 repo
createrepo -v /YUM/packages
Bash