YUM源

一 IP 配置

进入网络的配置文件
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
进入文件之后修改的配置
BOOTPROTO=static                //修改为静态地址
ONBOOT=yes                       //开机自动启动网卡
IPADDR=192.168.223.66            //IP地址
PREFIX=24                       //子网掩码
GATEWAY=192.168.223.2            //网关
DNS1=114.114.114.114            //DNS(可以写一个 DNS 也可以写两个 DNS)
DNS=8.8.8.8
按 ESC 键之后 Shift+: 然后输入 wq 是保存退出

[root@localhost ~]# systemctl restart network
做完之后去 ping qq.com ping通的话就说明配置成功

二 磁盘挂载
/dev/sr0 是光盘挂在区
opt目录下创建centos
[root@localhost ~]# mkdir /opt/centos
将/dev/sr0挂载到/opt/centos
[root@localhost ~]# mount /dev/sr0 /opt/centos
查看挂载情况
[root@localhost ~]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
devtmpfs                 475M     0  475M    0% /dev
tmpfs                    487M     0  487M    0% /dev/shm
tmpfs                    487M  7.8M  479M    2% /run
tmpfs                    487M     0  487M    0% /sys/fs/cgroup
/dev/mapper/centos-root   17G  1.5G   16G    9% /
/dev/sda1               1014M  138M  877M   14% /boot
tmpfs                     98M     0   98M    0% /run/user/0
/dev/sr0                 4.4G  4.4G     0  100% /opt/centos

这个目录就是光盘里所以的文件(两个须知目录一个是:Packages(所以软件包rpm所存放的位置)还有一个是:repodata(yum源数据))
[root@localhost ~]# ls /opt/centos
CentOS_BuildTag  EULA  images    LiveOS    repodata              RPM-GPG-KEY-CentOS-Testing-7
EFI              GPL   isolinux  Packages  RPM-GPG-KEY-CentOS-7  TRANS.TBL

 

三 配置yum源

与上一步(磁盘挂载同步,这个yum源需要与挂载)
源仓库
[root@localhost centos]# cd /etc/yum.repos.d/  (vi /etc/yum.repos.d/local.repo)
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo  CentOS-x86_64-kernel.repo
把yum源移走
[root@localhost yum.repos.d]# mv * /mnt/

创建自己的yum源库
[root@localhost yum.repos.d]# vi local.repo
进入文档之后输入【baseurl:仓库路经 gpgcheck:校验 nabled:开启】
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1

清除缓存
[root@localhost yum.repos.d]# yum clean all
列出yum仓库所有文件(下面的显示的源名称跟上面修改的一样)
[root@localhost yum.repos.d]# yum repolist all
已加载插件:fastestmirror
Determining fastest mirrors
centos                                                                                          | 3.6 kB  00:00:00     
(1/2): centos/group_gz                                                                          | 153 kB  00:00:00     
(2/2): centos/primary_db                                                                        | 3.3 MB  00:00:00     
源标识                                                源名称                                                状态
centos                                                centos                                                启用: 4,070
repolist: 4,070
安装vim测试是否可以下载
[root@localhost yum.repos.d]# yum install vim -y
查看vim
[root@localhost yum.repos.d]# rpm -qa | grep vim
vim-common-7.4.629-8.el7_9.x86_64
vim-filesystem-7.4.629-8.el7_9.x86_64
vim-enhanced-7.4.629-8.el7_9.x86_64
vim-minimal-7.4.629-7.el7.x86_64
常用的一些工具
vim install autofs wget net-tools telnet tree nmap sysstat lrasz dos2unix bind-utils bzip2 rsync psmisc mlocate unzip vim bash-completion -y

写一个小脚本让他开机自动挂载yum源
[root@localhost ~]#  echo "mount /dev/sr0 /opt/centos" >> /etc/rc.d/rc.local
会发现他是没有执行权限的
[root@localhost ~]# ll /etc/rc.d/rc.local
-rw-r--r--. 1 root root 500 11月 29 15:51 /etc/rc.d/rc.local
增加权限
[root@localhost ~]# chmod +x /etc/rc.d/rc.local
查看是否成功
[root@localhost ~]# ll /etc/rc.d/rc.local
-rwxr-xr-x. 1 root root 500 11月 29 15:51 /etc/rc.d/rc.local

windows文件夹的yum源
#先使用xftp把文件存放到Linux里放到root根目录下
[root@localhost ~]# ls
anaconda-ks.cfg        gpmall-repo
gpmall-repo 移动到 opt 目录下
[root@localhost ~]# mv gpmall-repo /opt
[root@localhost ~]# cd /etc/yum.repos.d/
可以接着上面的写
[root@localhost yum.repos.d]# vi local.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[gpmall]
name=gpmall
baseurl=file:///opt/gpmall-repo
gpgcheck=0

清除缓存
[root@localhost yum.repos.d]# yum clean all
列出yum仓库所有文件(下面的显示的源名称跟上面修改的一样)
[root@localhost yum.repos.d]# yum repolist all
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
源标识                             源名称                             状态
centos                             centos                             启用: 4,070
gpmall                             gpmall                             启用:   165
repolist: 4,235

四 关闭防火墙
关闭防火墙并开启不自启
[root@localhost ~]# systemctl stop firewalld 


关闭se(简单的关闭se,重启后还会自动打开)
[root@localhost yum.repos.d]# setenforce 0
修改se配置文件(永久性的关闭se
[root@localhost ~]# vim /etc/selinux/config 
进入文件之后修改
SELINUX=disabled
查看se状态
[root@localhost ~]# getenforce
Disabled
posted @ 2021-12-05 16:40  年年哎  阅读(171)  评论(0)    收藏  举报