一. YUM源服务器搭建(httpd方式)
1. 检查机器信息
[root@yumserver ~]# hostname yumserver [root@yumserver ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) [root@yumserver ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 96G 2.7G 94G 3% / devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 8.5M 3.9G 1% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda1 197M 121M 77M 62% /boot tmpfs 781M 0 781M 0% /run/user/0 /dev/sr0 4.3G 4.3G 0 100% /mnt/cdrom [root@yumserver ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000 link/ether 00:50:56:b7:a8:32 brd ff:ff:ff:ff:ff:ff inet 10.129.169.18/24 brd 10.129.169.255 scope global ens192 valid_lft forever preferred_lft forever inet6 fe80::3293:93ff:a9c0:f80e/64 scope link valid_lft forever preferred_lft forever inet6 fe80::8b8e:6494:940b:c5e7/64 scope link tentative dadfailed valid_lft forever preferred_lft forever inet6 fe80::25ef:615d:61e1:4d36/64 scope link tentative dadfailed valid_lft forever preferred_lft forever
2. httpd软件安装
[[root@yumserver ~]# yum -y install httpd [Loaded plugins: fastestmirror [Loading mirror speeds from cached hostfile [Resolving Dependencies [--> Running transaction check [---> Package httpd.x86_64 0:2.4.6-67.el7.centos will be installed [--> Processing Dependency: httpd-tools = 2.4.6-67.el7.centos for package: httpd-2.4.6-67.el7.centos.x86_64 [--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-67.el7.centos.x86_64 [--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-67.el7.centos.x86_64 [--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-67.el7.centos.x86_64 [--> Running transaction check [---> Package apr.x86_64 0:1.4.8-3.el7 will be installed [---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed [---> Package httpd-tools.x86_64 0:2.4.6-67.el7.centos will be installed [---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed [--> Finished Dependency Resolution [ [Dependencies Resolved [ [================================================================================================================== [ Package Arch Version Repository Size [================================================================================================================== [Installing: [ httpd x86_64 2.4.6-67.el7.centos cdrom 2.7 M [Installing for dependencies: [ apr x86_64 1.4.8-3.el7 cdrom 103 k [ apr-util x86_64 1.5.2-6.el7 cdrom 92 k [ httpd-tools x86_64 2.4.6-67.el7.centos cdrom 87 k [ mailcap noarch 2.1.41-2.el7 cdrom 31 k [ [Transaction Summary [================================================================================================================== [Install 1 Package (+4 Dependent packages) [ [Total download size: 3.0 M [Installed size: 10 M [Downloading packages: [------------------------------------------------------------------------------------------------------------------ [Total 36 MB/s | 3.0 MB 00:00:00 [Running transaction check [Running transaction test [Transaction test succeeded [Running transaction [ Installing : apr-1.4.8-3.el7.x86_64 1/5 [ Installing : apr-util-1.5.2-6.el7.x86_64 2/5 [ Installing : httpd-tools-2.4.6-67.el7.centos.x86_64 3/5 [ Installing : mailcap-2.1.41-2.el7.noarch 4/5 [ Installing : httpd-2.4.6-67.el7.centos.x86_64 5/5 [ Verifying : httpd-2.4.6-67.el7.centos.x86_64 1/5 [ Verifying : mailcap-2.1.41-2.el7.noarch 2/5 [ Verifying : apr-1.4.8-3.el7.x86_64 3/5 [ Verifying : httpd-tools-2.4.6-67.el7.centos.x86_64 4/5 [ Verifying : apr-util-1.5.2-6.el7.x86_64 5/5 [ [Installed: [ httpd.x86_64 0:2.4.6-67.el7.centos [ [Dependency Installed: [ apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-67.el7.centos [ mailcap.noarch 0:2.1.41-2.el7 [ [Complete! [[root@yumserver ~]# systemctl status httpd [● httpd.service - The Apache HTTP Server [ Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) [ Active: inactive (dead) [ Docs: man:httpd(8) [ man:apachectl(8) [[root@yumserver ~]# systemctl status httpd [● httpd.service - The Apache HTTP Server [ Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) [ Active: inactive (dead) [ Docs: man:httpd(8) [ man:apachectl(8)
3. httpd启动
[[root@yumserver ~]# systemctl start httpd [root@yumserver ~]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@yumserver ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2023-02-16 14:53:51 CST; 5 days ago Docs: man:httpd(8) man:apachectl(8) Main PID: 112093 (httpd) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service ├─ 39745 /usr/sbin/httpd -DFOREGROUND ├─ 39746 /usr/sbin/httpd -DFOREGROUND ├─ 39747 /usr/sbin/httpd -DFOREGROUND ├─ 39748 /usr/sbin/httpd -DFOREGROUND ├─ 39749 /usr/sbin/httpd -DFOREGROUND ├─ 78937 /usr/sbin/httpd -DFOREGROUND └─112093 /usr/sbin/httpd -DFOREGROUND Feb 16 14:53:51 yumserver systemd[1]: Starting The Apache HTTP Server... Feb 16 14:53:51 yumserver httpd[112093]: AH00558: httpd: Could not reliably determine the server's fully q...ssage Feb 16 14:53:51 yumserver systemd[1]: Started The Apache HTTP Server. Feb 19 03:34:01 yumserver httpd[39743]: AH00558: httpd: Could not reliably determine the server's fully qu...ssage Feb 19 03:34:01 yumserver systemd[1]: Reloaded The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full.
4. 配置YUM源文件,将光盘内容COPY到对应目录
[root@yumserver ~]# cd /var/www/html/ [root@yumserver html]# ll total 8 drwxrwxr-x. 7 root root 4096 Feb 14 09:48 Centos6.9 drwxrwxr-x. 10 root root 251 Feb 14 17:50 Centos7.3 drwxrwxr-x. 8 root root 220 Feb 9 14:35 Centos7.4 drwxrwxr-x. 12 root root 4096 Feb 13 11:30 Redhat6.9
5. 对目录进行yum源库的建立
[root@yumserver ~]# createrepo /var/www/html/Centos6.9 Spawning worker 0 with 810 pkgs Spawning worker 1 with 810 pkgs Spawning worker 2 with 810 pkgs Spawning worker 3 with 810 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@yumserver ~]# createrepo /var/www/html/Centos7.3 Spawning worker 0 with 1208 pkgs Spawning worker 1 with 1208 pkgs Spawning worker 2 with 1207 pkgs Spawning worker 3 with 1207 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@yumserver ~]# createrepo /var/www/html/Centos7.4 Spawning worker 0 with 974 pkgs Spawning worker 1 with 974 pkgs Spawning worker 2 with 973 pkgs Spawning worker 3 with 973 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete
6. 客户端yum配置文件
cat /etc/yum.repos.d/cdrom.repo [cdrom] name=cdrom baseurl=http://10.129.169.18/Redhat6.9 enabled=1 gpgcheck=0
7. 客户端yum测试
[root@rac1 ~]# yum clean all Loaded plugins: product-id, refresh-packagekit, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. Cleaning repos: cdrom Cleaning up Everything [root@rac1 ~]# yum repolist Loaded plugins: product-id, refresh-packagekit, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. cdrom | 2.9 kB 00:00 cdrom/primary_db | 3.1 MB 00:00 repo id repo name status cdrom cdrom 3,994 repolist: 3,994 [root@rac1 ~]# yum makecache Loaded plugins: product-id, refresh-packagekit, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. cdrom | 2.9 kB 00:00 cdrom/filelists_db | 3.4 MB 00:00 cdrom/other_db | 1.3 MB 00:00 Metadata Cache Created [root@rac1 ~]# yum install telnet -y Loaded plugins: product-id, refresh-packagekit, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package telnet.x86_64 1:0.17-48.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================== Package Arch Version Repository Size ================================================================================================================== Installing: telnet x86_64 1:0.17-48.el6 cdrom 58 k Transaction Summary ================================================================================================================== Install 1 Package(s) Total download size: 58 k Installed size: 109 k Downloading Packages: telnet-0.17-48.el6.x86_64.rpm | 58 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : 1:telnet-0.17-48.el6.x86_64 1/1 Verifying : 1:telnet-0.17-48.el6.x86_64 1/1 Installed: telnet.x86_64 1:0.17-48.el6 Complete!
总结:这次部署的YUM源服务器采用的是httpd方式,其实也可以通过ftp实现,这个有机会再完善吧。在部署过程中需要注意的如果操作系统没有安装httpd,createrpop两个软件包,可以先通过挂载cdrom方式,将其装好。最后再叨唠两句,好久没发文了,不对,是太久太久啦!这次回归,希望能给自己学习的道路上再添砖加瓦。Where there is a will, there is a way.
Sam Yang.
2023.02.23
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26148431/viewspace-2936645/ ,如需转载,请注明出处,否则将追究法律责任。