{"id":241279,"date":"2022-05-07T09:59:19","date_gmt":"2022-05-07T01:59:19","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=241279"},"modified":"2022-04-29T10:00:12","modified_gmt":"2022-04-29T02:00:12","slug":"yum-linux","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/yum-linux.html","title":{"rendered":"\u5206\u4eab\u4e00\u4e0b\u81ea\u5236yum\u4ed3\u5e93"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u4eca\u5929\u6765\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u4e00\u4e0blinux\u5236\u4f5cyum\u4ed3\u5e93\u7684\u65b9\u6cd5<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

yum\u4ed3\u5e93\u914d\u7f6e\u6587\u4ef6<\/strong><\/div>\n
# \u4ed3\u5e93\u540d\r\n[base]\r\n\r\n# \u4ed3\u5e93\u63cf\u8ff0\r\nname=CentOS-$releasever - Base - mirrors.aliyun.com\r\n\r\n# \u4ed3\u5e93\u5730\u5740\r\nbaseurl=http:\/\/mirrors.aliyun.com\/centos\/$releasever\/os\/$basearch\/\r\n\r\n# \u68c0\u6d4b\u7b7e\u540d\u673a\u5236\uff081\uff1a\u5f00\u542f\u68c0\u6d4b 0\uff1a\u5173\u95ed\u68c0\u6d4b\uff09\r\ngpgcheck=1\r\n\r\n# \u7b7e\u540d\u673a\u5236\u79d8\u94a5\u5730\u5740\r\ngpgkey=http:\/\/mirrors.aliyun.com\/centos\/RPM-GPG-KEY-CentOS-7\r\n<\/pre>\n
yum\u4ed3\u5e93\u7c7b\u578b<\/strong><\/div>\n
# 1.\u8fdc\u7a0b\u4ed3\u5e93<\/strong><\/span><\/div>\n
http:\/\/ \u00a0 \u7aef\u53e3\uff1a80\r\nhttps:\/\/ \u00a0 \u7aef\u53e3\uff1a443\r\nftp:\/\/ \u00a0 \u00a0 \u7aef\u53e3\uff1a21<\/pre>\n
# 2.\u672c\u5730\u4ed3\u5e93<\/strong><\/span><\/div>\n
file:\/\/ \u00a0 \u6ca1\u6709\u7aef\u53e3\uff08\u672c\u5730\u534f\u8bae\uff09\r\n\r\n# \u534f\u8bae\uff1ahttp:\/\/ https:\/\/ ftp:\/\/ file:\/\/\r\n\r\nhttp:\/\/ \u00a0 \u7aef\u53e3\uff1a80\r\nhttps:\/\/ \u00a0 \u7aef\u53e3\uff1a443\r\nftp:\/\/ \u00a0 \u00a0 \u7aef\u53e3\uff1a21\r\nfile:\/\/ \u00a0 \u6ca1\u6709\u7aef\u53e3\uff08\u672c\u5730\u534f\u8bae\uff09\r\n\r\n<\/pre>\n
\u672c\u5730yum\u4ed3\u5e93\uff08file:\/\/\uff09<\/strong><\/span><\/div>\n

# \u5148\u51b3\u6761\u4ef6
\n1\uff09\u521b\u5efa\u4ed3\u5e93\u7684\u547d\u4ee4<\/p>\n

               - createrepo<\/pre>\n

2\uff09\u8fd8\u8981\u6709rpm\u5305<\/p>\n

               - \u7f51\u7ad9\u83b7\u53d6\r\n                 - \u955c\u50cf\u83b7\u53d6\r\n                 - yum\u6e90\u83b7\u53d6<\/pre>\n

3\uff09yum\u6e90\u7684\u914d\u7f6e\u6587\u4ef6<\/p>\n

# 1.\u5b89\u88c5\u521b\u5efa\u4ed3\u5e93\u7684\u547d\u4ee4<\/p>\n

[root@localhost ]# yum install -y createrepo<\/sub><\/pre>\n

# 2.\u901a\u8fc7\u955c\u50cf\uff0c\u83b7\u53d6rpm\u5305
\n# 1\uff09\u6302\u8f7d\u955c\u50cf<\/p>\n

[root@localhost ]# mount \/dev\/cdrom \/mnt\/\r\nmount: \/dev\/sr0 is write-protected, mounting read-only<\/pre>\n

# 2\uff09\u521b\u5efa\u4e00\u4e2a\u4ed3\u5e93\u76ee\u5f55<\/p>\n

[root@localhost ]# mkdir \/local_yum_repo<\/sub><\/pre>\n

# 3\uff09\u62f7\u8d1drpm\u5305\u5230\u4ed3\u5e93\u76ee\u5f55\u4e2d<\/p>\n

[root@localhost ]# cp \/mnt\/Packages\/*.rpm \/local_yum_repo\/<\/pre>\n

# 4\uff09\u5148\u628a\u4ed3\u5e93\u53d8\u6210\u76ee\u5f55<\/p>\n

[root@localhost ]# createrepo \/local_yum_repo\/\r\nSpawning worker 0 with 4070 pkgs\r\nWorkers Finished\r\nSaving Primary metadata\r\nSaving file lists metadata\r\nSaving other metadata\r\nGenerating sqlite DBs\r\nSqlite DBs complete\r\n<\/sub><\/pre>\n

# 5)\u68c0\u67e5\u662f\u5426\u628a\u76ee\u5f55\u53d8\u6210\u4e86\u4ed3\u5e93<\/p>\n

[root@localhost ]# ll -d \/local_yum_repo\/\r\ndrwxr-xr-x. 3 root root 225280 Apr 25 17:28 \/local_yum_repo\/\r\n<\/pre>\n

# 6\uff09\u538b\u7f29\u5176\u4ed6yum\u6e90<\/p>\n

[root@localhost ]# gzip -r \/etc\/yum.repos.d\/<\/sub><\/pre>\n

# 7\uff09\u624b\u5199yum\u6e90\u914d\u7f6e\u6587\u4ef6\uff08\u5fc5\u987b\u4ee5repo\u7ed3\u5c3e\uff09<\/p>\n

# \u4ed3\u5e93\u540d\r\n[zxw_local]\r\n\r\n# \u4ed3\u5e93\u63cf\u8ff0\r\nname=Local Pepository By zxw\r\n\r\n# \u4ed3\u5e93\u5730\u5740\r\nbaseurl=file:\/\/\/local_yum_repo\r\n\r\n#\u5173\u95ed\u7b7e\u540d\u68c0\u6d4b\u673a\u5236\r\ngpgcheck=0\r\n\r\n#\u5f00\u542f\u4ed3\u5e93\r\nenabled=1\r\n<\/pre>\n
# 8\uff09\u4f7f\u7528yum\u6e90<\/strong><\/span><\/div>\n
[root@localhost ]# yum repolist all\r\nLoaded plugins: fastestmirror\r\nLoading mirror speeds from cached hostfile\r\nrepo id                                                                          repo name                                                                                       status\r\nzxw_local                                                                        Local Pepository By zxw                                                                         enabled: 4,070\r\nrepolist: 4,070\r\n<\/pre>\n
\u8fdc\u7a0byum\u4ed3\u5e93<\/strong><\/div>\n
# 1.\u5148\u51b3\u6761\u4ef6<\/strong><\/span><\/div>\n

1\uff09\u521b\u5efa\u4ed3\u5e93\u7684\u547d\u4ee4<\/p>\n

 - createrepo<\/pre>\n

2\uff09\u8fd8\u8981\u6709rpm\u5305<\/p>\n

  - \u7f51\u7ad9\u83b7\u53d6\r\n - \u955c\u50cf\u83b7\u53d6\r\n - yum\u6e90\u83b7\u53d6<\/pre>\n

3\uff09yum\u6e90\u7684\u914d\u7f6e\u6587\u4ef6
\n# 1.\u5b89\u88c5\u521b\u5efa\u4ed3\u5e93\u7684\u547d\u4ee4<\/p>\n

[root@localhost ]# yum install -y createrepo<\/sub><\/pre>\n
# 2.\u901a\u8fc7\u955c\u50cf\uff0c\u83b7\u53d6rpm\u5305<\/strong><\/span><\/div>\n

## 1\uff09\u6302\u8f7d\u955c\u50cf<\/p>\n

[root@localhost ]# mount \/dev\/cdrom \/mnt\/\r\nmount: \/dev\/sr0 is write-protected, mounting read-only<\/pre>\n

## 2\uff09\u5b89\u88c5\u5b89\u88c5vsftpd\u670d\u52a1<\/p>\n

[root@localhost ]# yum install -y vsftpd<\/sub><\/pre>\n

## 3\uff09\u542f\u52a8\u670d\u52a1<\/p>\n

[root@localhost ]# systemctl start vsftpd<\/pre>\n

## 4\uff09\u68c0\u67e5\u7aef\u53e3
\n\u5982\u679c\u6ca1\u6709\u547d\u4ee4net-tools\u5c31\u5b89\u88c5\u4e00\u4e2a<\/p>\n

[root@localhost ]# yum install -y net-tools\r\n[root@localhost <\/sub>]# netstat -lntup\r\nActive Internet connections (only servers)\r\nProto Recv-Q Send-Q Local Address           Foreign Address         State       PID\/Program name    \r\ntcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      941\/sshd            \r\ntcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1107\/master         \r\ntcp6       0      0 :::21                   :::*                    LISTEN      11416\/vsftpd        \r\ntcp6       0      0 :::22                   :::*                    LISTEN      941\/sshd            \r\ntcp6       0      0 ::1:25                  :::*                    LISTEN      1107\/master         \r\n[root@localhost ]# netstat -lntup|grep vsftpd\r\ntcp6       0      0 :::21                   :::*                    LISTEN      11416\/vsftpd   <\/sub><\/pre>\n

## 5\uff09\u6253\u5f00\u6d4f\u89c8\u5668\u8bbf\u95ee\uff1aftp:\/\/10.0.0.105<\/p>\n

ftp:\/\/ID\r\n<\/pre>\n

## 6\uff09\u5173\u95ed\u9632\u706b\u5899<\/p>\n

[root@localhost ]# systemctl stop firewalld\r\n[root@localhost ]# setenforce 0<\/sub><\/pre>\n

## 7)\u521b\u5efa\u4ed3\u5e93\u76ee\u5f55<\/p>\n

[root@localhost ]# mkdir \/var\/ftp\/pub\/{base,epel}\r\n[root@localhost ]# ll \/var\/ftp\/pub\/\r\ntotal 0\r\ndrwxr-xr-x. 2 root root 6 Apr 25 18:27 base\r\ndrwxr-xr-x. 2 root root 6 Apr 25 18:27 epel\r\n<\/sub><\/pre>\n

## 8\uff09\u62f7\u8d1drpm\u5305\u5230base\u76ee\u5f55\u4e0b\uff08\u6211\u5c31\u968f\u4fbf\u5f04\u4e86\u4fe9\uff0c\u8fd9\u91cc\u53ea\u662f\u793a\u8303\uff09<\/p>\n

[root@localhost pub]# cp \/mnt\/Packages\/zip-3.0-11.el7.x86_64.rpm .\/base\/\r\n[root@localhost pub]# cp \/mnt\/Packages\/tree-1.6.0-10.el7.x86_64.rpm .\/base\/\r\n[root@localhost pub]# ll base\/\r\ntotal 308\r\n-rw-r--r--. 1 root root  47508 Apr 25 18:42 tree-1.6.0-10.el7.x86_64.rpm\r\n-rw-r--r--. 1 root root 266160 Apr 25 18:38 zip-3.0-11.el7.x86_64.rpm<\/pre>\n

## 9\uff09\u4e0b\u8f7drpm\u5305\u5230epel\u6e90<\/p>\n

[root@localhost pub]# cd epel\/\r\n[root@localhost epel]# wget https:\/\/mirrors.aliyun.com\/epel\/7\/x86_64\/Packages\/h\/hdf5-1.8.12-13.el7.x86_64.rpm\r\n[root@localhost epel]# ll\r\ntotal 1644\r\n-rw-r--r--. 1 root root 1682124 Sep 16  2021 hdf5-1.8.12-13.el7.x86_64.rpm\r\n<\/pre>\n

## 10\uff09\u5206\u522b\u628a\u8fd9\u4e24\u4e2a\u76ee\u5f55\u505a\u6210\u4ed3\u5e93<\/p>\n

[root@localhost ]# createrepo \/var\/ftp\/pub\/base\/\r\nSpawning worker 0 with 2 pkgs\r\nWorkers Finished\r\nSaving Primary metadata\r\nSaving file lists metadata\r\nSaving other metadata\r\nGenerating sqlite DBs\r\nSqlite DBs complete\r\n[root@localhost ]# createrepo \/var\/ftp\/pub\/epel\/\r\nSpawning worker 0 with 1 pkgs\r\nWorkers Finished\r\nSaving Primary metadata\r\nSaving file lists metadata\r\nSaving other metadata\r\nGenerating sqlite DBs\r\nSqlite DBs complete\r\n[root@localhost <\/sub>]# ll \/var\/ftp\/pub\/base\/\r\ntotal 312\r\ndrwxr-xr-x. 2 root root   4096 Apr 25 19:16 repodata\r\n-rw-r--r--. 1 root root  47508 Apr 25 18:42 tree-1.6.0-10.el7.x86_64.rpm\r\n-rw-r--r--. 1 root root 266160 Apr 25 18:38 zip-3.0-11.el7.x86_64.rpm\r\n[root@localhost ]# ll \/var\/ftp\/pub\/epel\/\r\ntotal 1648\r\n-rw-r--r--. 1 root root 1682124 Sep 16  2021 hdf5-1.8.12-13.el7.x86_64.rpm\r\ndrwxr-xr-x. 2 root root    4096 Apr 25 19:17 repodata\r\n<\/sub><\/pre>\n

## 11\uff09\u5728\u5176\u4ed6\u673a\u5668\u4e0a\u624b\u5199repo\u914d\u7f6e\u6587\u4ef6<\/p>\n

[root@zxw ]# vim \/etc\/yum.repos.d\/base_epel.repo\r\n[zxw_base]\r\nname=wode base cangku\r\nbaseurl=ftp:\/\/10.0.0.105\/pub\/base\/\r\ngpgcheck=0\r\nenabled=1\r\n\r\n\r\n[zxw_epel]\r\nname=wode epel cangku\r\nbaseurl=ftp:\/\/10.0.0.105\/pub\/epel\r\ngpgcheck=0\r\nenabled=1\r\n\r\n# 12\uff09\u68c0\u67e5yum\u4ed3\u5e93\r\n[root@zxw ]# yum repolist \r\nLoaded plugins: fastestmirror\r\nLoading mirror speeds from cached hostfile\r\nrepo id                              repo name                                    status\r\nzxw_base                             wode base cangku                             2\r\nzxw_epel                             wode epel cangku                             1\r\nrepolist: 3\r\n\r\n# 13\uff09\u4f7f\u7528yum\u5b89\u88c5\r\n[root@zxw <\/sub>]# yum install -y tree\r\nLoaded plugins: fastestmirror\r\nLoading mirror speeds from cached hostfile\r\nResolving Dependencies\r\n--> Running transaction check\r\n---> Package tree.x86_64 0:1.6.0-10.el7 will be installed\r\n--> Finished Dependency Resolution\r\n\r\nDependencies Resolved\r\n\r\n========================================================================================\r\n Package         Arch              Version                    Repository           Size\r\n========================================================================================\r\nInstalling:\r\n tree            x86_64            1.6.0-10.el7               zxw_base             46 k\r\n\r\nTransaction Summary\r\n========================================================================================\r\nInstall  1 Package\r\n\r\nTotal download size: 46 k\r\nInstalled size: 87 k\r\nDownloading packages:\r\ntree-1.6.0-10.el7.x86_64.rpm                                     |  46 kB  00:00:00     \r\nRunning transaction check\r\nRunning transaction test\r\nTransaction test succeeded\r\nRunning transaction\r\n  Installing : tree-1.6.0-10.el7.x86_64                                             1\/1 \r\n  Verifying  : tree-1.6.0-10.el7.x86_64                                             1\/1 \r\n\r\nInstalled:\r\n  tree.x86_64 0:1.6.0-10.el7                                                            \r\n\r\nComplete!\r\n[root@zxw ~]# tree\r\n.\r\n\u251c\u2500\u2500 1.TXT\r\n\u2514\u2500\u2500 2.TXT\r\n\r\n0 directories, 2 files\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

# \u4ed3\u5e93\u540d [base] # \u4ed3\u5e93\u63cf\u8ff0 name=CentOS-$releasever – Base – mi […]<\/p>\n","protected":false},"author":1469,"featured_media":241310,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-241279","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/241279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1469"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=241279"}],"version-history":[{"count":13,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/241279\/revisions"}],"predecessor-version":[{"id":241566,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/241279\/revisions\/241566"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/241310"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=241279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=241279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=241279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}