yum 网络库服务器基础搭建

来源:互联网 发布:linux 查看ssh 编辑:程序博客网 时间:2024/06/07 02:59

yum配置使用

网络yum库服务搭建

  • 环境:把centos 7当做服务器端,centos6当做客户端
    首先用镜像搭建一个本地yum
  • 配置/etc/yum.repo.d/bash.repo 配置文件
[root@centos7 yum.repos.d]# lsbak  base.repo
  • 如果没有此文件可以创建一个后缀只要是.repo的就行
  • 我们现在编辑base.repo文件
[base]  库idname=base 库名字baseurl=file:///run/media/root/CentOS\ 7\ x86_64/  rpm包路径,必须是repodata.文件的父目录路径gpgcheck=0 包检查enabled = 1 是否启用
  • 现在我们安装vsftpd服务
[root@centos7 yum.repos.d]# yum install vsftpd
  • ftp共享的文件路径是/var/ftp/pub ,我们进去创建centos/6/os/x86_64/
[root@centos7 pub]# mkdir -p centos/6/os/x86_64/[root@centos7 pub]# lltotal 0drwxr-xr-x. 3 root root 15 Nov 30 19:27 centos
  • 上面创建的目录是共享目录,现在我们把所需要的rpm包复制到这个目录里由于我是用虚拟机做的所以就把6的光盘挂载到这个目录里
[root@centos7 pub]# mount /dev/sr0 centos/6/os/x86_64/mount: /dev/sr0 is write-protected, mounting read-only[root@centos7 pub]# 
  • 现在我们启动ftp服务
systemctl start vsftpd 开启服务systemctl enable vsftpd 开机启动vsftpd服务centos7关防火墙systemctl stop  firewalld 关闭防火墙systemctl disable firwalld 设置开启启动中centos6 关防火墙chkconfig iptables offservice iptables top检查是不是清空了:iptables -nVL ---------------------------------[root@centos7 ~]# systemctl stop firewalld[root@centos7 ~]# systemctl disable firewalldRemoved symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.----------------------------------------我们在把selinux 文件修改一下路径 /etc/selinux/config[root@centos7 ~]# sed -i.bak 's@SELINUX=enforcing@SELINUX=permissive@'  /etc/selinux/config    [root@centos7 ~]# setenforce 0  这样我们可以在浏览器上访问我们centos7的地址用ftp方式ftp://172.168.1.1 就可以看见光盘里的内容。

Centos 6客户端配置
- 我们只需要配置yum仓库

[root@centos6 ~]# vim /etc/yum.repos.d/baes.repo[base]name=guobaseurl=ftp://192.168.27.129/pub/centos/$releasever/os/$basearch/gpgcheck=0
  • 上面的变量代表含义
    • $releasever :当前OS版本的发行主版本号
    • $basearch : 基础平架构x86_64
  • 现在我们用 yum repolist 查一下能看到仓库名不
[root@centos6 ~]# yum repolistLoaded plugins: fastestmirror, refresh-packagekit, securityDetermining fastest mirrorsbase                                                      | 4.0 kB     00:00     base/primary_db                                           | 4.7 MB     00:00     repo id                                repo name                           statusbase                                   guo                                 6,706repolist: 6,706
  • 现在我们用yum装一个软件
[root@centos6 ~]# yum repolist这样就成功了。

关于yum排错失误

  • 首先检查电脑之间是否能够互联
  • 然后检查yum 配置是否正确 (可以用 yum clean all清除一下缓存)
  • 看看防火墙和SELinux等配置是否关闭。