Method 1: Centos and Windows shared folder

Use Samba to implement shared folders

Step 1: Check that Samba is installed

rpm -qi samba
Copy the code

Step 2: Not installed, install Samba, if installed, ignore;

yum -y install samba samba-client
Copy the code

Step 3: Share a directory and log in with a user name and password to access it. You must be able to read and write the Samba configuration file

vim /etc/samba/smb.conf

[global]
        workgroup = WORKGROUP
        security = user
        passdb backend = tdbsam
        load printers = yes
        cups options = raw

[share]
        comment = share for users
        path = /var/backups
        browseable = yes
        writable = yes
        public = no
Copy the code

Step 4: Save the configuration file and create a directory:

mkdir /var/backups
chown root /var/backups
chmod -R 777 /var/backups
Copy the code

Step 5: Add users to the shared folder

smbpasswd -a root
service smb restart
Copy the code

Step 6: SELinux in CentOS is a powerful access control system. Its full name is Security Enhanced Linux, and it is an implementation of the access control system. Its purpose is to specify which resources a process can access. These resources include, but are not limited to, files or network ports

setenforce 0
Copy the code

Step 7: Access the “Win + R” key in Windows and type “\ IP address of shared folder”

\ \ 192.168.25.101Copy the code

Method 2: File sharing is implemented between centos7 and Centos7

Network File System (NFS) allows computers on a Network to share resources over the TCP/IP Network. In NFS applications, the local NFS client application can transparently read and write files on the remote NFS server, just like accessing local files.

Server: 192.168.25.100 (where files are stored) Client: 192.168.25.101 (Operations on the client are synchronized to the server)

Step 1 in server configuration: Download dependencies

yum install -y nfs-utils
Copy the code

Step 2: Add clients

Vim /etc/exports /var/backups/ 192.168.25.101/24(rw,sync,fsid=0)Copy the code

Step 3: Set boot

systemctl enable rpcbind.service
systemctl enable nfs-server.service
systemctl start rpcbind.service
systemctl start nfs-server.service
Copy the code

Step 4: Make the configuration take effect

/home/nfs 192.168.248.0/24Copy the code

Step 5: Check the mount status

rpcinfo -p
Copy the code

Client configuration step 1: Download the dependencies

yum install -y nfs-utils
Copy the code

Step 2: Set boot

systemctl enable rpcbind.service
systemctl enable nfs-server.service
systemctl start rpcbind.service
systemctl start nfs-server.service
Copy the code

Step 3: Check whether there are directory shares on the NFS server (that is, the list of licensed clients on the server)

Showmount -e 192.168.25.100Copy the code

Step 4: The client mounts the server file

The mount -t NFS 192.168.25.100: / var/backups/var/backupsCopy the code