Deploy YUM warehouse and NFS sharing service

YUM warehouse

YUM overview

YUM(Yellow dog Updater Modified)

  • Software update mechanism based on RPM package
  • Can resolve dependencies automatically
  • All software packages are provided by a centralized YUM software warehouse

Prepare the installation source

How to provide software warehouse

FTP service: ftp://...
HTTP service: http://...local
directory: file://...

The source of the RPM package

A collection of RPM packages released by CentOS A collection of RPM packages released by a
third-party organization A collection of
user-defined RPM packages

Overview of YUM tools

YUM configuration file

Basic setting: /etc/yum.conf
warehouse setting: /etc/yum.repos.d/*.repo
log file: /var/log/yum.log

YUM command collection

Query software package
yum list [software name]
yum info [software name]
yum search <keyword>
yum whatprovides <keyword>

Query package group
yum grouplist [package group name]
yum groupinfo <package group name>

Installing the software
yum install [software name]

Upgrade software
yum update

Uninstall the software
yum remove <software name>

NFS shared storage service

NFS overview

NFS (Network File System)
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 as if it were accessing a local directory.

  • Depends on RPC (Remote Procedure Call)
  • Need to install nfs-utils, rpcbind software package
  • System service: nfs, rpcbind
  • Shared configuration file: /etc/exports

NFS features

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, because NFS does not have a user authentication mechanism, and the data is transmitted in plain text on the network, the security is very poor, and it can only be used in a local area network.

Packages that NFS depends on

The realization of the NFS service relies on the RPC (Remote Process Call) mechanism to complete the remote-to-local mapping process.
Therefore, 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, and the latter is used for RPC support.

The configuration file of NFS is /etc/exports

The format is:
shared directory location client address (permission option)

Experimental configuration

Server publishes shared resources

1. Install the nfs-utils and rpcbind packages

rpm -q rpcbind nfs-utils 
yum -y install nfs-utils rpcbind

Insert picture description here

2. Set up a shared directory

mkdir -p /opt/wwwroot
chmod 777 /opt/wwwroot

Insert picture description here

3. Configure NFS configuration file

vim /etc/exports
/opt/wwwroot 192.168.80.0/24(rw,sync,no_root_squash)
/var/ftp/pub 192.168.4.11(ro) 192.168.4.110(rw)
/share *(rw,sync)

客户机地址可以是主机名、IP 地址、网段地址,允许使用“*”、“?”通配符。
“rw” 表示允许读写,“ro” 表示为只读。
sync :表示同步写入到内存与硬盘中。
no_root_squash : 表示当客户机以root身份访问时赋予本地root权限(默认是root_squash)。
root_squash :表示客户机用root用户访问该共享目录时,将root用户映射成匿名用户。

其它常用选项
all_squash :所有访问用户都映射为匿名用户或用户组。
async :将数据先保存在内存缓冲区中,必要时才写入磁盘。
subtree_check(默认):若输出目录是一个子目录,则nfs服务器将检查其父目录的权限。
no_subtree_check :即使输出目录是一个子目录,nfs服务器也不检查其父目录的权限,这样可以提高效率。

Insert picture description here

4. Start the NFS service program

#手动加载NFS共享服务时,应该先启动rpcbind,再启动nfs
systemctl start rpcbind
systemctl start nfs
systemctl enable rpcbind
systemctl enable nfs

netstat -anpt | grep rpcbind			#查看rpcbind端口是否开启,rpcbind默认使用tcp端口111

Insert picture description here

4. View the NFS shared directory published by this machine

Insert picture description here

Client accesses NFS shared resources

1. Install the nfs-utils and rpcbind software packages to check which directories are shared by the NFS server

Insert picture description here

2. Manually mount the NFS shared directory

Insert picture description here

3. Set up automatic mounting

Insert picture description here

4. Forcibly uninstall NFS

如果服务器端NFS服务突然间停掉了,而客户端正在挂载使用时,在客户端就会出现执行 df -h 命令卡死的现象。这个时候直接使用umount 命令是无法直接卸载的,需要加上 -lf 选项才能卸载。
umount -lf /myshare

Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/Jun____________/article/details/114097980
Recommended