顯示具有 電腦-Linux-Server-Yum Server 標籤的文章。 顯示所有文章
顯示具有 電腦-Linux-Server-Yum Server 標籤的文章。 顯示所有文章

2022年9月14日 星期三

電腦-Centos 如何啟用或停用Yum Repository

Centos 如何啟用或停用Yum Repository

最近在調整Centos的Yum Reository,以前都只會直接去修改設定檔,經人指導後,才發生可以使用command修改。

VM環境

os:



現有支援repository




直接修改設定檔

設定檔目錄 /etc/yum.repos.d/








修改 /etc/yum.repos.d/CentOS-Base.repo,如果要啟用是enable=1,停用是enable=0

使用yum-config-manager
需安裝yum-utils
停用updates,enable=0
檢查repolist,updates已停用
啟用updates,enable=1

以上是永久性停用及啟用。

暫時性的方式可以使用yum --disablerepo=reository commands
正常yum update時使用base、extras、updates
yum update停用base,只更新extras、updates
yum --disablerepo=base update

安裝特定repositry的套件
yum --enablerepo=reository install rpm

補充:
20220915
為加快更新速度可以更改reository設定檔中的url。
mirrorlist註解
#mirrorlist=http://#mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
修改baseurl
baseurl=http://mirror01.idc.hinet.net/centos/$releasever/os/$basearch/



參考資料:
4.Enabling or disabling a repository using Red Hat Subscription Management


















2022年9月13日 星期二

電腦-yum下載rpm及相依性套件安裝


Yum下載rpm及相依性套件安裝

在資安規定要求下,主機無法對外連線,進行yum安裝套件。

查詢後,可以先在可對外的相同版本主機,將rpm套件下載,再傳送到主機上安裝使用。

使用以下指令,下載rpm套件

yum install --downloadonly --downloaddir=/下載目錄 rpm名稱

再使用yum localinstall 安裝


VM環境

OS

yum 版本


先確認確認套件數量-java


下載相關套件,檔案放置於/data/java




yum localinstall java
    安裝數目相同


確認安裝結果,java -version






另外在查詢時,有其它方式,可以參考資料的做法。


參考資料:








2016年11月17日 星期四

電腦 CentOS yum server 建置-對外更新

Yum Server 建置-對外更新


CentOS 7 以最小安裝設定完成,如果無網路對外安裝套件,建罝yum server安裝套件。

新增硬碟(40G)為/data,放置更新檔。

建立更新目錄
mkdir -p /data/centos/7

安裝相關更新套件
yum install yum-utils createrepo

下載套件
cd /data/centos/7
reposync --repoid=updates --repoid=extras --repoid=base

建立索引檔
createrepo /data/centos/7/base/
createrepo /data/centos/7/extras/
createrepo /data/centos/7/updates/


建立網站服務,讓client更新
使用httpd
yum install httpd
systemctl start httpd
systemctl enable httpd

建立更新目錄連結
mkdir -p /var/www/html/centos/7/updates /var/www/html/centos/7/extras/ /var/www/html/centos/7/base/
cd /var/www/html/centos/7/updates && ln -s /data/centos/7/updates/ x86_64 && cd -
cd /var/www/html/centos/7/extras && ln -s /data/centos/7/extras/ x86_64 && cd -
cd /var/www/html/centos/7/base && ln -s /data/centos/7/base/ x86_64 && cd -

建立更新repo
vim /etc/yum.repos.d/local.repo


[local-base]
name=Local Server-base
baseurl=http://192.168.1.72/centos/7/base/x86_64
enabled=1

[local-extras]
name=Local Server-extras
baseurl=http://192.168.1.72/centos/7/extras/x86_64
enabled=1

[local-updates]
name=Local Server-updates
baseurl=http://192.168.1.72/centos/7/updates/x86_64
enabled=1

指定由local更新

yum update --disablerepo="*" --enablerepo="local*"


每月定期更新排程
vi /etc/cron.monthly/repoupdate.sh
#!/bin/sh
cd /data/centos/7
reposync --repoid=updates --repoid=extras --repoid=base
createrepo /data/centos/7/base/
createrepo /data/centos/7/extras/
createrepo /data/centos/7/updates/

chomd +x /etc/cron.monthly/repoupdate.sh


2016年11月16日 星期三

電腦 CentOS yum server建置-使用iso檔

Yum Server建置-使用iso檔


CentOS 7 以最小安裝設定完成,如果無網路對外安裝套件,使用安裝iso檔建罝yum server安裝。

本機
1.掛載iso檔
  a.在vmware環境下,光碟機先掛載iso檔,不用上傳至主機。
     ls -l /dev/cdrom
     mount /dev/cdrom /mnt
  b.直接上傳iso檔至主機,將iso檔掛載至/mnt。
     mount -o loop,ro CentOS-7-x86_64-Everything-1511.iso /mnt/cdrom

2.新增local.repo
    vim /etc/yum.repos.d/local.repo
    [local]
    name=Local ISO
    baseurl=file:///mnt/cdrom
    gpgcheck=0
    enabled=1

3.指定由local更新
   yum update --disablerepo="*" --enablerepo="local"
   指定由local安裝httpd
   yum install --disablerepo="*" --enablerepo="local" httpd
   
其它主機可以經由http或ftp協定更新

a.使用httpd
   yum install --disablerepo="*" --enablerepo="local" httpd
   指定路徑
   cd /var/www/html
   ln -sf /mnt
   啟用httpd
   systemctl start httpd
   systemctl enable httpd


b.使用vsftpd
   yum install --disablerepo="*" --enablerepo="local" vsftpd
   修改登匿名者登入目錄
   echo 'anon_root=/mnt' >> /etc/vsftpd/vsftpd.conf
   啟用httpd
   systemctl start vsftpd
   systemctl enable vsftpd

c.新增local.repo,看要http或ftp。
    vim /etc/yum.repos.d/local.repo
    [local]
    name=Local ISO
    baseurl=http://192.168.1.72/mnt
    baseurl=ftp://192.168.1.72/
    gpgcheck=0
    enabled=1

3.指定由local更新
   yum update --disablerepo="*" --enablerepo="local"
   指定由local安裝httpd
   yum install --disablerepo="*" --enablerepo="local" httpd