案例一:将一个地方里的所有差异数据同步到另一个地方
# rsync -avDogp <source directory>/* <target directory>
案例二:将一个地方里的所有差异数据同步到另一个地方,并且被同步的地方有的数据而原地方没有的数据都将被删除
# rsync -avDogp --delete <source directory>/* <target directory>
	# rsync -avDogp <source directory>/* <target directory>
# rsync -avDogp --delete <source directory>/* <target directory>
	纪念:站主于 2020 年 6 月完成了此开源实验,并将过程中的所有命令经过整理和注释以后,形成以下教程
服务端 192.168.101.10
客户端 192.168.101.11
1) 服务器提供 NFS 服务将自己的目录分享
2) 客户端挂载和使用 NFS 服务将服务端分享的目录挂载在自己的目录上
1) 所有服务器的系统都需要是 CentOS 8 版本
2) 所有服务器都要关闭防火墙
3) 所有服务器系统都要配置好可用的软件源
4) 需要按照拓扑图给对应的服务器配置好 IP 地址和主机名
5) 所有服务器都要可以相互 ping 通自己和对方的 IP 地址和主机名
(分别在服务端和客户端上执行以下步骤)
# yum -y install rpcbind nfs-utils
(分别在服务端和客户端上执行以下步骤)
# systemctl enable nfs-server
(分别在服务端和客户端上执行以下步骤)
# systemctl start nfs-server
(只在服务端上执行以下步骤)
# mkdir /nfsshare
(只在客户端上执行以下步骤)
# mkdir /autofs
(只在服务端上执行以下步骤)
# vim /etc/exports
添加以下内容:
......
/nfsshare 192.168.101.0/24(rw,sync,no_root_squash,no_subtree_check)
(补充:这里的 192.168.101.0.24 是客户端的 IP 地址所在的网段)
(只在服务端上执行以下步骤)
# exportfs -a
(只在客户端上执行以下步骤)
# yum -y install autofs
(只在客户端上执行以下步骤)
# systemctl enable autofs
(只在客户端上执行以下步骤)
# vim /etc/auto.master
将以下内容:
......
#
/misc   /etc/auto.misc
#
......
修改为:
......
/misc   /etc/auto.misc
/autofs /etc/auto.autofs
......
(补充:在这里指定了 /etc/auto.autofs 为 Autofs 的从配置文件,并且将 autofs 的主目录设置为 /autofs)
(只在客户端上执行以下步骤)
# cp /etc/auto.misc /etc/auto.autofs
# vim /etc/auto.autofs
将以下内容:
......
cd              -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
......
修改为:
......
cd              -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
directory01             -fstype=nfs,rw 192.168.101.10:/nfsshare
......
(补充:在这里指定了 Autofs 的次级目录为 directory01,即:/autofs/directory01)
(只在客户端上执行以下步骤)
# systemctl restart autofs
(只在客户端上执行以下步骤)
# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        957M     0  957M   0% /dev
tmpfs           971M     0  971M   0% /dev/shm
tmpfs           971M   17M  954M   2% /run
tmpfs           971M     0  971M   0% /sys/fs/cgroup
/dev/vda1        10G  1.6G  8.5G  16% /
tmpfs           195M     0  195M   0% /run/user/0
(只在客户端上执行以下步骤)
# cd /autofs/directory01
(只在客户端上执行以下步骤)
# df -h
Filesystem                Size  Used Avail Use% Mounted on
devtmpfs                  957M     0  957M   0% /dev
tmpfs                     971M     0  971M   0% /dev/shm
tmpfs                     971M   17M  955M   2% /run
tmpfs                     971M     0  971M   0% /sys/fs/cgroup
/dev/vda1                  10G  1.6G  8.5G  16% /
tmpfs                     195M     0  195M   0% /run/user/0
192.168.101.10:/nfsshare   10G  1.6G  8.5G  16% /autofs/directory01
(补充:在进入到 Autofs 自动挂载的目录后,自动挂载就在系统中自动出现了)
1) h 以方便人类阅读的方式进行显示
2) s 将所有文件的大小进行相加
# du -s
或者:
# du -s
# du -sh
或者:
# du -sh *
# du -h <directory>
或者:
# du -h <directory>/*
# du -h <file>
# du -h --max-depth=1
# du -sm
或者:
# du -sm *
# du -sg
或者:
# du -sg *
	?
*
[<character><character><character>]
或者:
{<character>,<character>,<character>}
[^<character><character><character>]
或者:
[!<character><character><character>]
{<head character>...<tail character>}
# touch {a..b}{1..3}.txt
# ls
a1.txt  a2.txt  a3.txt  b1.txt  b2.txt  b3.txt
# cd /tmp
# tar -zcvf /home/zhumingyu/all.tar.gz .[!.]* *
	# cd <directory>
# cd
或者:
# cd ~
# cd -
# cd .
# cd ..