Linux下本地yum源配置(内网、无连接公网)

最近公司由于全国性的h w运动,老服务器openssh版本太低,有很多漏洞容易被攻破,部门人员恳请我个open人员PG(Programmer Develope),披坚执锐兮,孤立山岗。吾来着不惧(拒),回应定能一夫当关万夫莫开。然而一看清单,服务器都没有与公网链接,内部安装系统的时候都是精装版的。连GCC、G++都没装。好吧,眉头一皱,计上心来(事情不简单)。故配置本地yum源。希望对大家有帮助(备自己忘)。都是纯命令撸的,待闲鱼(闲暇)之时, 在对命令批注解!


往后考虑是否专门在此局域网用一台服务器做yum源为几百台服务器提供yum服务。

一、Linux 下本地YUM源配置
1.1、挂载本地ISO镜像
1.2、创建本地的repo文件
1.3、现在即可使用本地的YUM进行安装软件
提前准备把CentOS-6.9-x86_64-bin-DVD1.iso移到/home目录下
移动之前要df -h查看下剩余的磁盘空间。
[root@localhost gcc-4.1.2]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G  4.9G   42G  11% /
tmpfs                 3.9G   80K  3.9G   1% /dev/shm
/dev/sda1             477M   36M  416M   8% /boot
/dev/mapper/VolGroup-lv_home
                       78G   23G   51G  31% /home
[root@localhost home]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir BAK
[root@localhost yum.repos.d]# mv *.repo ./BAK/
[root@localhost yum.repos.d]# ll BAK/
[root@localhost yum.repos.d]# touch local.repo
[root@localhost yum.repos.d]# vi local.repo 
[Local]
name=Local Diretory
baseurl=file:///mnt/cdrom
enable=1
gpgcheck=0
[root@localhost yum.repos.d]# cd /mnt/
[root@localhost mnt]# mkdir cdrom
[root@localhost ~]# vi /etc/rc.local 
[root@localhost ~]# cat /etc/rc.local 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
[root@localhost ~]# cat /etc/rc.local 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

mount -o loop /home/CentOS-6.9-x86_64-bin-DVD1.iso /mnt/cdrom/
[root@localhost ~]# cd /home/
[root@localhost home]# ll
总用量 3878940
-rw-r--r--.  1 root  root  3972005888 9月  10 2018 CentOS-6.9-x86_64-bin-DVD1.iso
drwx------. 26 yi yi       4096 6月   1 14:16 yi
[root@localhost home]# chmod 444 CentOS-6.9-x86_64-bin-DVD1.iso 
[root@localhost home]# 
[root@localhost home]# 
[root@localhost home]# 
[root@localhost home]# ll
总用量 3878940
-r--r--r--.  1 root  root  3972005888 9月  10 2018 CentOS-6.9-x86_64-bin-DVD1.iso
drwx------. 26 yi yi       4096 6月   1 14:16 yi
[root@localhost home]# cat /etc/rc.local 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

mount -o loop /home/CentOS-6.9-x86_64-bin-DVD1.iso /mnt/cdrom/
[root@localhost home]# mount -o loop /home/CentOS-6.9-x86_64-bin-DVD1.iso /mnt/cdrom/
[root@localhost home]# rpm -qa | grep gcc
[root@localhost home]# yum list | grep gcc
libgcc.x86_64                            4.4.7-11.el6                      @anaconda-CentOS-201410241409.x86_64/6.6
yum install gcc.x86_64 gcc-c++.x86_64 -y
[root@localhost home]# yum install zlib-devel.x86_64 perl-Params-Validate.x86_64 perl-Module-Load-Conditional pam-devel -y
已加载插件:fastestmirror, refresh-packagekit, security

往后考虑是否专门在此局域网用一台服务器做yum源发布服务为几百台服务器提供yum服务。

有啥不合理地方 望请指正哈。
 ok---恰同学少年-19.8.6

你可能感兴趣的:(PG的维护)