wordpress官网案例,移动端优化,网站建设编辑,网站这么做优化文件服务器
路漫漫其修远兮#xff0c;吾将上下而求索.构建NFS远程共享存储
一、NFS介绍 文件系统级别共享#xff08;是NAS存储#xff09; --------- 已经做好了格式化#xff0c;可以直接用。 速度慢比如#xff1a;nfs#xff0c;sambaNFS
NFS#xff1a;Networ…文件服务器
路漫漫其修远兮吾将上下而求索.构建NFS远程共享存储
一、NFS介绍 文件系统级别共享是NAS存储 --------- 已经做好了格式化可以直接用。 速度慢比如nfssambaNFS
NFSNetwork File System 网络文件系统NFS 和其他文件系统一样,是在 Linux 内核中实现的因此 NFS 很难做到与 Windows 兼容。NFS 共享出的文件系统会被客户端识别为一个文件系统客户端可以直接挂载并使用。
#NFS 文件系统仅支持基于 IP 的用户访问控制NFS 的客户端主要为Linux。 因为NFS有很多功能不同的功能需要使用不同的端口。因此NFS无法固定端口。而RPC会记录NFS端口的信息这样就能够通过RPC实现服务端和客户端的RPC来沟通端口信息。
那RPC和NFS之间又是如何之间相互通讯的
首先当NFS启动后就会随机的使用一些端口然后NFS就会向RPC去注册这些端口。RPC就会记录下这些端口。并且RPC会开启111端口等待客户端RPC的请求如果客户端有请求那服务端的RPC就会将记录的NFS端口信息告知客户端。 实验环境准备两台机器
支持多节点同时挂载以及并发写入
服务端nfs-server 192.168.246.160
客户端web1 192.168.246.161 centos7服务端和客户端都关闭防火墙和selinux内核防火墙
#systemctl stop firewalld
#systemctl disable firewalld
#setenforce 0 二、实战 NFS-server操作
[rootnfs-server ~]# yum -y install rpcbind #安装rpc协议的包
[rootnfs-server ~]# yum -y install nfs-utils #安装nfs服务。
启动服务
[rootnfs-server ~]# systemctl start nfs
[rootnfs-server ~]# systemctl start rpcbind
[rootnfs-server ~]# mkdir /nfs-dir #创建存储目录
[rootnfs-server ~]# echo nfs-test /nfs-dir/index.html #制作test文件
[rootnfs-server ~]# vim /etc/exports #编辑共享文件
/nfs-dir 192.168.246.0/24(rw,no_root_squash,sync)
可选参数注释
ro只读
rw读写
*:表示共享给所有网段。
sync所有数据在请求时写入共享
root_squash 对于使用分享目录的使用者如果是root用户那么这个使用者的权限将被压缩成为匿名使用者只读权限。
no_root_squash使用分享目录的使用者如果是 root 的话那么对于这个分享的目录来说他就具有 root 的权限。 [rootnfs-server ~]# systemctl restart nfs-server #重启服务。
[rootnfs-server ~]# systemctl enable nfs-server #制作开机启动 web1 客户端操作
[rootweb1 ~]# yum -y install rpcbind
[rootweb1 ~]# yum -y install nfs-utils
[rootweb1 ~]# mkdir /qf #创建挂载点
[rootweb1 ~]# mount -t nfs 192.168.246.160:/nfs-dir /qf #挂载
-t:指定文件系统类型
[rootweb1 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 17G 1.1G 16G 7% /
tmpfs tmpfs 98M 0 98M 0% /run/user/0
192.168.246.160:/nfs-dir nfs4 17G 1.4G 16G 8% /qf
[rootweb1 ~]# ls /qf
index.html
[rootweb1 ~]# umount /qf #取消挂载
制作开机挂载
[rootclient.qfedu.com ~]# vim /etc/fstab
192.168.246.160:/nfs-dir /qf nfs defaults 0 0
[rootclient.qfedu.com ~]# mount -a ftp及lftp 文件传输协议File Transfer ProtocolFTP基于该协议FTP客户端与服务端可以实现共享文件、上传文件、下载、删除文件。FTP服务器端可以同时提供给多人共享使用。 FTP服务是Client/Server简称C/S模式基于FTP协议实现FTP文件对外共享及传输的软件称之为FTP服务器源端客户端程序基于FTP协议则称之为FTP客户端FTP客户端可以向FTP服务器上传、下载文件。
FTP Server
作用提供文件共享服务,实现上传下载
端口
21号建立tcp连接 默认端口
20号传输数据
一、FTP基础
软件包: vsftpd
FTP端口: 控制端口:21/tcp
配置文件: /etc/vsftpd/vsftpd.conf
1. ftp主动模式
ftp主动模式客户端开启一个端口N1023向服务端的21端口建立连接同时开启一个N1告诉服务端我监听的是N1端口服务端接到请求之后用自己的20端口连接到客户端的N1端口进行传输
21端口建立连接
20端口传输数据
2. ftp被动模式 ftp被动模式客户端同时开启两个端口10241025一个端口1024跟服务端的21端口建立连接并请求大哥我连上了你再开一个端口呗。服务端接到请求之后随机会开启一个端口1027并告诉客户端我开启的是1027端口客户端用另一个端口1025与服务端的1027端口进行连接传输数据 二、Vsftp 服务器简介 非常安全的FTP服务进程Very Secure FTP daemonVsftpdVsftpd在Unix/Linux发行版中最主流的FTP服务器程序优点小巧轻快安全易用、稳定高效、满足企业跨部门、多用户的使用1000用户等。
三、vsftpd配置
1. 安装vsftpd[ftp服务端] FTP Server服务端
实验环境--准备两台机器
关闭防火墙和selinux
#systemctl stop firewalld
#systemctl disable firewalld
#setenforce 0ftp-server 192.168.246.160
client 192.168.246.161[rootftp-server ~]# yum install -y vsftpd
[rootftp-server ~]# systemctl start vsftpd
[rootftp-server ~]# systemctl enable vsftpd #FTP默认共享目录/var/ftp
[rootlocalhost ~]# mkdir /var/ftp/upload #创建自己的共享目录
[rootftp-server ~]# touch /var/ftp/upload/test.txt #创建文件到共享目录
[rootftp-server ~]# cd /var/ftp/
[rootftp-server ftp]# ls
pub upload
[rootftp-server ftp]# chown ftp.ftp * -R #修改根目录的属主与属组
[rootftp-server ftp]# ll
total 0
drwxr-xr-x. 2 ftp ftp 22 Aug 3 03:15 pub
drwxr-xr-x. 2 ftp ftp 22 Aug 27 03:15 upload 重点改变根目录的属主如果不改变的话只能访问其他权限不能生效。因为我们是以ftp用户的身份访问的而默认的属主属组是root。 注意
- 修改完配置之后需要重启完服务才能生效
- 还需要从新从客户端登陆否则修改后的配置看不到效果。
2. 编辑配置文件 [rootftp-server ~]# vi /etc/vsftpd/vsftpd.conf ----找到29行将下面的注释取消
30 anon_umask022 #添加匿名用户上传下载目录权限掩码
34 anon_other_write_enableYES [rootftp-server ~]# systemctl restart vsftpd FTP Clinet客户端
关闭防火墙和selinux
[rootclient ~]# yum -y install lftp #安装客户端
get命令下载首先要开启下载功能
[rootclient ~]# lftp 192.168.246.160
lftp 192.168.246.160:~ ls
drwxr-xr-x 2 0 0 6 Oct 30 2018 pub
drwxr-xr-x 2 14 50 6 Oct 30 2018 upload
lftp 192.168.246.160:/ cd upload/
lftp 192.168.246.160:/upload ls
-rw-r--r-- 1 14 50 0 Aug 02 19:14 test.txt
lftp 192.168.246.160:/upload get test.txt #下载
lftp 192.168.246.160:/upload exit
[rootclient ~]# ls #会下载到当前目录
anaconda-ks.cfg test.txt
[rootclient ~]# lftp 192.168.246.160
lftp 192.168.246.160:/upload mkdir dir #也可以创建目录
mkdir ok, dir created
put命令上传命令上传之前请在服务端进行配置将上传功能打开
[rootclient ~]# touch a.txt #创建测试文件
[rootclient ~]# mkdir /test/ #创建测试目录
[rootclient ~]# touch /test/b.txt #在测试目录下面创建测试文件
[rootclient ~]# lftp 192.168.246.160
lftp 192.168.246.160:~ cd upload/
lftp 192.168.246.160:/upload put /root/a.txt #上传文件
lftp 192.168.246.160:/upload ls
-rw------- 1 14 50 0 Nov 16 12:14 a.txt
drwx------ 2 14 50 6 Aug 02 19:17 dir
lftp 192.168.246.160:/upload mirror -R /root/test/ #上传目录以及目录中的子文件
Total: 1 directory, 1 file, 0 symlinks
New: 1 file, 0 symlinks
lftp 192.168.246.160:/upload ls
drwx------ 2 14 50 23 Nov 16 12:18 test
-rw------- 1 14 50 0 Nov 16 12:14 upload.txt
lftp 192.168.246.160:/upload mirror test/ #下载目录
Total: 1 directory, 1 file, 0 symlinks
New: 1 file, 0 symlinks
lftp 192.168.246.160:/upload exit
[rootcllient ~]# ls
anaconda-ks.cfg a.txt test
[rootclient ~]# cd test/
[rootclient test]# ls
b.txt 3. ftp配置本地用户登录 创建测试用户 创建 zhangsan、lisi 密码都设置为 “123456” [rootftp-server ~]# useradd zhangsan
[rootftp-server ~]# useradd lisi
[rootftp-server ~]# echo 123456 | passwd --stdin zhangsan #设置密码
Changing password for user zhangsan.
passwd: all authentication tokens updated successfully.
[rootftp-server ~]# echo 123456 | passwd --stdin lisi
Changing password for user lisi.
passwd: all authentication tokens updated successfully. 配置本地用户ftp配置文件 [rootftp-server ~]# vim /etc/vsftpd/vsftpd.conf ---添加注释并修改
anonymous_enableNO #将允许匿名登录关闭
#anon_umask022 #匿名用户所上传文件的权限掩码
#anon_upload_enableYES #允许匿名用户上传文件
#anon_mkdir_write_enableYES #允许匿名用户创建目录
#anon_other_write_enableYES #是否允许匿名用户有其他写入权改名删除覆盖
103 chroot_list_enableYES #启用限制登陆用户在主目录里面
104 # (default follows)
105 chroot_list_file/etc/vsftpd/chroot_list #限制登陆的用户在这个文件列表中一行一个用户
106 allow_writeable_chrootYES #允许限制的用户对目录有写权限
新添加
local_root/home/zhangsan # 设置本地用户的FTP根目录一般为用户的家目录
local_max_rate0 # 限制最大传输速率字节/秒0为无限制 重启vsftpd [rootftp-server ~]# vim /etc/vsftpd/chroot_list
zhangsan
[rootftp-server ~]# systemctl restart vsftpd 四、客户端操作 [rootftp-client ~]# lftp 192.168.153.137 -u zhangsan
Password:
lftp zhangsan192.168.153.137:~ ls
lftp zhangsan192.168.153.137:~ mkdir aaa
mkdir ok, aaa created
lftp zhangsan192.168.153.137:~ ls
drwxr-xr-x 2 1000 1000 6 Aug 02 20:55 aaa
lftp zhangsan192.168.153.137:~ put /root/test.txt
lftp zhangsan192.168.153.137:~ ls
drwxr-xr-x 2 1000 1000 6 Aug 02 20:55 aaa
-rw-r--r-- 1 1000 1000 0 Aug 02 20:59 test.txt
服务器端查看
[rootftp-server ~]# cd /home/zhangsan/
[rootftp-server zhangsan]# ls
aaa test.txt
[rootftp-server zhangsan]# ll
total 0
drwxr-xr-x. 2 zhangsan zhangsan 6 Aug 3 04:55 aaa
-rw-r--r--. 1 zhangsan zhangsan 0 Aug 3 04:59 test.txt Linux禁止root用户远程登陆
认识sshd_congfig配置文件
[roottestpm ~]# vim /etc/ssh/sshd_config
#Port 22 #监听端口默认监听22端口 【默认可修改】
#AddressFamily any #IPV4和IPV6协议家族用哪个any表示二者均有
#ListenAddress 0.0.0.0 #指明监控的地址0.0.0.0表示本机的所有地址 【默认可修改】
#ListenAddress :: #指明监听的IPV6的所有地址格式
#LogLevel INFO #日志记录级别默认为info
#LoginGraceTime 2m #登录的宽限时间默认2分钟没有输入密码则自动断开连接
#PermitRootLogin yes #是否允许管理员直接登录yes表示允许实际生产中建议修改为no
#MaxAuthTries 6 #最大认证尝试次数最多可以尝试6次输入密码超过之后断开连接
#MaxSessions 10 #最大允许保持多少个连接。默认值是 10
#PubkeyAuthentication yes #是否开启公钥验证
禁止root用户远程登录
[roottestpm ~]# vim /etc/ssh/sshd_config
37 #LoginGraceTime 2m
38 #PermitRootLogin yes #默认为允许root用户远程登陆
39 #StrictModes yes
进行修改如下
[roottestpm ~]# vim /etc/ssh/sshd_config
37 #LoginGraceTime 2m
38 PermitRootLogin no #将注释打开并将yes修改为no
39 #StrictModes yes
保存退出并重启sshd服务
[roottestpm ~]# systemctl restart sshd 谷歌验证登录
配置本地yum源 [rootlocalhost ~]# yum install -y git automake libtool pam-devel bzip2 wget vim ntpdate 校对时间时间一定要对不然会出大问题 #修改时区
[rootlocalhost ~]# timedatectl set-timezone Asia/Shanghai
#校对时间
[rootlocalhost ~]# ntpdate time.windows.com 下载工具包 [rootlocalhost ~]# wget http://repository.timesys.com/buildsources/l/libpam-google-authenticator/libpam-google-authenticator-1.0/libpam-google-authenticator-1.0-source.tar.bz2 解压 [rootlocalhost ~]# tar -xjvf libpam-google-authenticator-1.0-source.tar.bz2 编译安装 [rootlocalhost ~]# cd libpam-google-authenticator-1.0
[rootlocalhost ~]# make make install 修改ssh服务的配置 [rootlocalhost ~]# echo auth required pam_google_authenticator.so /etc/pam.d/sshd
#修改sshd配置文件
[rootlocalhost ~]# vim /etc/ssh/sshd_config
这个是文件自己有的不需要自己添加ChallengeResponseAuthentication yes
#重启sshd服务
[rootlocalhost ~]# systemctl restart sshd 使用令牌工具生成登录密钥
[rootlocalhost ~]# google-authenticator
google-authenticator
Do you want authentication tokens to be time-based (y/n) y
https://www.google.com/chart?chs200x200chldM|0chtqrchlotpauth://totp/rootlocalhost.localdomain%3Fsecret%3DWLJCY4JSNGQNH454
Your new secret key is: WLJCY4JSNGQNH454
Your verification code is 635811
Your emergency scratch codes are:1826391256060832395718222056963990543013
Do you want me to update your /root/.google_authenticator file (y/n) y
Do you want to disallow multiple uses of the same authentication
token? This restricts you to one login about every 30s, but it increases
your chances to notice or even prevent man-in-the-middle attacks (y/n) y
By default, tokens are good for 30 seconds and in order to compensate for
possible time-skew between the client and the server, we allow an extra
token before and after the current time. If you experience problems with poor
time synchronization, you can increase the window from its default
size of 1:30min to about 4min. Do you want to do so (y/n) y
If the computer that you are logging into isnt hardened against brute-force
login attempts, you can enable rate-limiting for the authentication module.
By default, this limits attackers to no more than 3 login attempts every 30s.
Do you want to enable rate-limiting (y/n) n
使用动态码登录服务器WindTerm不行finalshell可以 然后重新登陆即可需要下载一个谷歌验证器app就有验证码 补充
ftp和http区别 FTPFile Transfer Protocol文件传输协议和HTTPHypertext Transfer Protocol超文本传输协议是两种在计算机网络中常用的协议它们的主要区别体现在以下几个方面 定义和用途FTP主要被用于文件传输特别是在两台计算机之间互相传送文件。无论是上传文件还是下载文件FTP都是非常适用的协议。而HTTP则主要是为网页浏览设计的它用于从服务器读取Web页面内容使得用户可以通过浏览器浏览和交互网页。运作方式FTP使用两个TCP连接一个是命令链路用于在FTP客户端与服务器之间传递命令另一个是数据链路用于上传或下载数据。而HTTP协议则是基于请求/响应范式的通常是在用户代理和源服务器之间通过一个单独的连接来完成。时效性和连接方式FTP具有较高的延时并且可能需要执行冗长的登录进程。相比之下HTTP的连接是实时的即使存在延时也是非常细微的差距。安全性FTP在传输文件时并不提供加密功能因此传输的数据可能会被第三方截获。而HTTP虽然本身也不提供加密但可以通过HTTPSHTTP Secure协议实现加密传输确保数据的安全性。控制信息的传送方式FTP的控制信息是带外out-of-band传送的即控制信息和数据信息的传输是分开的。而HTTP的控制信息是带内in-band传送的即在同一个TCP连接中既发送请求和响应首部行也传输实际的数据。状态管理FTP服务器在整个会话期间需要保留用户的状态信息而HTTP是无状态的每个请求都是独立的。 综上所述FTP和HTTP各有其特点和适用场景用户应根据具体需求选择适当的协议。FTP适用于大量数据的传输和文件管理而HTTP则更适合用于浏览和交互式的Web应用。 绿色的还是关闭的大概率是个工具是正常的
showmount -e 1912.42.45.11
看有没有可以挂载的nfs
showmount -a 刷新配置 放到后台跳过这个选项确保客户端正常运行。