Linux deployment of YUM warehouse and NFS sharing service
table of Contents
1. Overview of YUM
YUM is based on the software update mechanism constructed by RPM packages, which can automatically resolve dependencies. All packages are provided by the centralized YUM software warehouse
Two, prepare the installation source
1. How to provide software warehouse
- FTP service: ftp://……
- HTTP service: http://……
- Local directory: file://……
2. The source of the RPM package
- Collection of RPM packages released by CentOS
- A collection of RPM packages released by third-party organizations
- User-defined RPM package collection
Three, build the CentOS 7 software warehouse
1. The RPM package comes from CentOS7 DVD
2. Provide to the client via FTP
mkdir -p /var/ftp/centos7
cp -rf /dev/cdrom/* /var/ftp/centos7
rpm -ivh /media/cdrom/Packages/vsftpd-3.0.2-21.el7.x86_64.rpm
systemctl start vsftpd
systemctl enable vsftpd
3. Add unofficial RPM charter to the software warehouse
- Include all RPM packages with dependencies
- Use createrepo tool to build warehouse data file
mkdir /var/ftp/other
cd /var/ftp/other————Unofficial RPM must be placed in this directory first
createrepo -g /media/cdrom/repodata/repomd.xml ./
Specify the YUM warehouse location for the client
4. Configuration file: /etc/yum.repos.d/centos7.repo
vim /etc/yum.repos.d/centos7.repo
[base]
name=CentOS 7.3
baseurl = ftp: //192.168.4.20/centos7
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7————Software verification public key
[other]
name=Other RPM Packages
baseurl=ftp://192.168.4.20/other
enable=1
gpgcheck=0
5. About YUM command
- Provided by package yum-3.4.3-150.el7.centos.noarch
- Used to access YUM warehouse, query, download and install and uninstall software packages
6. YUM's configuration file
- Basic settings: /etc/yum.conf
- Warehouse settings: /etc/yum.repos.d/*.repo
- Log file: /var/log/yum.log
7. Local YUM warehouse
Directly use Centos7 CD as software warehouse
- Put the Centos7 CD into the CD-ROM drive
- Mount the image to the warehouse location, the URL address is file:///media/cdrom
vim /etc/yum.repos.d/local.repo
……
[local]
name=CentOS7.3
baseurl = file: /// media / cdrom
enabled=1
gpgcheck=0
8. YUM cache directory
- Store downloaded software packages, warehouse information and other data
- Located in /var/cache/yum/ basearch/basearch/basearch/releasever
yum clean all-clean up cached data
Four, package query
1. Query software package
yum list [software name]
yum info [software name]
yum search <keyword>
yum whatprovides <keyword>
2. Query package group
yum grouplist [package group name]
yum groupinfo <package group name>
3. Install the software
yum install [software name]
yum groupinstall <package group name>
4. Upgrade software
yum update
yum groupupdate
5. Uninstall the software
yum remove <software name>
yum groupremove <package group name>
Five, NFS shared storage service
1. NFS is a network file system protocol based on TCP/IP transmission. By using the NFS protocol, the client can access the shared resources in the remote server the same as the local directory.
2. 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, but because NFS does not have a user authentication mechanism, and the data is in clear text on the network Transmission, so the security is very poor, generally can only be used in the local area network
3. The implementation of the NFS service relies on the RPC (remote procedure call) mechanism to complete the remote-to-local mapping process, so it is necessary to install the nfs-utils and rpcbind software packages to provide NFS sharing services, the former is used for NFS sharing publishing and access , The latter is used for RPC support
4. The configuration file of NFS is /etc/exports
The format is: shared directory location client address (permission option)
Six, NFS deployment
Use NFS to publish shared resources on the file server
1. Install nfs-utils and rpcbind software packages
rpm -q rpcbind nfs-utils
yum -y install nfs-utils rpcbind
2. Set up a shared directory
mkdir -p /opt/abc
chmod 777 /opt/abc
vim /etc/exports
/opt/abc 192.168.241.0/24(rw,sync,no_root_squash)
The client address can be the host name, IP address, network segment address, and wildcard characters "*" and "?" are allowed
The "rw" mark allows reading and writing, and the "ro" means read-only
sync: means synchronously write to memory and hard disk
no_root_squash: Indicates that local root privileges are granted when the client is accessed as root (default is root——squash)
root——squash: means that when the client uses the root user to access the shared directory, the root user is mapped to an anonymous user
Other common options
all_squash: All access users are mapped to anonymous users or user groups
async: save the data in the memory buffer first, and write it to disk when necessary
subtree_check (default): If the output directory is a subdirectory, the nfs server will check the permissions of its parent directory
no_subtree_check: Even if the output directory is a subdirectory, the nfs server will check the permissions of its parent directory
anonuid=xxx: Specify the UID of the anonymous user in the /etc/passwd file of the NFS server
anongid=xxx: Specify the GID of the anonymous user in the /etc/passwd file of the NFS server
3. Start the NFS service program
When manually loading the NFS sharing service, you should start rpcbind first, and then start nfs
systemctl start rpcbind
systemctl start nfs
systemctl enable rpcbind
systemctl enable nfs
netstat -antp | grep rpcbind————查看rpcbind端口是否开启,rpcbind默认使用tcp端口111
4. View the NFS shared directory published by this machine
exportfs -rv————发布共享
showmount -e
Access NFS shared resources in the client
1. Install nfs-utils and rpcbind software packages
rpm -q rpcbind nfs-utils
yum -y install nfs-utils rpcbind
systemctl start rpcbind
systemctl enable rpcbind
2. Check which directories are shared on the NFS server
showmount -e 192.168.241.3
3. Manually mount the NFS shared directory
mkdir /share
mount 192.168.241.3:/opt/abc /share
df -Th——Confirm the mounting result, or mount
Automount
vim /etc/fstab
192.168.241.3:/opt/abc /share nfs defaults,_netdev 0 0—————_netdev: indicates that the device needs a network to mount
4. Forcibly uninstall NFS
If the server-side NFS service suddenly stops while the client is being mounted and used, the df -h command will be stuck on the client. At this time, the umount command cannot be directly uninstalled. You need to add -lf option to uninstall
umount -lf /share