Common configuration methods of yum source

(1) Overview of yum source
  yum needs a yum library, that is, yum source. By default, CentOS has a yum source. There are some default configuration files in the /etc/yum.repos.d/ directory (you can move these files to /opt, or rename them directly under yum.repos.d/).
  First find a yum library (source), and then make sure that there is a client locally (the yum command is the client), and the yum program connects to the server. The connection method is determined by the configuration file. You can modify the settings by editing the /etc/yum.repos.d/CentOS-Base.repo file.
  Open the CentOS-Base.repo file, you can see that the url path is the yum source of CentOS's official website itself, http://mirrorlist.centos.org/?release=releasever&arch=releasever&arch=basearch&repo=os. You can comment out this mirrorlist, and then set the baseurl to the domestic Alibaba Cloud source http://mirrors.aliyun.com/repo/Centos-6.repo, or you can set it to yourself under the premise of using a large number of rpm packages The local file system (mount directory) of the file system, you need to remove the CentOS-Base.repo file and edit the CentOS-Media.repo file.
name=Description#A description, arbitrary.
baseurl=#Set the address of the resource library, you can write Alibaba Cloud or your own yum
ftp://
http://
file:///
enabled={1|0}#enabled=
1Enable local update mode gpgcheck={ 1|0}# gpgcheck=1 means check; gpgcheck=0 may not be checked
gpgkey=#Checked key; if you don’t check this line above, you don’t need to write it.
(2) Yum source configuration method one (Aliyun source)

  1. Install wget
    yum install -y wget

  2. Back up the /etc/yum.repos.d/CentOS-Base.repo file
    cd /etc/yum.repos.d/
    mv CentOS-Base.repo CentOS-Base.repo.back

  3. Download Alibaba Cloud's
    CentOS- 6.repo file wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

  4. Reload yum
    yum clean all
    yum makecache
    (three) yum source configuration method two (local mount directory)

  5. Download the iso file
      Download the full version of the iso file of CentOS from the official website of CentOS and upload it to the Linux file system, such as /opt/tools/.

  6. Create a mount directory    creates a directory
      for mounting iso files.
    mkdir /mnt/vcdrom

  7. Mount    mount
      the iso file to the mount directory.
    mount -o loop -t iso9660 /opt/tools/CentOS-6.7-x86_64-bin-DVD1.iso /mnt/vcdrom

  8. Remove or backup the Centos-Base.repo file
    cd /etc/yum.repos.d/
    mv Centos-Base.repo Centos-Base.repo.back

  9. Edit the Centos-Media.repo file
    vim /etc/yum.repos.d/Centos-Media.repo
    name=CentOS-$releasever-Media
    baseurl=file:///mnt/vcdrom/#Modify baseurl to DVD mount Directory
    gpgcheck=1
    enabled=1#Enable local update mode

  10. Reload yum
    yum clean all
    yum makecache

  11. Write a script and automatically mount
      it at boot    First, write a script.
    vim /opt/shell/mymount.sh
    #!/bin/bash

mount -o loop -t iso9660 /opt/tools/CentOS-6.7-x86_64-bin-DVD1.iso /mnt/vcdrom
  Next, modify the script execution permissions.
chmod 777 /opt/shell/mymount.sh
  Again, modify the /etc/rc.local configuration file.
vim /etc/rc.local
  add the following
/opt/shell/mymount.sh to the last line of the file
  . Finally, restart the machine to test.
init 6
(four) yum source configuration method three (remote mounting directory)

  1. Server configuration
      First, install nfs-utils and rpcbind.
    yum -y install nfs-utils rpcbind
      Second, set the boot service.
    chkconfig nfs on
    chkconfig rpcbind on
      Third, start related services.
    systemctl start rpcbind #Need to start rpcbind first
    systemctl start nfs
      Fourth, create a shared directory.
    mkdir -p /mnt/vcdrom/
      Fifth, edit the /etc/exports file and add the following content.
    vi /etc/exports
    /mnt/vcdrom/ 192.168.94.5 (rw, async, no_root_squash, no_subtree_check)   
      Note: Configuration file description: /mnt/vcdrom/ is a shared directory, using absolute path. For 192.168.94.5(rw,no_root_squash,no_all_squash,sync) is the client's address and authority. The address can be a network segment, an IP address or a domain name. The domain name supports wildcards, such as *youxia.com.
      Permission description: rw: read-write, readable and writable; ro: read-only, read-only; sync: files are written to hard disk and memory at the same time; async: files are temporarily stored in memory instead of directly written to memory; no_root_squash: NFS If the client uses root when connecting to the server, it also has root privileges for the directories shared by the server. Obviously it is not safe to turn on this item. root_squash: If root is used when the NFS client connects to the server, it has anonymous user permissions for the directory shared by the server. Usually he will use the identity of nobody or nfsnobody; all_squash: no matter when the NFS client connects to the server What user is used, the directory shared by the server has anonymous user permissions; anonuid: the UID value of the anonymous user, usually nobody or nfsnobody, which can be set here; anongid: the GID value of the anonymous user.
      Sixth, refer to the second method of yum source configuration, mount the ios file under /opt/tools/ to /mnt/vcdrom, and you need to set up automatic mounting at boot.
  2. Client configuration
      First, install nfs-utils and rpcbind.
    yum install -y nfs-utils rpcbind
      Second, set the boot service.
    systemctl enable nfs
    ssytemctl enable rpcbind
      Third, start the service.
    systemctl start nfs
    ssytemctl start rpcbind
      Fourth, create a mount point.
    mkdir -p /mnt/vcdrom/
      Fifth, mount the directory.
    mount -t nfs server_ip:/mnt/vcdrom /mnt/vcdrom
      Sixth, edit /etc/fstab, configure automatic mounting at boot
      Here you can refer to the introduction of yum source configuration method two, write a script, and make the script start up and run. The second method is given below:
    vim /etc/fstab
    server_ip:/mnt/vcdrom /mnt/vcdrom nfs rw,tcp,intr 0 1

(5) Introduction to yum commands and
List of Commands:

check Check for RPM database problems
check-update Check if there is a software package available update
clean Delete cache data
deplist List the dependencies of the software package
distribution-synchronization The software package has been synchronized to the latest available version
downgrade The software package
erase is removed from the system Or multiple packages
fs Acts on the filesystem data of the host, mainly for removing docs/lanuages ​​for minimal hosts.
fssnapshot Creates filesystem snapshots, or lists/deletes current snapshots.
groups display or use, group information
help display usage prompt
history display Or use transaction history
info to display detailed information about a package or group
install Install one or more packages into the system
list List one or a group of packages
load-transaction Load a stored transaction from the file name
makecache Create metadata Cache
provides find packages that provide specified content.
reinstall. Overwrite installation packages.
repo-pkgs treats a source as a package group so that we can install/remove all packages at once.
repolist Display the configured source
search Search for the specified string in the package details
shell Run interactive yum shell
swap Simple way to swap packages, instead of using shell
update Update one or more packages in the system
update-minimal Works like upgrade, but goes to the'newest' package match which fixes a problem that affects your system
updateinfo Acts on repository update information
upgrade. Update the software package and consider the software package replacement relationship.
version shows the machine and/or available source version.

(6) How to install software using epel source?
For example, I want to view cacti information

yum --enablerepo = epel info cacti

IT network, http://www.it.net.cn
installation, execute the following command:

yum --enablerepo=epel install cacti

Note: Epel's configuration file is in /etc/yum.repos.d/epel.repo.

(7) How to check whether epel is installed successfully?
Use the following command:

yum repolist

输出如下
[root@test ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

  • base: mirrors.yun-idc.com
  • epel: ftp.sjtu.edu.cn
  • extras: mirrors.yun-idc.com
  • updates: mirrors.yun-idc.com
    repo id repo name status
    base/7/x86_64 CentOS-7 - Base 8,465
    epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 5,036
    extras/7/x86_64 CentOS-7 - Extras 30
    updates/7/x86_64 CentOS-7 - Updates 423
    repolist: 13,954
    [root@Lixiaolong ~]#

Guess you like

Origin blog.csdn.net/smileui/article/details/103247519