{"id":4438,"date":"2015-07-01T17:57:08","date_gmt":"2015-07-01T09:57:08","guid":{"rendered":"https:\/\/www.hmouse.tk\/?p=4438"},"modified":"2015-07-22T11:27:23","modified_gmt":"2015-07-22T03:27:23","slug":"%e7%a7%81%e6%9c%89yum%e6%ba%90%e7%9a%84%e5%ae%89%e8%a3%85","status":"publish","type":"post","link":"https:\/\/www.hmouse.cn\/?p=4438","title":{"rendered":"\u79c1\u6709yum\u6e90\u7684\u5b89\u88c5"},"content":{"rendered":"<p>\u540c\u6b65\u7cfb\u7edf\u6e90\u7684\u811a\u672c\u3002<\/p>\n<p>\u53c2\u8003url:<a title=\"http:\/\/www.nowo.com\/create_private_yum_repo\/\" href=\"http:\/\/www.nowo.com\/create_private_yum_repo\/\">http:\/\/www.nowo.com\/create_private_yum_repo\/<\/a><\/p>\n<p>\u63a8\u8350\u4f7f\u7528\u79d1\u5927\u7684\u6e90<\/p>\n<p>\u540c\u6b65\u811a\u672c\u5728\u540e\u9762\uff0c<\/p>\n<p>1\uff1a\u540c\u6b65\u6e90\u5230\u672c\u5730\u673a\u5668<\/p>\n<p>2\uff1a\u5b89\u88c5\u8f6f\u4ef6<\/p>\n<p><code>yum install createrepo<\/code><br \/><code>yum install http<\/code><\/p>\n<p><code>3\uff1a\u521b\u5efa\u79c1\u6709\u6e90<\/code><\/p>\n<p>\u5728 web \u76ee\u5f55\u4e0b\u521b\u5efa\u76f8\u5e94\u7684\u8def\u5f84\uff0c\u5e76\u4e14\u5c06 rpm \u5305\u7f6e\u5165\u5176\u4e2d\uff0c\u5e76\u521b\u5efa\u6e90\u7684 rpm \u5305\u7d22\u5f15\u4fe1\u606f\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6bcf\u6b21\u589e\u52a0\u65b0\u7684 rpm \u5305\uff0c\u90fd\u9700\u8981\u4f7f\u7528 createrepo \u547d\u4ee4\u6765\u66f4\u65b0\u4e00\u6b21\u7d22\u5f15\u4fe1\u606f\u3002  <\/p>\n<p><code>mkdir -p centos\/6\/x86_64<\/code>  <\/p>\n<p><code>cp ~\/*.rpm centos\/6\/x86_64\/<\/code>  <\/p>\n<p><code>createrepo -p -d -o centos\/6\/x86_64 centos\/6\/x86_64<\/code>  <\/p>\n<p><code>\u4ece\u79d1\u5927copy\u8fc7\u6765\u7684\u5f88\u591a\u7d22\u5f15\u4fe1\u606f\u90fd\u6709\u4e86\uff0c\u76f4\u63a5\u53ef\u4ee5\u7528\uff0c\u5982\u679c\u4ee5\u540e\u6ca1\u6709\u8fd9\u4e2a\uff0c\u6216\u8005\u81ea\u5efa\u7684\u8bdd \u5c31\u9700\u8981\u521b\u5efa\u7d22\u5f15\u4fe1\u606f\u3002<\/code>  <\/p>\n<p><code>4\uff1a\u8bbe\u7f6e\u5ba2\u6237\u7aef<\/code>  <\/p>\n<p><code><\/code>&nbsp; <\/p>\n<p>[root@localhost 6]# cat \/etc\/yum.repos.d\/CentOS-Base.repo <br \/># CentOS-Base.repo<br \/>#<br \/># The mirror system uses the connecting IP address of the client and the<br \/># update status of each mirror to pick mirrors that are updated to and<br \/># geographically close to the client.&nbsp; You should use this for CentOS updates<br \/># unless you are manually picking other mirrors.<br \/>#<br \/># If the mirrorlist= does not work for you, as a fall back you can try the <br \/># remarked out baseurl= line instead.<br \/>#<br \/>#  <\/p>\n<p>[base]<br \/>name=CentOS-$releasever &#8211; Base<br \/>mirrorlist=<a href=\"http:\/\/mirrorlist.centos.org\/?release=\">http:\/\/mirrorlist.centos.org\/?release=<\/a>$releasever&amp;arch=$basearch&amp;repo=os<br \/>#baseurl=<a href=\"http:\/\/mirror.centos.org\/centos\/\">http:\/\/mirror.centos.org\/centos\/<\/a>$releasever\/os\/$basearch\/<br \/>gpgcheck=1<br \/>gpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-CentOS-6  <\/p>\n<p>#released updates <br \/>[updates]<br \/>name=CentOS-$releasever &#8211; Updates<br \/>mirrorlist=<a href=\"http:\/\/mirrorlist.centos.org\/?release=\">http:\/\/mirrorlist.centos.org\/?release=<\/a>$releasever&amp;arch=$basearch&amp;repo=updates<br \/>#baseurl=<a href=\"http:\/\/mirror.centos.org\/centos\/\">http:\/\/mirror.centos.org\/centos\/<\/a>$releasever\/updates\/$basearch\/<br \/>gpgcheck=1<br \/>gpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-CentOS-6  <\/p>\n<p>#additional packages that may be useful<br \/>[extras]<br \/>name=CentOS-$releasever &#8211; Extras<br \/>mirrorlist=<a href=\"http:\/\/mirrorlist.centos.org\/?release=\">http:\/\/mirrorlist.centos.org\/?release=<\/a>$releasever&amp;arch=$basearch&amp;repo=extras<br \/>#baseurl=<a href=\"http:\/\/mirror.centos.org\/centos\/\">http:\/\/mirror.centos.org\/centos\/<\/a>$releasever\/extras\/$basearch\/<br \/>gpgcheck=1<br \/>gpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-CentOS-6  <\/p>\n<p>#additional packages that extend functionality of existing packages<br \/>[centosplus]<br \/>name=CentOS-$releasever &#8211; Plus<br \/>mirrorlist=<a href=\"http:\/\/mirrorlist.centos.org\/?release=\">http:\/\/mirrorlist.centos.org\/?release=<\/a>$releasever&amp;arch=$basearch&amp;repo=centosplus<br \/>#baseurl=<a href=\"http:\/\/mirror.centos.org\/centos\/\">http:\/\/mirror.centos.org\/centos\/<\/a>$releasever\/centosplus\/$basearch\/<br \/>gpgcheck=1<br \/>enabled=0<br \/>gpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-CentOS-6  <\/p>\n<p>#contrib &#8211; packages by Centos Users<br \/>[contrib]<br \/>name=CentOS-$releasever &#8211; Contrib<br \/>mirrorlist=<a href=\"http:\/\/mirrorlist.centos.org\/?release=\">http:\/\/mirrorlist.centos.org\/?release=<\/a>$releasever&amp;arch=$basearch&amp;repo=contrib<br \/>#baseurl=<a href=\"http:\/\/mirror.centos.org\/centos\/\">http:\/\/mirror.centos.org\/centos\/<\/a>$releasever\/contrib\/$basearch\/<br \/>gpgcheck=1<br \/>enabled=0<br \/>gpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-CentOS-6  <\/p>\n<p>&nbsp;<\/p>\n<p>\u7136\u540e\u5c31\u4eab\u53d7\u5185\u7f51\u7684\u66f4\u65b0\uff0c\u901f\u5ea6\u4e0e\u6fc0\u60c5\u5427\uff01\uff01\uff01<\/p>\n<p>&nbsp;<\/p>\n<p>\u540c\u6b65\u811a\u672c\u5982\u4e0b\uff1a<\/p>\n<p>&nbsp;<\/p>\n<p>[root@localhost 6]# cat \/root\/shell\/rsync.sh <br \/>#!\/bin\/bash  <\/p>\n<p># base value<br \/># \u8981\u540c\u6b65\u7684\u6e90<br \/>YUM_SITE=&#8221;rsync:\/\/mirrors.ustc.edu.cn\/centos\/&#8221;<br \/>YUM_SITE2=&#8221;rsync:\/\/mirrors.ustc.edu.cn\/epel\/&#8221;<br \/># \u672c\u5730\u5b58\u653e\u76ee\u5f55<br \/>LOCAL_PATH=&#8221;\/home\/share\/yum\/centos\/&#8221;<br \/>LOCAL_PATH2=&#8221;\/home\/share\/yum\/epel\/&#8221;<br \/># \u9700\u8981\u540c\u6b65\u7684\u7248\u672c\uff0c\u6211\u53ea\u9700\u89815\u548c6\u7248\u672c\u8fd8\u67097\u7684\uff0c\u603b\u5171\u5728120G\u5de6\u53f3\uff0c\u4e0d\u5305\u62eciso\u4f1a\u5c11\u70b9<br \/>LOCAL_VER=&#8221;5 5* 6 6*&#8221;<br \/># \u540c\u6b65\u65f6\u8981\u9650\u5236\u7684\u5e26\u5bbd<br \/>BW_limit=20480<br \/># \u8bb0\u5f55\u672c\u811a\u672c\u8fdb\u7a0b\u53f7<br \/>LOCK_FILE=&#8221;\/var\/log\/yum_server.pid&#8221;<br \/># \u540c\u6b65\u65e5\u5fd7\u6587\u4ef6<br \/>LogFile=\/root\/rsyumlog\/`date +&#8221;%Y-%m-%d&#8221;`.log<br \/># \u5982\u7528\u7cfb\u7edf\u9ed8\u8ba4rsync\u5de5\u5177\u4e3a\u7a7a\u5373\u53ef\u3002<br \/># \u5982\u7528\u81ea\u5df1\u5b89\u88c5\u7684rsync\u5de5\u5177\u76f4\u63a5\u586b\u5199\u5b8c\u6574\u8def\u5f84<br \/>RSYNC_PATH=&#8221;\/usr\/bin\/rsync&#8221;<br \/># check update yum server&nbsp; pid<br \/>MY_PID=$$<br \/>if [ -f $LOCK_FILE ]; then<br \/>&nbsp;&nbsp;&nbsp; get_pid=`\/bin\/cat $LOCK_FILE`<br \/>&nbsp;&nbsp;&nbsp; get_system_pid=`\/bin\/ps -ef|grep -v grep|grep $get_pid|wc -l`<br \/>&nbsp;&nbsp;&nbsp; if [ $get_system_pid -eq 0 ] ; then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $MY_PID&gt;$LOCK_FILE<br \/>&nbsp;&nbsp;&nbsp; else<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &#8220;Have update yum server now!&#8221;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit 1<br \/>&nbsp;&nbsp;&nbsp; fi<br \/>else<br \/>&nbsp;&nbsp;&nbsp; echo $MY_PID&gt;$LOCK_FILE<br \/>fi<br \/># check rsync tool<br \/>if [ -z $RSYNC_PATH ]; then<br \/>&nbsp;&nbsp;&nbsp; RSYNC_PATH=`\/usr\/bin\/whereis rsync|awk &#8216; &#8221;{print $2}&#8217;`<br \/>&nbsp;&nbsp;&nbsp; if [ -z $RSYNC_PATH ]; then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &#8216;Not find rsync tool.&#8217;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &#8216;use comm: yum install -y rsync&#8217;<br \/>&nbsp;&nbsp;&nbsp; fi<br \/>fi<br \/># sync yum source<br \/>echo &#8220;rsync start at $(date +&#8221;%Y-%m-%d %H:%M:%S&#8221;)&#8221; &gt;$LogFile<br \/>echo &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#8221; &gt;&gt;$LogFile<br \/>for VER in $LOCAL_VER;<br \/>do<br \/>&nbsp;&nbsp;&nbsp; # Check whether there are local directory<br \/>&nbsp;&nbsp;&nbsp; if [ ! -d &#8220;$LOCAL_PATH$VER&#8221; ] ; then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &#8220;Create dir $LOCAL_PATH$VER&#8221;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; `\/bin\/mkdir -p $LOCAL_PATH$VER`<br \/>&nbsp;&nbsp;&nbsp; fi<br \/>&nbsp; if [ ! -d &#8220;$LOCAL_PATH2$VER&#8221; ] ; then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &#8220;Create dir $LOCAL_PATH2$VER&#8221;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; `\/bin\/mkdir -p $LOCAL_PATH2$VER`<br \/>&nbsp;&nbsp;&nbsp; fi<br \/>&nbsp;&nbsp;&nbsp; # sync yum source<br \/>&nbsp;&nbsp;&nbsp;&nbsp; echo &#8220;Start sync $LOCAL_PATH$VER&#8221;&nbsp; &gt;&gt;$LogFile<br \/>&nbsp;&nbsp;&nbsp;&nbsp; echo &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#8221; &gt;&gt;$LogFile <br \/>&nbsp;&nbsp;&nbsp; $RSYNC_PATH -avrtH &#8211;exclude-from=\/root\/shell\/exclude.list &#8211;delete &#8211;bwlimit=$BW_limit&nbsp; $YUM_SITE$VER $LOCAL_PATH&nbsp; &gt;&gt;$LogFile<br \/>&nbsp;&nbsp;&nbsp; $RSYNC_PATH -avrtH &#8211;exclude-from=\/root\/shell\/exclude.list &#8211;delete &#8211;bwlimit=$BW_limit&nbsp; $YUM_SITE2$VER $LOCAL_PATH2&nbsp; &gt;&gt;$LogFile<br \/>done<br \/>echo &#8220;rsync end at $(date +&#8221;%Y-%m-%d %H:%M:%S&#8221;)&#8221; &gt;&gt;$LogFile<br \/>echo &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#8221; &gt;&gt;$LogFile <br \/>done<br \/># clean lock file<br \/>`\/bin\/rm -rf $LOCK_FILE`<br \/>echo &#8216;sync end.&#8217;<br \/>exit 1<\/p>\n<p>&nbsp;<\/p>\n<p>#########<\/p>\n<p>\u540e\u7eed\u6dfb\u52a0gitlab-ce\u7684\u79c1\u6709\u6e90\u7684\u505a\u6cd5<\/p>\n<p>\u540c\u6b65\u811a\u672c\uff1a<\/p>\n<p>[root@localhost el]# cat \/root\/shell\/get_gitlab.sh <br \/>version=$(yum provides gitlab-ce | tail -n 10 | grep omnibus | awk &#8216;{print $1}&#8217;)<br \/>version_old=$(cat \/root\/shell\/old.txt)<br \/>if [ $version != $version_old ]<br \/>then<br \/>cd \/home\/share\/yum\/gitlab-ce\/el\/6\/x86_64  <\/p>\n<p>wget -O $version.rpm <a href=\"https:\/\/packages.gitlab.com\/gitlab\/gitlab-ce\/packages\/el\/7\/\">https:\/\/packages.gitlab.com\/gitlab\/gitlab-ce\/packages\/el\/7\/<\/a>$version.rpm\/download <br \/>echo $version &gt; \/root\/shell\/old.txt<br \/>createrepo -p -d .\/<br \/>fi  <\/p>\n<p>\u6e90\u7684\u5199\u6cd5\uff1a<\/p>\n<p>[root@imooc yum.repos.d]# cat gitlab_gitlab-ce.repo <br \/>[gitlab_gitlab-ce]<br \/>name=gitlab_gitlab-ce<br \/>baseurl=<a href=\"http:\/\/192.168.9.171:10086\/yum\/gitlab-ce\/el\/6\/\">http:\/\/192.168.9.171:10086\/yum\/gitlab-ce\/el\/6\/<\/a>$basearch <\/p>\n<p>repo_gpgcheck=1<br \/>gpgcheck=0<br \/>enabled=1<br \/><font color=\"#ff0000\">gpgkey=https:\/\/packages.gitlab.com\/gpg.key<\/font><\/p>\n<p>\u7ea2\u8272\u5b57\u4f53\u5fc5\u987b\u6dfb\u52a0\uff0c\u5426\u5219\u4f1a\u9a8c\u8bc1\u65e0\u6cd5\u5b89\u88c5\uff0c\u7c7b\u4f3c\u6821\u9a8c\u662f\u5426\u5b98\u7f51\u7684rpm\u5305\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u6b65\u7cfb\u7edf\u6e90\u7684\u811a\u672c\u3002<\/p>\n<p>\u53c2\u8003url:<a title=\"http:\/\/www.nowo.com\/create_private_yum_repo\/\" href=\"http:\/\/www.nowo.com\/create_private_yum_repo\/\">http:\/\/www.nowo.com\/create_private_yum_repo\/<\/a><\/p>\n<p>\u63a8\u8350\u4f7f\u7528\u79d1\u5927\u7684\u6e90<\/p>\n<p>\u540c\u6b65\u811a\u672c\u5728\u540e\u9762\uff0c<\/p>\n<p>1\uff1a\u540c\u6b65\u6e90\u5230\u672c\u5730\u673a\u5668<\/p>\n<p>2\uff1a\u5b89\u88c5\u8f6f\u4ef6<\/p>\n<p><code>yum install createrepo<\/code><br \/><code>yum install http<\/code><\/p>\n<p><code>3\uff1a\u521b\u5efa\u79c1\u6709\u6e90<\/code><\/p>\n<p>\u5728 web \u76ee\u5f55\u4e0b\u521b\u5efa\u76f8\u5e94\u7684\u8def\u5f84\uff0c\u5e76\u4e14\u5c06 rpm \u5305\u7f6e\u5165\u5176\u4e2d\uff0c\u5e76\u521b\u5efa\u6e90\u7684 rpm \u5305\u7d22\u5f15\u4fe1\u606f\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6bcf\u6b21\u589e\u52a0\u65b0\u7684 rpm \u5305\uff0c\u90fd\u9700\u8981\u4f7f\u7528 createrepo \u547d\u4ee4\u6765\u66f4\u65b0\u4e00\u6b21\u7d22\u5f15\u4fe1\u606f\u3002  <\/p>\n<p><code>mkdir -p centos\/6\/x86_64<\/code>  <\/p>\n<p><code>cp ~\/*.rpm centos\/6\/x86_64\/<\/code>  <\/p>\n<p><code>createrepo -p -d -o centos\/6\/x86_64 centos\/6\/x86_64<\/code>  <\/p>\n<p><code>\u4ece\u79d1\u5927copy\u8fc7\u6765\u7684\u5f88\u591a\u7d22\u5f15\u4fe1\u606f\u90fd\u6709\u4e86\uff0c\u76f4\u63a5\u53ef\u4ee5\u7528\uff0c\u5982\u679c\u4ee5\u540e\u6ca1\u6709\u8fd9\u4e2a\uff0c\u6216\u8005\u81ea\u5efa\u7684\u8bdd \u5c31\u9700\u8981\u521b\u5efa\u7d22\u5f15\u4fe1\u606f\u3002<\/code>  <\/p>\n<p><code>4\uff1a\u8bbe\u7f6e\u5ba2\u6237\u7aef<\/code>  <\/p>\n<p><code><\/code>&nbsp; <\/p>\n<p>[root@localhost 6]# cat \/etc\/yum.repos.d\/CentOS-Base.repo <br \/># CentOS-Base.repo<br \/>#<br \/># The mirror system uses the connecting IP address of the client and the<br \/># update status of each mirror to pick mirrors that are updated to and<br \/># geographically close to the client.&nbsp; You should use this for CentOS updates<br \/># unless you are manually picking other mirrors.<br \/>#<br \/># If the mirrorlist= does not work for you, as a fall back you can try the <br \/># remarked out baseurl= line instead.<br \/>#<br \/>#  <\/p>\n<p>[base]<br \/>name=CentOS-$releasever &#8211; Base<br \/>mirrorlist=<a href=\"http:\/\/mirrorlist.centos.org\/?release=\">http:\/\/mirrorlist.centos.org\/?release=<\/a>$releasever&amp;arch=$basearch&amp;repo=os<br \/>#baseurl=<a href=\"http:\/\/mirror.centos.org\/centos\/\">http:\/\/mirror.centos.org\/centos\/<\/a>$releasever\/os\/$basearch\/<br \/>gpgcheck=1<br \/>gpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-CentOS-6  <\/p>\n<p>#released updates <br \/>[updates]<br \/>name=CentOS-$releasever &#8211; Updates<br \/>mirrorlist=<a href=\"http:\/\/mirrorlist.centos.org\/?release=\">http:\/\/mirrorlist.centos.org\/?release=<\/a>$releasever&amp;arch=$basearch&amp;repo=updates<br \/>#baseurl=<a href=\"http:\/\/mirror.centos.org\/centos\/\">http:\/\/mirror.centos.org\/centos\/<\/a>$releasever\/updates\/$basearch\/<br \/>gpgcheck=1<br \/>gpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-CentOS-6  <\/p>\n<p>#additional packages that may be useful<br \/>[extras]<br \/>name=CentOS-$releasever &#8211; Extras<br \/>mirrorlist=<a href=\"http:\/\/mirrorlist.centos.org\/?release=\">http:\/\/mirrorlist.centos.org\/?release=<\/a>$releasever&amp;arch=$basearch&amp;repo=extras<br \/>#baseurl=<a href=\"http:\/\/mirror.centos.org\/centos\/\">http:\/\/mirror.centos.org\/centos\/<\/a>$releasever\/extras\/$basearch\/<br \/>gpgcheck=1<br \/>gpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-CentOS-6  <\/p>\n<p>#additional packages that extend functionality of existing packages<br \/>[centosplus]<br \/>name=CentOS-$releasever &#8211; Plus<br \/>mirrorlist=<a href=\"http:\/\/mirrorlist.centos.org\/?release=\">http:\/\/mirrorlist.centos.org\/?release=<\/a>$releasever&amp;arch=$basearch&amp;repo=centosplus<br \/>#baseurl=<a href=\"http:\/\/mirror.centos.org\/centos\/\">http:\/\/mirror.centos.org\/centos\/<\/a>$releasever\/centosplus\/$basearch\/<br \/>gpgcheck=1<br \/>enabled=0<br \/>gpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-CentOS-6  <\/p>\n<p>#contrib &#8211; packages by Centos Users<br \/>[contrib]<br \/>name=CentOS-$releasever &#8211; Contrib<br \/>mirrorlist=<a href=\"http:\/\/mirrorlist.centos.org\/?release=\">http:\/\/mirrorlist.centos.org\/?release=<\/a>$releasever&amp;arch=$basearch&amp;repo=contrib<br \/>#baseurl=<a href=\"http:\/\/mirror.centos.org\/centos\/\">http:\/\/mirror.centos.org\/centos\/<\/a>$releasever\/contrib\/$basearch\/<br \/>gpgcheck=1<br \/>enabled=0<br \/>gpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-CentOS-6  <\/p>\n<p>&nbsp;<\/p>\n<p>\u7136\u540e\u5c31\u4eab\u53d7\u5185\u7f51\u7684\u66f4\u65b0\uff0c\u901f\u5ea6\u4e0e\u6fc0\u60c5\u5427\uff01\uff01\uff01<\/p>\n<p>&nbsp;<\/p>\n<p>\u540c\u6b65\u811a\u672c\u5982\u4e0b\uff1a<\/p>\n<p>&nbsp;<\/p>\n<p>[root@localhost 6]# cat \/root\/shell\/rsync.sh <br \/>#!\/bin\/bash  <\/p>\n<p># base value<br \/># \u8981\u540c\u6b65\u7684\u6e90<br \/>YUM_SITE=&#8221;rsync:\/\/mirrors.ustc.edu.cn\/centos\/&#8221;<br \/>YUM_SITE2=&#8221;rsync:\/\/mirrors.ustc.edu.cn\/epel\/&#8221;<br \/># \u672c\u5730\u5b58\u653e\u76ee\u5f55<br \/>LOCAL_PATH=&#8221;\/home\/share\/yum\/centos\/&#8221;<br \/>LOCAL_PATH2=&#8221;\/home\/share\/yum\/epel\/&#8221;<br \/># \u9700\u8981\u540c\u6b65\u7684\u7248\u672c\uff0c\u6211\u53ea\u9700\u89815\u548c6\u7248\u672c\u8fd8\u67097\u7684\uff0c\u603b\u5171\u5728120G\u5de6\u53f3\uff0c\u4e0d\u5305\u62eciso\u4f1a\u5c11\u70b9<br \/>LOCAL_VER=&#8221;5 5* 6 6*&#8221;<br \/># \u540c\u6b65\u65f6\u8981\u9650\u5236\u7684\u5e26\u5bbd<br \/>BW_limit=20480<br \/># \u8bb0\u5f55\u672c\u811a\u672c\u8fdb\u7a0b\u53f7<br \/>LOCK_FILE=&#8221;\/var\/log\/yum_server.pid&#8221;<br \/># \u540c\u6b65\u65e5\u5fd7\u6587\u4ef6<br \/>LogFile=\/root\/rsyumlog\/`date +&#8221;%Y-%m-%d&#8221;`.log<br \/># \u5982\u7528\u7cfb\u7edf\u9ed8\u8ba4rsync\u5de5\u5177\u4e3a\u7a7a\u5373\u53ef\u3002<br \/># \u5982\u7528\u81ea\u5df1\u5b89\u88c5\u7684rsync\u5de5\u5177\u76f4\u63a5\u586b\u5199\u5b8c\u6574\u8def\u5f84<br \/>RSYNC_PATH=&#8221;\/usr\/bin\/rsync&#8221;<br \/># check update yum server&nbsp; pid<br \/>MY_PID=$$<br \/>if [ -f $LOCK_FILE ]; then<br \/>&nbsp;&nbsp;&nbsp; get_pid=`\/bin\/cat $LOCK_FILE`<br \/>&nbsp;&nbsp;&nbsp; get_system_pid=`\/bin\/ps -ef|grep -v grep|grep $get_pid|wc -l`<br \/>&nbsp;&nbsp;&nbsp; if [ $get_system_pid -eq 0 ] ; then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $MY_PID&gt;$LOCK_FILE<br \/>&nbsp;&nbsp;&nbsp; else<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &#8220;Have update yum server now!&#8221;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit 1<br \/>&nbsp;&nbsp;&nbsp; fi<br \/>else<br \/>&nbsp;&nbsp;&nbsp; echo $MY_PID&gt;$LOCK_FILE<br \/>fi<br \/># check rsync tool<br \/>if [ -z $RSYNC_PATH ]; then<br \/>&nbsp;&nbsp;&nbsp; RSYNC_PATH=`\/usr\/bin\/whereis rsync|awk &#8216; &#8221;{print $2}&#8217;`<br \/>&nbsp;&nbsp;&nbsp; if [ -z $RSYNC_PATH ]; then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &#8216;Not find rsync tool.&#8217;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &#8216;use comm: yum install -y rsync&#8217;<br \/>&nbsp;&nbsp;&nbsp; fi<br \/>fi<br \/># sync yum source<br \/>echo &#8220;rsync start at $(date +&#8221;%Y-%m-%d %H:%M:%S&#8221;)&#8221; &gt;$LogFile<br \/>echo &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#8221; &gt;&gt;$LogFile<br \/>for VER in $LOCAL_VER;<br \/>do<br \/>&nbsp;&nbsp;&nbsp; # Check whether there are local directory<br \/>&nbsp;&nbsp;&nbsp; if [ ! -d &#8220;$LOCAL_PATH$VER&#8221; ] ; then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &#8220;Create dir $LOCAL_PATH$VER&#8221;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; `\/bin\/mkdir -p $LOCAL_PATH$VER`<br \/>&nbsp;&nbsp;&nbsp; fi<br \/>&nbsp; if [ ! -d &#8220;$LOCAL_PATH2$VER&#8221; ] ; then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &#8220;Create dir $LOCAL_PATH2$VER&#8221;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; `\/bin\/mkdir -p $LOCAL_PATH2$VER`<br \/>&nbsp;&nbsp;&nbsp; fi<br \/>&nbsp;&nbsp;&nbsp; # sync yum source<br \/>&nbsp;&nbsp;&nbsp;&nbsp; echo &#8220;Start sync $LOCAL_PATH$VER&#8221;&nbsp; &gt;&gt;$LogFile<br \/>&nbsp;&nbsp;&nbsp;&nbsp; echo &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#8221; &gt;&gt;$LogFile <br \/>&nbsp;&nbsp;&nbsp; $RSYNC_PATH -avrtH &#8211;exclude-from=\/root\/shell\/exclude.list &#8211;delete &#8211;bwlimit=$BW_limit&nbsp; $YUM_SITE$VER $LOCAL_PATH&nbsp; &gt;&gt;$LogFile<br \/>&nbsp;&nbsp;&nbsp; $RSYNC_PATH -avrtH &#8211;exclude-from=\/root\/shell\/exclude.list &#8211;delete &#8211;bwlimit=$BW_limit&nbsp; $YUM_SITE2$VER $LOCAL_PATH2&nbsp; &gt;&gt;$LogFile<br \/>done<br \/>echo &#8220;rsync end at $(date +&#8221;%Y-%m-%d %H:%M:%S&#8221;)&#8221; &gt;&gt;$LogFile<br \/>echo &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#8221; &gt;&gt;$LogFile <br \/>done<br \/># clean lock file<br \/>`\/bin\/rm -rf $LOCK_FILE`<br \/>echo &#8216;sync end.&#8217;<br \/>exit 1<\/p>\n<p>&nbsp;<\/p>\n<p>#########<\/p>\n<p>\u540e\u7eed\u6dfb\u52a0gitlab-ce\u7684\u79c1\u6709\u6e90\u7684\u505a\u6cd5<\/p>\n<p>\u540c\u6b65\u811a\u672c\uff1a<\/p>\n<p>[root@localhost el]# cat \/root\/shell\/get_gitlab.sh <br \/>version=$(yum provides gitlab-ce | tail -n 10 | grep omnibus | awk &#8216;{print $1}&#8217;)<br \/>version_old=$(cat \/root\/shell\/old.txt)<br \/>if [ $version != $version_old ]<br \/>then<br \/>cd \/home\/share\/yum\/gitlab-ce\/el\/6\/x86_64  <\/p>\n<p>wget -O $version.rpm <a href=\"https:\/\/packages.gitlab.com\/gitlab\/gitlab-ce\/packages\/el\/7\/\">https:\/\/packages.gitlab.com\/gitlab\/gitlab-ce\/packages\/el\/7\/<\/a>$version.rpm\/download <br \/>echo $version &gt; \/root\/shell\/old.txt<br \/>createrepo -p -d .\/<br \/>fi  <\/p>\n<p>\u6e90\u7684\u5199\u6cd5\uff1a<\/p>\n<p>[root@imooc yum.repos.d]# cat gitlab_gitlab-ce.repo <br \/>[gitlab_gitlab-ce]<br \/>name=gitlab_gitlab-ce<br \/>baseurl=<a href=\"http:\/\/192.168.9.171:10086\/yum\/gitlab-ce\/el\/6\/\">http:\/\/192.168.9.171:10086\/yum\/gitlab-ce\/el\/6\/<\/a>$basearch <\/p>\n<p>repo_gpgcheck=1<br \/>gpgcheck=0<br \/>enabled=1<br \/><font color=\"#ff0000\">gpgkey=https:\/\/packages.gitlab.com\/gpg.key<\/font><\/p>\n<p>\u7ea2\u8272\u5b57\u4f53\u5fc5\u987b\u6dfb\u52a0\uff0c\u5426\u5219\u4f1a\u9a8c\u8bc1\u65e0\u6cd5\u5b89\u88c5\uff0c\u7c7b\u4f3c\u6821\u9a8c\u662f\u5426\u5b98\u7f51\u7684rpm\u5305\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[164,165],"class_list":["post-4438","post","type-post","status-publish","format-standard","hentry","category-5","tag-yum","tag-165","category-5-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/4438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4438"}],"version-history":[{"count":7,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/4438\/revisions"}],"predecessor-version":[{"id":4665,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/4438\/revisions\/4665"}],"wp:attachment":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}