In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to build a file server in Linux. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
At a team or company level, it is necessary to be a local file server and download online resources locally. This will save a lot of download time for others.
The concrete method of building file server by Linux
Samba service
Function: shared directory (smb protocol) software: samba server, samba-client client configuration file: / etc/samba/smb.conf service: smb, nmb port: smb-> 139/tcp, 445/tcp provides file sharing function nmb-> 137/udp, 138/udp provides parsing computer name configuration file: / etc/samba/smb.conf
Global configuration
[global] workgroup = MYGROUP > > set workgroup name server string = Samba Server Version% v > > display samba software version information interfaces = lo eth0 192.168.12.2 24 192.168.13.2 > IP address hosts allow for samba service monitoring. 192.168.12. 192.168.13. > set only which hosts are allowed to access hosts deny = 192.168.12. 192.168.1.1 security 24 > which hosts are denied access to share = user > access based on user authentication > Anonymous access to shared directory configuration
[share name] comment = > > description information path = / bj > > specify directory name browseable = yes > > downloadable file writable = yes > uploadable file public = yes > allow all users to access write list = user1 > only allow user1 to upload files example:
Environment description: Linux 192.168.122.105 Centos 7.2 file sharing server Windows/Linux client requirements: share the local / caiwu directory through samba software, the client can be accessed through martin users, only allow them to download files to close SELinux, firewall
[root@file-server ~] # setenforce 0 [root@file-server ~] # getenforce Permissive [root@file-server ~] # vim / etc/sysconfig/selinux
[root@file-server ~] # systemctl stop firewalld.service [root@file-server ~] # systemctl disable firewalld.service
Install softwar
[root@file-server ~] # yum install-y samba samba-client
Edit the configuration file, share / caiwu directory
[root@file-server ~] # mkdir / caiwu [root@file-server ~] # touch / caiwu/ {1.. 5} .mp3
[root@file-server ~] # vim / etc/samba/smb.conf
[caiwu] comment = It is a test path = / caiwu browseable = yes create a shared user
[root@file-server ~] # useradd martin [root@file-server ~] # smbpasswd-a martin New SMB password: Retype new SMB password: Added user martin.
[root@file-server ~] # pdbedit-L > View shared user martin:1001: [root@file-server ~] #
Start the service
[root@file-server ~] # systemctl start smb [root@file-server ~] # systemctl enable smb
[root@file-server] # ss-antp | grep smbd LISTEN 0 50: 139 *: users: (("smbd", pid=2804,fd=38)) LISTEN 0 50 *: 445 *: * users: (("smbd", pid=2804,fd=37)) LISTEN 050:: 139: * users: (("smbd", pid=2804,fd=36)) LISTEN 050: 445:: * users: ("smbd", pid=2804,fd=35))
Test access
Windows client:
\\ 192.168.122.105 cancel the sharing of the user host directory [root@file-server ~] # vim / etc/samba/smb.conf
[homes] comment = Home Directories browseable = no writable = yes
[root@file-server ~] # systemctl restart smb
Linux client:
[root@client ~] # yum install-y samba-client
[root@client ~] # smbclient / / 192.168.122.105/caiwu-U martin
Configure to allow martin users to upload files
Edit configuration file
[root@file-server ~] # vim / etc/samba/smb.conf
[caiwu]... Writable = yes [root@file-server ~] # systemctl restart smb
Set local permissions for a directory
[root@file-server] # setfacl-m u:martin:rwx / caiwu/
Example:
Share the local / shichang directory through samba software, allow martin users to download files, allow admin users to upload files to create directories, and create shared users
[root@file-server ~] # mkdir / shichang [root@file-server ~] # touch / shichang/ {1. 5} .jpg [root@file-server ~] # [root@file-server ~] # useradd admin [root@file-server ~] # smbpasswd-an admin New SMB password: Retype new SMB password: Added user admin. [root@file-server] # [root@file-server] # pdbedit-L martin:1001: admin:1002: [root@file-server ~] #
Edit configuration file
[root@file-server ~] # vim / etc/samba/smb.conf
[shichang] path = / shichang browseable = yes write list = admin [root@file-server ~] # systemctl restart smb
[root@file-server] # chown admin / shichang/ [root@file-server] # ls-ldh / shichang/ drwxr-xr-x. 2 admin root 66 February 21 12:00 / shichang/ [root@file-server ~] #
Test access
Clear the shared cache for windows
Net use * / delwindows sets the network map drive to access the share
FTP-File Transport Protocol File transfer Protocol
Connection mode of FTP protocol: active connection passive connection
Software: vsftpd profile: / etc/vsftpd/vsftpd.conf Service: vsftpd Port: 21/tcp Command connection Port 20/tcp data connection Port (active)
FTP root directory: user host directory
Access method: anonymous user access (ftp) user authenticated access
Example: build a FTP server with anonymous access
Install vsftpd softwar
[root@file-server ~] # yum install-y vsftpd
[root@file-server] # systemctl start vsftpd [root@file-server] # systemctl enable vsftpd Created symlink from / etc/systemd/system/multi-user.target.wants/vsftpd.service to / usr/lib/systemd/system/vsftpd.service.
[root@file-server ~] # ss-antp | grep: 21 LISTEN 0 32: 21:: Users: ("vsftpd", pid=5748,fd=3))
Test access:
Windows: files that can be uploaded anonymously by ftp://192.168.122.105 FileZilla FTP client software
[root@file-server ~] # chmod otakw / var/ftp/pub/
Anon_upload_enable=YES > allow file upload anon_mkdir_write_enable=YES > allow upload directory anon_other_write_enable=YES > allow other modifications (delete, rename, etc.)
Anon_umask=022 > allow other users to download files from anonymous users
Anon_root=/company > change the root directory of the anonymous user's FTP
FTP services authenticated by local users
Example: build FTP yum source to provide MySQL installation package
[root@file-server] # ls / rpm/mysql/ mysql-community-client-5.7.16-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm mysql-community-common-5.7.16-1.el7.x86_64.rpm mysql-community-server-5.7.16-1.el7.x86_64.rpm mysql-community-libs-5.7.16-1.el7.x86_64.rpm
[root@file-server ~] # createrepo / rpm/mysql/
[root@file-server ~] # vim / etc/vsftpd/vsftpd.conf
Anon_root=/ RPM [root @ file-server ~] # systemctl restart vsftpd
Use ftp source:
[root@client ~] # cat / etc/yum.repos.d/centos.repo
[Centos] name=centos7u2 baseurl= ftp://172.16.8.100/centos7u2 enabled=1 gpgcheck=0
[mysql] name=mysql baseurl= ftp://192.168.122.105/mysql enabled=1 gpgcheck=0
Nfs-Network File System network file system
Function: data sharing among Linux servers
Software: nfs-utils rpcbind
[root@file-server] # rpm-Q rpcbind rpcbind-0.2.0-32.el7.x86_64
[root@file-server ~] # rpm-Q nfs-utils nfs-utils-1.3.0-0.21.el7.x86_64 [root@file-server ~] #
Directory export file-/ etc/exports
File format:
Directory name client address (permissions) client address: IP address 192.168.1.1 network segment 192.168.1.0 rw 24 * permissions: ro read-only rw read-write sync synchronous async Asynchronous all_squash client all files uploaded by users belong to nfsnobody root_squash client root user uploaded files will be mapped to nfsnobody no_ The file uploaded by the root_squash client root user still belongs to the root anonuid= anongid= example:
Share the local directory / webdata through nfs, allowing 192.168.122.121 to be mounted read-only
[root@file-server ~] # mkdir / webdata [root@file-server ~] # touch / webdata/ {1.. 10} .html
[root@file-server ~] # cat / etc/exports / webdata 192.168.122.121 (ro) [root@file-server ~] #
[root@file-server ~] # systemctl restart rpcbind [root@file-server ~] # systemctl restart nfs-server
[root@file-server ~] # systemctl enable nfs-server
[root@file-server ~] # showmount-e localhost Export list for localhost: / webdata 192.168.122.121 [root@file-server ~] #
Client:
[root@client ~] # mount 192.168.122.105:/webdata / www/
[root@client ~] # ls / www/ 10.html 1.html 2.html 3.html 4.html 5.html 6.html 7.html 8.html 9.html
Auto mount:
* 1* | 0**vim / etc/fstab**
192.168.122.105:/webdata / www nfs defaults 0 0
Example 2:
Share the local directory / mysqldata through nfs, allowing 192.168.122.121 to be mounted read-write
[root@file-server ~] # mkdir / mysqldata [root@file-server ~] # touch / mysqldata/ {1.. 10} .SQL [root@file-server ~] # chmod otakw / mysqldata/
[root@file-server] # vim / etc/exports... / mysqldata 192.168.122.121 (rw)
[root@file-server ~] # exportfs-rav exporting 192.168.122.121:/mysqldata exporting 192.168.122.121:/webdata [root@file-server ~] #
Client:
[root@client ~] # vim / etc/fstab
192.168.122.105:/mysqldata / database nfs defaults 0 0
[root@client] # mount-a
[root@client ~] # df-h File system capacity available available Mount Point / dev/mapper/centos-root 7.3G 4.4G 3.0G 60% / devtmpfs 230M 0230M 0% / devtmpfs 245M 0245m 0% / dev/shm tmpfs 245M 4.7M 240M 2% / run tmpfs 245M 0245m 0% / sys/fs/cgroup / dev/mapper/centos-home 2.0G 33M 2.0G 2% / home / dev/ Vda1 512M 141M 372M 28% / boot tmpfs 49M 049M 0% / run/user/0 192.168.122.105:/webdata 7.3G 3.6G 3.8G 49% / www 192.168.122.105:/mysqldata 7.3G 3.6G 3.8G 49% / database
After reading the above, do you have any further understanding of how Linux builds a file server? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.