Article Directory
Preface
In the CentOS7 system, only software warehouses are built and used to realize standardized management of network-based software package installation, update, and uninstallation, and deploy NFS servers in the local area network.
1. Deploy YUM Warehouse Service
1. Build YUM software warehouse
(1) Overview of YUM
The predecessor of YUM is YUP (Yellow dog Updater, software updater for Yellow dog Linux). It was originally developed by TSS using Python language, and later improved by the Linux development team of Duke University, named YUM (Yellow dog Updater Modified). ).
With the help of YUM software warehouse, tasks such as installation, downloading, and automatic upgrade of rpm packages can be completed, and the dependencies between rpm packages can be automatically found and resolved, without the need for an administrator to manually install each rpm package one by one, so that management It is easier to maintain a large number of Linux servers. Especially in a local network with a large number of Linux hosts, building a source server can greatly ease the dependence on the Internet such as software installation and upgrades.
(2) Prepare network installation source (server side)
How to provide software warehouse:
- FTP service: ftp: //...
- HTTP service: http://...
- Local directory: file://...
RPM package source:
- A collection of RPM packages released by CentOS
- A collection of RPM packages released by third-party organizations
- User-defined RPM package collection
2. Use yum tools to manage software packages
(1) Overview of yum tool
About yum command
- Provided by package yum-...
- Used to access YUM warehouse, query, download and install, uninstall software packages
yum configuration file
- Basic settings: /etc/yum.conf
- Warehouse settings: /etc/yum.repos.d/*.repo
- Log file: /var/log/yum.log
yum cache directory
(2) Query software package
Query package list
yum list 【软件名】
Query the description information of the software package
yum info 【软件名】
Query the specified package
yum search <关键词>
What package group the query command belongs to
yum whatprovides <命令>
Query package group information
yum grouplist
yum groupinfo
(3) Install, upgrade and uninstall software packages
install software
yum install [软件名]
yum groupinstall <包组名>
Upgrade software
yum update
yum groupdate
yum update 更新软件包,连内核一起更新
yum upgrade 只更新软件包,但不更新内核
Uninstall software
yum remove <软件名>…
yum groupremove <包组名>…
2. NFS shared storage service
NFS is a network file system protocol based on TCP/IP transmission, originally developed by Sun. By using the NFS protocol, the NFS client can access the shared resources in the remote NFS server like a local directory. For most load balancing clusters, it is a common practice to use the NFS protocol to share data storage. NFS is also a protocol that NAS storage devices must support. However, NFS does not have a user authentication mechanism, and data is transmitted in clear text on the network, so the security is very poor, and it can generally only be used in a local area network.
1. Use NFS to publish resources
NFS (Network File System) network file system
- Rely on RPC (remote procedure call)
- Need to install nfs-utils, rpcbind package
- System service: nfs, rpcbind
- Shared configuration file: /etc/exports
2. Access NFS shared resources in the client
The purpose of the NFS protocol is to provide a network file system, so access to NFS shares is also mounted with the mount command, and the corresponding file system type is nfs. Either you can receive the mount, or you can add the fstab configuration file to automatically mount it at boot.
Three, experiment
Experiment 1: Deploy the YUM warehouse
Start: Both 20.0.0.110 and 20.0.0.111 need to
turn off the firewall
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalled
Turn off the kernel protection
[root@localhost ~]# vi /etc/selinux/config
SELINUX=disabled
[root@localhost ~]# init 6
[root@localhost ~]# setenforce?
Mount the CD
[root@localhost ~]# mount /dev/cdrom /mnt
20.0.0.110 Build centos7 software warehouse
[root@localhost ~]# mkdir -p /var/ftp/centos7
[root@localhost ~]# cp -rf /mnt/* /var/ftp/centos7
[root@localhost ~]# rpm -ivh /mnt/Packages/vsftpd-3.0.2-22.el7.x86_64.rpm
[root@localhost ~]# systemctl start vsftpd
[root@localhost ~]# systemctl enable vsftpd
[root@localhost ~]# mkdir /var/ftp/other
[root@localhost ~]# cd /var/ftp/other
[root@localhost other]# createrepo -g /mnt/repodata/repomd.xml ./
createrepo may not be installed, you need to download yum -y install createrepo
webpage input: ftp://20.0.0.110 you can view the file
20.0.0.111 Specify the YUM warehouse location for the client
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll
[root@localhost yum.repos.d]# mkdir backup
[root@localhost yum.repos.d]# mv C* backup/
[root@localhost yum.repos.d]# cp backup/CentOS-Base.repo centos7.repo
[root@localhost yum.repos.d]# cd backup/
[root@localhost backup]# ll
[root@localhost backup]# cd ..
[root@localhost yum.repos.d]# vi centos7.repo
[centos]
name=CentOS
baseurl=ftp://20.0.0.110/centos7
gpgcheck=0
enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[other]
name=other
baseurl=ftp://20.0.0.110/other
gpgcheck=0
enabled=1
[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum makecache
Experiment 2: Use NFS to publish shared resources
20.0.0.110.
Install nfs-utils and rpcbind software packages in the server
[root@localhost ~]# yum -y install nfs-utils rpcbind
[root@localhost ~]# systemctl enable nfs
[root@localhost ~]# systemctl enable rpcbind
Set up a shared directory
[root@localhost ~]# mkdir -p /opt/wwwroot
[root@localhost ~]# vi /etc/exports
/opt/wwwroot 20.0.0.0/24(rw,sync,no_root_squash)
Start the NFS service program
[root@localhost ~]# systemctl start nfs
[root@localhost ~]# systemctl start rpcbind
View the local shared NFS directory
[root@localhost ~]# netstat -anpt | grep rpc
[root@localhost ~]# showmount -e
Write data on the client and check whether the data is synchronized on the server
[root@localhost ~]# cd /opt/wwwroot/
[root@localhost wwwroot]# cat index.html
20.0.0.111 in the client
[root@localhost ~]# yum -y install nfs-utils rpcbind
[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl enable rpcbind
[root@localhost ~]# showmount -e 20.0.0.110
Manually mount the NFS shared directory
[root@localhost ~]# mkdir -p /var/www/html
[root@localhost ~]# mount 20.0.0.110:/opt/wwwroot /var/www/html
[root@localhost ~]# tail -1 /etc/mtab
Write data on the client, go to the server to check whether the data is synchronized
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# ll
total 0
[root@localhost html]# vi index.html
welcome come to china1
Permanently mount
[root@localhost ~]# vi /etc/fstab
20.0.0.110:/opt/wwwroot /var/www/html nfs defaults,_netdev 0 0
[root@localhost ~]# init 6
Re-open a client with the same IP,
do not exit
, uninstall at the first client
[root@localhost ~]# umount /var/www/html
Force uninstall
[root@localhost ~]# umount -lf /var/www/html
success