linux中yum配置使用

yum配置使用

網絡yum庫服務搭建

  • 環境:把centos 7當做服務器端,centos6當做客戶端
    首先用鏡像搭建一個本地yum
  • 配置/etc/yum.repo.d/bash.repo 配置文件
[root@centos7 yum.repos.d]# ls
bak  base.repo
  • 如果沒有此文件可以創建一個後綴只要是.repo的就行
  • 我們現在編輯base.repo文件
[base]  庫id
name=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]# ll
total 0
drwxr-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 off
service iptables top
檢查是不是清空了:iptables -nVL 
---------------------------------
[root@centos7 ~]# systemctl stop firewalld
[root@centos7 ~]# systemctl disable firewalld
Removed 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=guo
baseurl=ftp://192.168.27.129/pub/centos/$releasever/os/$basearch/
gpgcheck=0
  • 上面的變量代表含義
    • $releasever :當前OS版本的發行主版本號
    • $basearch : 基礎平架構x86_64
  • 現在我們用 yum repolist 查一下能看到倉庫名不
[root@centos6 ~]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
base                                                      | 4.0 kB     00:00     
base/primary_db                                           | 4.7 MB     00:00     
repo id                                repo name                           status
base                                   guo                                 6,706
repolist: 6,706
  • 現在我們用yum裝一個軟件
[root@centos6 ~]# yum repolist
這樣就成功了。

關於yum排錯失誤

  • 首先檢查電腦之間是否能夠互聯
  • 然後檢查yum 配置是否正確 (可以用 yum clean all清除一下緩存)
  • 看看防火牆和SELinux等配置是否關閉。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章