一, 了解一下
1.NFS
NFS(Network File System)即网络文件系统, 是 FreeBSD 支持的文件系统中的一种, 它允许网络中的计算机之间通过 TCP/IP 网络共享资源. 在 NFS 的应用中, 本地 NFS 的客户端应用可以透明地读写位于远端 NFS 服务器上的文件, 就像访问本地文件一样.
好处:
节省本地存储空间, 将常用的数据存放在一台 NFS 服务器上且可以通过网络访问, 那么本地终端将可以减少自身存储空间的使用.
用户不需要在网络中的每个机器上都建有 Home 目录, Home 目录可以放在 NFS 服务器上且可以在网络上被访问使用.
一些存储设备如软驱, CDROM 和 Zip(一种高储存密度的磁盘驱动器与磁盘)等都可以在网络上被别的机器使用. 这可以减少整个网络上可移动介质设备的数量.
.
.
2.Samba
Samba 是在 Linux 和 UNIX 系统上实现 SMB 协议的一个免费软件, 由服务器及客户端程序构成. SMB(Server Messages Block, 信息服务块)是一种在局域网上共享文件和打印机的一种通信协议, 它为局域网内的不同计算机之间提供文件及打印机等资源的共享服务. SMB 协议是客户机 / 服务器型协议, 客户机通过该协议可以访问服务器上的共享文件系统, 打印机及其他资源. 通过设置 "NetBIOS over TCP/IP" 使得 Samba 不但能与局域网络主机分享资源, 还能与全世界的电脑分享资源.
好处:
- [root@linuxview ~]# vim /etc/exports
- [root@linuxview ~]# cat /etc/exports
- /server/source 192.168.0.0/16(rw,no_root_squash,sync)
- [root@linuxview ~]# systemctl restart nfs
- [root@linuxview ~]# cd /server/source/
- [root@linuxview source]# touch linuxview.txt
- [root@linuxview source]# echo hello>> linuxview.txt
- [root@linuxview source]# ls
- linuxview.txt
- [root@linuxview source]# systemctl status nfs
- Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
- Active: active (exited) since Thu 2018-09-13 22:36:14 CST; 6s ago
- Process: 2695 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)
- Process: 2692 ExecStopPost=/usr/sbin/exportfs -au (code=exited, status=0/SUCCESS)
- Process: 2690 ExecStop=/usr/sbin/rpc.nfsd 0 (code=exited, status=0/SUCCESS)
- Process: 2715 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
- Process: 2708 ExecStartPre=/bin/sh -c /bin/kill -HUP `cat /run/gssproxy.pid` (code=exited, status=0/SUCCESS)
- Process: 2707 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
- Main PID: 2715 (code=exited, status=0/SUCCESS)
- CGroup: /system.slice/nfs-server.service
- Sep 13 22:36:14 linuxview systemd[1]: Starting NFS server and services...
- Sep 13 22:36:14 linuxview systemd[1]: Started NFS server and services.
- [root@linuxview source]#
- [root@web2 ~]# showmount -e 192.168.1.9
- Export list for 192.168.1.9:
- /server/source 192.168.0.0/16
- [root@web2 ~]# df
- Filesystem 1K-blocks Used Available Use% Mounted on
- /dev/mapper/centos-root 17811456 2445572 15365884 14% /
- devtmpfs 1919556 0 1919556 0% /dev
- tmpfs 1931784 4 1931780 1% /dev/shm
- tmpfs 1931784 11824 1919960 1% /run
- tmpfs 1931784 0 1931784 0% /sys/fs/cgroup
- /dev/sda1 1038336 145092 893244 14% /boot
- tmpfs 386360 0 386360 0% /run/user/0
- [root@web2 ~]# mount -t nfs 192.168.1.9:/server/source /mnt/
- [root@web2 ~]# df
- Filesystem 1K-blocks Used Available Use% Mounted on
- /dev/mapper/centos-root 17811456 2445592 15365864 14% /
- devtmpfs 1919556 0 1919556 0% /dev
- tmpfs 1931784 4 1931780 1% /dev/shm
- tmpfs 1931784 11828 1919956 1% /run
- tmpfs 1931784 0 1931784 0% /sys/fs/cgroup
- /dev/sda1 1038336 145092 893244 14% /boot
- tmpfs 386360 0 386360 0% /run/user/0
- 192.168.1.9:/server/source 17811456 2445312 15366144 14% /mnt
- [root@web2 ~]# cd /mnt/
- [root@web2 mnt]# ls
- linuxview.txt
- [root@web2 mnt]# cat linuxview.txt
- hello
- [root@web2 mnt]#
- [root@linuxview ~]# iptables -L
- Chain INPUT (policy ACCEPT)
- target prot opt source destination
- Chain FORWARD (policy ACCEPT)
- target prot opt source destination
- Chain OUTPUT (policy ACCEPT)
- target prot opt source destination
- [root@linuxview ~]# uname -a
- Linux linuxview 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
- [root@linuxview ~]# getenforce
- Disabled
- [root@linuxview ~]# yum install -y samba samba-client samba-swat
- [root@linuxview ~]# useradd linuxview
- [root@linuxview ~]# smbpasswd -a linuxview
- New SMB password:
- Retype new SMB password:
- Added user linuxview.
- [root@linuxview ~]# vim /etc/samba/smb.conf
- [smbshare]
- comment = share
- path = /server/data
- browseable = yes
- writable = yes
- available = yes
- admin users = linuxview
- valid users = linuxview
- public = yes
- [root@linuxview ~]# mkdir -p /server/data
- [root@linuxview ~]# systemctl restart smb
- [root@linuxview ~]# systemctl status smb
- Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled)
- Active: active (running) since Sun 2018-09-16 13:57:17 CST; 3s ago
- Main PID: 28641 (smbd)
- Status: "smbd: ready to serve connections..."
- CGroup: /system.slice/smb.service
- Sep 16 13:57:17 linuxview systemd[1]: Starting Samba SMB Daemon...
- Sep 16 13:57:17 linuxview smbd[28641]: [2018/09/16 13:57:17.272004, 0] ../lib/u...y)
- Sep 16 13:57:17 linuxview smbd[28641]: STATUS=daemon 'smbd' finished starting ...ns
- Sep 16 13:57:17 linuxview systemd[1]: Started Samba SMB Daemon.
- Hint: Some lines were ellipsized, use -l to show in full.
- [root@client ~]# smbclient -U linuxview //192.168.1.9/smbshare
- Enter SAMBA\linuxview's password:
- Try "help" to get a list of possible commands.
- smb: \> ls
- . D 0 Sun Sep 16 17:59:15 2018
- .. D 0 Sun Sep 16 13:50:31 2018
- test N 0 Sun Sep 16 17:05:39 2018
- 17811456 blocks of size 1024. 15328676 blocks available
- [root@client /]# #mount //192.168.1.9/smbshare /mnt -o username=linuxview
- [root@client /]# df
- Filesystem 1K-blocks Used Available Use% Mounted on
- /dev/mapper/centos-root 17811456 2472244 15339212 14% /
- devtmpfs 1919556 0 1919556 0% /dev
- tmpfs 1931784 4 1931780 1% /dev/shm
- tmpfs 1931784 11836 1919948 1% /run
- tmpfs 1931784 0 1931784 0% /sys/fs/cgroup
- /dev/sda1 1038336 145092 893244 14% /boot
- tmpfs 386360 0 386360 0% /run/user/0
- [root@client /]# mount //192.168.1.9/smbshare /mnt -o username=linuxview
- Password for linuxview@//192.168.1.9/smbshare: ******
- [root@client /]# df
- Filesystem 1K-blocks Used Available Use% Mounted on
- /dev/mapper/centos-root 17811456 2472244 15339212 14% /
- devtmpfs 1919556 0 1919556 0% /dev
- tmpfs 1931784 4 1931780 1% /dev/shm
- tmpfs 1931784 11836 1919948 1% /run
- tmpfs 1931784 0 1931784 0% /sys/fs/cgroup
- /dev/sda1 1038336 145092 893244 14% /boot
- tmpfs 386360 0 386360 0% /run/user/0
- //192.168.1.9/smbshare 17811456 2482316 15329140 14% /mnt
- [root@client /]# cd /mnt/
- [root@client mnt]# ls
- test
- [root@client mnt]#
- smb: \> help
- ? allinfo altname archive backup
- blocksize cancel case_sensitive cd chmod
- chown close del deltree dir
- du echo exit get getfacl
- geteas hardlink help history iosize
- lcd link lock lowercase ls
- l mask md mget mkdir
- more mput newer notify open
- posix posix_encrypt posix_open posix_mkdir posix_rmdir
- posix_unlink posix_whoami print prompt put
- pwd q queue quit readlink
- rd recurse reget rename reput
- rm rmdir showacls setea setmode
- scopy stat symlink tar tarmode
- timeout translate unlock volume vuid
- wdel logon listconnect showconnect tcon
- tdis tid logoff .. !
- smb: \>
- 3.FTP
- [root@linuxview ~]# useradd ftpuser
- [root@linuxview ~]# passwd ftpuser
- Changing password for user ftpuser.
- New password:
- BAD PASSWORD: The password is a palindrome
- Retype new password:
- passwd: all authentication tokens updated successfully.
- [root@linuxview ~]# getenforce
- Disabled
- [root@linuxview ~]#
- [root@linuxview ~]# service vsftpd restart
- Shutting down vsftpd: [ OK ]
- Starting vsftpd for vsftpd: [ OK ]
- [root@linuxview ~]# ps -aux |grep vsftpd
- Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
- root 2587 0.0 0.0 52124 812 ? Ss 21:34 0:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
- root 2591 0.0 0.0 103324 856 pts/0 S+ 21:35 0:00 grep vsftpd
- [root@linuxview ~]#
来源: http://blog.51cto.com/leoheng/2176182