日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux本地网络软件仓库搭建

發布時間:2023/12/14 linux 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux本地网络软件仓库搭建 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

    • 1.網絡環境的搭建
      • (1)本地主機網絡搭建
        • 新建網卡
        • 修改網卡ip
      • (2)遠程主機網絡搭建
        • 遠程主機網絡設置
        • 測試連接外網主機
    • 2.本地軟件倉庫的搭建
        • 創建掛載目錄并掛載
        • 編寫軟件倉庫文件
        • westos.repo文件內容
    • 3.網絡軟件倉庫的搭建
        • 安裝軟件
        • 打開防火墻
        • 建立共享目錄&重新掛載
        • 更改westos.repo內容
        • 設置開機自動掛載
    • 4.第三方軟件倉庫搭建
        • westos.repo添加文件內容
    • 5.在遠程主機中訪問資源并書寫repo文件
        • 寫入repo文件
        • 安裝epel擴展源
        • 安裝yumdownloader
        • 在本地主機下載ansible及其依賴
        • 在遠程主機下載安裝ansible
        • 查看ansible安裝版本

1.網絡環境的搭建

(1)本地主機網絡搭建

新建網卡

修改網卡ip

[root@localhost Desktop]# nm-connection-editor

[root@localhost Desktop]# nmcli connection reload [root@localhost Desktop]# nmcli connection up ens224 [root@localhost Desktop]# ip a

ip及網關已經設置

(2)遠程主機網絡搭建

[root@localhost Desktop]# nm-connection-editor


# 自動ip獲取(DHCP)

遠程主機網絡設置

#!/bin/bash cd /run/media/root/RHEL-8-2-0-BaseOS-x86_64/BaseOS/Packages/# 安裝dhcp-server rpm -ivh dhcp-server-4.3.6-40.el8.x86_64.rpm # cp /usr/share/doc/dhcp-server/dhcpd.conf.example /etc/dhcp/dhcpd.conf# 將配置文件覆蓋寫入dhcp.conf# 將配置文件覆蓋寫入dhcp.conf # 文件寫入開始cat >/etc/dhcp/dhcpd.conf << EOF# dhcpd.conf # # Sample configuration file for ISC dhcpd ## option definitions common to all supported networks... option domain-name "westos.westos.org"; option domain-name-servers 114.114.114.114;default-lease-time 600; max-lease-time 7200;# Use this to enble / disable dynamic dns updates globally. #ddns-update-style none;# If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. #authoritative;# Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7;# No service will be given on this subnet, but declaring it helps the # DHCP server to understand the network topology.# This is a very basic subnet declaration.subnet 172.25.254.0 netmask 255.255.255.0 { # 子網設定range 172.25.254.50 172.25.254.70; # 分配ip地址范圍option routers 172.25.254.250; # 網關 }EOF# 重啟DHCP systemctl restart dhcpd
#重啟網絡 [root@localhost Desktop]# nmcli connection reload [root@localhost Desktop]# nmcli connection up ens160

獲取到的ip屬于分配的地址池

[root@localhost Desktop]# ip a

測試連接外網主機

2.本地軟件倉庫的搭建

創建掛載目錄并掛載

mkdir /rhel8.2 mount /dev/cdrom /rhel8.2

編寫軟件倉庫文件

cd /etc/yum.repos.d/ # 軟件源指向文件配置目錄 [root@localhost rhel8.2]# vim /etc/yum.repos.d/westos.repo #軟件倉庫指向文件

westos.repo文件內容

[AppStream] name = Appstream baseurl = file:///rhel8.2/AppStream gpgcheck = 0 enabled = 1 gpgkey = file:///etc/pki/rpm-gpg/PRM-GPG-KEY-redhat-release[BaseOS] name = BaseOS baseurl = file://rhel8.2/BaseOS gpgcheck = 0 enabled = 1 gpgkey = file:///etc/pki/rpm-gpg/PRM-GPG-KEY-redhat-release

3.網絡軟件倉庫的搭建

安裝軟件

dnf install httpd -y

打開防火墻

[root@localhost rhel8.2]# systemctl enable --now httpd [root@localhost rhel8.2]# firewall-cmd --permanent --add-service=http success [root@localhost rhel8.2]# firewall-cmd --reload success

建立共享目錄&重新掛載

mkdir /var/www/html/rhel8.2 umount /rhel8.2 mount /dev/cdrom /var/www/html/rhel8.2

更改westos.repo內容

[root@localhost Desktop]# vim /etc/yum.repos.d/westos.repo [root@localhost Desktop]# cat /etc/yum.repos.d/westos.repo [AppStream] name = Appstream baseurl = file:///var/www/html/rhel8.2/AppStream gpgcheck = 0 enabled = 1 gpgkey = file:///etc/pki/rpm-gpg/PRM-GPG-KEY-redhat-release[BaseOS] name = BaseOS baseurl = file:///var/www/html/rhel8.2/BaseOS gpgcheck = 0 enabled = 1 gpgkey = file:///etc/pki/rpm-gpg/PRM-GPG-KEY-redhat-release

設置開機自動掛載

[root@localhost Desktop]# vim /etc/rc.d/rc.local ## 添加內容 mount /dev/cdrom /var/www/html/rhel8.2 ## 打開文件權限 [root@localhost Desktop]# chmod +x /etc/rc.d/rc.local

4.第三方軟件倉庫搭建

# 建立目錄 mkdir /var/www/html/software

把所有的第三方軟件存放到/software中
/software中只能存在rpm類型的文件,壓縮包是不能使用dnf管理的
采集第三方軟件數據生成repodate目錄

dnf install createrepo -y安裝采集工具 cd /software進入到目錄 createrepo . 對目錄中進行掃描生成repodate數據目錄 cretaerepo -v 指定目錄

westos.repo添加文件內容

vim /etc/yum.repos.d/westos.repo [software] name=software baseurl=http://172.25.254.50/software gpgcheck=0

5.在遠程主機中訪問資源并書寫repo文件

寫入repo文件

[root@localhost Desktop]# vim /etc/yum.repos.d/westos.repo [root@localhost Desktop]# cat /etc/yum.repos.d/westos.repo [AppStream] name=AppStream baseurl=http://172.25.254.50/rhel8.2/AppStream/ gpgcheck=0[BaseOS] name=BaseOS baseurl=http://172.25.254.50/rhel8.2/BaseOS/ gpgcheck=0[software] name=software baseurl=http://172.25.254.50/software gpgcheck=0

連接本地主機,訪問軟件資源

安裝epel擴展源

rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

安裝yumdownloader

查看安裝文件
dnf whatprovides yumdownloader

安裝yum-utils-4.0.12-3.el8.noarch

在本地主機下載ansible及其依賴

yumdownloader #下載軟件包到本機指定位置
yumdownloader httpd #下載倉庫中指定軟件的安裝包到當前目錄
yumdownloader --destdir=/mnt #下載倉庫中指定軟件的安裝包到指定/mnt目錄
yumdownloader httpd --destdir=/mnt --resolve #下載倉庫中指定軟件安裝包和軟件依賴性到/mnt目錄

下載并掛載到sofrware

[root@localhost Desktop]# yumdownloader ansible --destdir=/var/www/html/ansible --resolve

在遠程主機下載安裝ansible

[root@localhost Desktop]# dnf install ansible -y

查看ansible安裝版本

[root@localhost Desktop]# ansible --version

總結

以上是生活随笔為你收集整理的Linux本地网络软件仓库搭建的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。