I. Using NFS services for remote database storage
The NFS service requires the use of the Nfs-utils program, so the package must be installed first; (Yum install-y nfs-utils)
Here I have two sets of Centos6.9 and Centos7.4 virtual machine to implement the experimental process; Centos6.9 as the server side, Centos7.4 as the client;
First: Install the Nfs-utils package on the Centos6.9 server and start the service;
Step Two: We modify the NFS configuration file/etc/exports, in the order of the file: The file directory to be shared allows the host address requirements of the directory to be mounted (optional)
Host address requirements: You can write a clear IP address, logical network segment, you can also use the "?" in the IP address. Represents any single character, "*" denotes any arbitrary character;
Available options:
RO: Read only;
RW: Read and write;
Async: Asynchronous storage;
Sync: synchronous storage;
Nohide: Do not hide the contents of file systems that are mounted on subdirectories of a shared directory;
Root_squash: Compresses the root user's permissions and typically maps them to nfsnobody users; (default)
No_root_squash: Revoke the root user's permission compression;
All_squash: All non-root users do permissions compression, mapped to nfsnobody users;
No_all_squash: All non-root users do not do permission compression, only mapping UID; (default)
The folder I shared here is/data, the network segment allowed to access is 179.5.99.*, the option is only to make it readable and writable;
To test its functionality, I created a file called A.txt in the/data directory;
You can use the Showmount command to view the file directories that can be mounted on the server:
# SHOWMOUNT-E 179.5.99.77
The third step: we switch to the client Centos7.4 use the Mount command to mount the file; (My Centos7.4 IP address is 179.5.99.12 in accordance with the address access control rules we have just completed manually)
Use-T to indicate the file system type, mount the/data under the 179.5.99.77 server to the/mydata directory of the current client, and you can see the test file created in the previous step to indicate that the service is working properly;
Fourth step: Check whether the/data directory has write permission to all people, if not add, no side will be written failure, insufficient permissions, after confirming the MYSQL/MARIADB service directory to/mydata, and create database, table and other data test its work is normal;
1. Modify the MySQL database service directory
、
2. In order to ensure the normal start of the MARIADB service, please copy the files from the original/var/lib/mysql/directory to the/mydata/directory and make sure that the main array is MySQL;
# scp/var/lib/mysql/*/mydata/
3. Start the MARIADB service on the Centos7.4 client
# Systemctl Start Mariadb.service
(I have previously set the database password so I want to use the-P option to log in)
So far we have completed a simple remote database storage using NFS service and Mariadb/mysql service;
Second, Samba realizes remote database storage
The same we use two virtual machine implementation, Centos6.9 as the server side, Centos7.4 as a client;
First: Verify that the following Samba packages are installed on the server side:
Samba
Samba-libs
Samba-client
Samba-client-libs
Samba-common
Samba-commom-tools
Samba-common-libs
Cifs-utils
Step two: Start the samba service
Step three: Modify the relevant configuration
1. Modify the Samba master configuration file;
# vim/etc/samba/smb.conf
C69share the name of the shared file directory
Comment Comment Information
Path to shared files directory
Valid name of the user allowed to access
Whether writable has Write permissions
Directory mode shared directory permissions
Create mode default permissions for creating files
Guest OK whether to turn on anonymous login
Note: if Passdb backend = Tdbsam[:/etc/samba/samusers] is required in the configuration file, use the Pdbedit command (default)
If the configuration file Passdb backend = smbpasswd:/etc/samba/smbpasswd need to use the SMBPASSWD command
Create a user for remote login;
#useradd boom
#pdbedit-a boom
(The SMBPASSWD command uses the same method as Pdbedit, adding users using the-a option)
Fourth step: You can use the Testparm command to detect the configuration file if there is a syntax error
Mount on the Centos7.4 client
# mount-t Cifs-o username=boom//179.5.99.77/c69share/mydata
You can see what was copied in the previous experiment, and start the MARIADB service to realize Remote storage of the database;
Simple implementation of MARIADB service samples based on Samba and NFS