All the servers in this area are CentOS 6.9,samba Client and NFS client are 7.2
You need to install the package to complete the following operations: Yum install httpd mariadb-server (CentOS6.9 is mysql-server) nfs-utils samba php php-fpm php-mysql nginx
The installation is complete and can be operated;
Share the/data directory separately using Samba and NFS:
First use NFS to share the/data directory:
To create a shared directory:
~]# Mkdir/data
Edit the file in Centos6/etc/exports
~]# Vim/etc/exports
Add a line of content internally:
/data
()//The first one is the directory to be shared, """" means that the shared host address is acceptable to all hosts
After adding, save exit;
Next, start the NFS process:
~]# Service NFS Start
Start NFS service: [OK]
Turn off NFS quotas: [OK]
Start NFS mountd: [OK]
Start the NFS daemon: [OK]
Starting RPC IDMAPD: [OK]
After the successful startup is complete:
~]# SS-TNL
State recv-q send-q Local address:port Peer address:port
LISTEN 0 128 172.16.72.11:8000
:
LISTEN 0 64::: 2049:::
LISTEN 0: 2049
:
.....
You can see that a process with a port number of 2049 starts;
At this point we can create a file in our locally shared directory and then edit a line inside it:
~]# Touch/data/test
~]# Vim/data/test
Test success
After editing is completed, save and exit;
In order to test whether sharing is successful, I can do the following on another host:
~]# Mkdir/mnt/nfs//Create a directory that can be mounted first
~]# showmount-e 172.16.72.11//View a list of directories shared by the server
Export list for 172.16.72.11:
/data *
~]# mount-t NFS 172.16.72.11:/data/mnt/nfs//Mount shared directory
~]# DF//See if the mount is successful 172.16.72.11:/data 51475200 12512512 36341248 26%/mnt/nfs There's a row for success.
~]# cat/mnt/nfs/test//See if sharing is successful
Test success//display for the text we entered before, so sharing success;
Next we use Samba to share the/data directory:
We have created the shared directory/data so we don't have to create it here;
We need to modify the main configuration file for Samba before sharing:
~]# vim/etc/samba/smb.conf
Workgroup = MyGroup It is recommended that this line be modified to workgroup =workgroup
Passdb backend = Tdbsam modified: Passdb backend = tdbsam:/etc/samba/test.db
Then pull to the end of the document to add content:
[Data]//share file name
Comment = Shared file//A description It doesn't matter if you write
Path =/data//directory of shared files must be written
Valid users = li//able to access the user
writable = yes//Specifies that shared users have write permissions
public = no//anonymous access is not allowed and must be authenticated before access
browsable = yes//on the browse page to see
Create mask = 0644//Specifies the upload permission after the Write permission is specified
After editing, save the exit;
If you want to see an edited file for errors, you can do so with the following command:
~]# Testparm
Load SMB config files from/etc/samba/smb.conf
Rlimit_max:increasing Rlimit_max (1024x768) to minimum Windows limit (16384)
Processing section "[Homes]"
Processing section "[Printers]"
Processing section "[Testfile]"
Loaded Services file OK.
Server Role:role_standalone
Press ENTER to see a dump of your service definitions
This proves that there is no grammatical error;
Build the user we wrote in the configuration file:
~]# Useradd Li
Creating mailbox file: File already exists
~]# pdbedit-a Li
New Password:
Retype new Password:
Unix Username:li
NT Username:
Account Flags: [U]
User sid:s-1-5-21-1182130408-243049493-2191779520-1000
Primary Group sid:s-1-5-21-1182130408-243049493-2191779520-513
Full Name:
Home Directory: \localhost\li
Homedir Drive:
Logon Script:
Profile Path: \localhost\li\profile
Domain:localhost
Account desc:
Workstations:
Munged Dial:
Logon time:0
Logoff time: Three, 06 February 2036 23:06:39 CST
Kickoff time: Three, 06 February 2036 23:06:39 CST
Password last set: Day, 06 May 2018 23:56:13 CST
Password can change: day, 06 May 2018 23:56:13 CST
Password must Change:never
Last Bad password:0
Bad password count:0
Logon HOURS:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Because our previous files are in. db format, we're going to create them with Pdbedit.
This is one of the many files we wrote in the samba file before we looked at the/etc/samba file.
~]# Ls/etc/samba
Lmhosts smb.conf smbusers test.db
Want to see the contents of this file to use the Pdbedit-l command instead of cat otherwise see is garbled;
When this is done, we can start the service:
~]# Service SMB Restart
Turn off the SMB service: [Failed]
Start the SMB service: [OK]
Use the command: ~]# SS-TNL//You can see Port No. 445 and Port 139th open, so that the SMB communication can be completed properly
~]# smbclient-l 172.16.72.11-u li//Use Li This user to view the server SMB contribution directory list, type the password for the previous set of Li's password
Enter Samba\li ' s password:
Sharename Type Comment--------- ---- -------testfile Disk shared fileIPC$ IPC IPC Service (Samba Server Version 3.6.23-46el6_9)li Disk Home Directories
Reconnecting with SMB1 for workgroup listing.
Server Comment--------- -------Workgroup Master--------- -------
Although we have previously specified the Write permission but in the file/data can see:
~]# Ll/data
Total Dosage 4
-rw-r--r--. 1 root root 13 May 6 22:42 Test
-rw-r--r--. 1 root root 0 May 6 23:36 testfile
We can give it a permission:
~]# chmod 1777/data
This is where we can create a file in a set that can be concentrated:
~]# Vim/etc/test1
Test
Save exit
And then:
~]# smbclient-u Li//172.16.72.11/testfile
Enter Samba\li ' s password:
Try "Help" to get a list of possible commands.
SMB: \> put/etc/test1 test1
Putting File/etc/test1 as \test1 (1.0 kb/s) (Average 1.0 kb/s)
SMB: \> ls
. D 0 Mon May 7 00:23:21 2018
.. DR 0 Sun May 6 22:13:06 2018
Test1 N 7 Mon May 7 00:23:21 2018
Test N Sun May 6 22:42:31 2018
Testfile N 0 Sun May 6 23:36:46 2018
51475068 blocks of size 1024. 36338320 blocks available这样就完成了将本地文件上传到服务器操作;
Then switch to the server host:
~]# cat/data/test1
Test
to prove that the upload was successful;
can also be shared via Mount like NFS
~]# mkdir/mnt/cifs
~]# mount-t Cifs-o Username=li//172.16.72.11/data/mnt/cifs/
Password for [email protected]//172.16.72.11/data: * *
**~]# DF
DF: "/RUN/USER/0/GVFS": No file or directory
File system 1k-block used available% mount point
/dev/sda1 40498872 3942252 36556620 10%/< Br>devtmpfs 924900 0 924900 0%/dev
tmpfs 935256 + 935172 1%/dev/shm
Tmpfs 935256 25496 909760 3%/run
Tmpfs 93 5256 0 935256 0%/sys/fs/cgroup
Tmpfs 187052 4 187048 1%/run/user/0
//172.16.72.11/data 51475068 12515276 36338352 26%/mnt/cifs
~]# cat/mnt/cifs/testfile
Test
Shared success
Let the Samba client and the NFS client mount the/data/-to-local/mydata directory that is shared on the Samba server, and the data directory for the local mysqld or MARIADB service is set to/mydata, requiring the service to start normally, and to store the data normally:
Create the local directory/mydata on the Samba client just before you complete the mount:
~]# Mkdir/mydata
~]# mount-t cifs-o Username=li//172.16.72.11/data/mydata
Password for [email protected]//172.16.72.11/data: * *
Create the local directory/mydata on the NFS client just before you complete the mount:
~]# Mkdir/mydata
~]# mount-t NFS 172.16.72.11:data/mydata
Modify the MARIADB Master profile for the Samba client:
~]# vim/etc/my.cnf
Datadir=/var/lib/mysql modified to Datadir=/mydata
Modify the MARIADB Master profile for the NFS client:
~]# vim/etc/my.cnf
Datadir=/var/lib/mysql modified to Datadir=/mydata
Complete the following actions on the shared server after completion:
~]# cp-a/var/lib/mysql/data/mysql
~]# Chmod-r 1777/data
~]# MySQL
Welcome to the MariaDB Monitor. Commands End With; or \g.
Your MariaDB Connection ID is 3
Server VERSION:5.5.56-MARIADB MariaDB Server
Copyright (c), Oracle, MariaDB Corporation Ab and others.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
MariaDB [(None)]> CREATE DATABASE mydb Character set = UTF8;
Query OK, 1 row Affected (0.00 sec)
Be able to successfully create a table, indicating success;
(1) Use Samba and NFS to share/data/application/web, deploy lamp, and provide WordPress application in the above catalogue;
(2) Use Samba Client and NFS client to mount the directory of Samba server and NFS server shares to/var/www/html, respectively;
(3) respectively through two servers to verify whether WordPress can be accessed, the normal post and upload pictures;
First use Samba and NFS to share/data/application/web in the server, the above operation is the same, just change the file name;
Operations in the server:
~]# Vim/etc/exports
/data/application/web (rw)//To enable NFS clients to upload articles and pictures to give them write permission
~]# vim/etc/samba/smb.conf
[web]
Comment = Shared file
Path =/data/application/
Valid users = Li
writable = yes
public = No
browsable = yes
Create mode = 0644
Directory mode = 0755
~]# chmod 777/data/application/web//In order to allow Samba clients to upload articles and images to give them the appropriate permissions
T ~]# vim/etc/samba/smb.conf
~]# Service NFS Restart
To turn off the NFS daemon: [OK]
Turn off NFS mountd: [OK]
Turn off NFS quotas: [OK]
Turn off NFS services: [OK]
Shutting down RPC IDMAPD: [OK]
Start NFS service: [OK]
Turn off NFS quotas: [OK]
Start NFS mountd: [OK]
Start the NFS daemon: [OK]
Starting RPC IDMAPD: [OK]
[[Email protected] ~]# service SMB restart
Turn off the SMB service: [OK]
Start the SMB service: [OK]
~]# mount-t NFS 172.16.72.11:/data/application/web/var/www/html
~]# mount-t cifs-o Username=li//172.16.72.11/data/application/var/www/html
Password for [email protected]//172.16.72.11/data/application: * *
Send WordPress files from the computer host to the virtual machine Server host/data/application/web, this is the tool we need to use XFTP tools and software packages Wordpress-4.2-zh_ CN.tar.gz after extracting the WordPress file inside
After completing the operation, do the following in the Samba client and Client for NFS:
~]# setenforce 0
~]# systemctl disable Firewalld.service
~]# systemctl stop firewalld.service
~]# iptables- F
~]# systemctl start httpd.service
~]# systemctl status httpd.service
httpd.service-the Apache HTTP serverloaded:loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset:disabled)
Active:active (running ) since four 2018-05-17 21:59:02 CST; 29min ago
Docs:man:httpd (8)
Man:apachectl (8)
Main pid:22428 (httpd)
Status: "Total requests:2; Current requests/sec:0; Current traffic:0 b/sec "
CGroup:/system.slice/httpd.service
├─22428/usr/sbin/httpd-dforeground
├─22430/ Usr/sbin/httpd-dforeground
├─22431/usr/sbin/httpd-dforeground
├─22432/usr/sbin/httpd-dforeground
├─22433/usr/sbin/httpd-dforeground
├─22434/usr/sbin/httpd-dforeground
├─22436/usr/sbin/httpd-dforeground
└─22451/usr/sbin/httpd-dforeground
May 21:59:02 Localhost.localdomain systemd[1]: Starting the Apache HTT ...
May 21:59:02 localhost.localdomain httpd[22428]: AH00558:httpd:Could ...
May 21:59:02 localhost.localdomain systemd[1]: Started the Apache HTTP ...
Hint:some lines were ellipsized, use-l to show on full.
Then you access 172.16.72.1/wordpress and 172.16.72.10/wordpress on your own computer host, respectively.
This proves that the server can be accessed;
Next we set up the database in the server:
~]# mysql-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 62
Server version:5.1.73 Source Distribution
Copyright (c) and/or, Oracle, its affiliates. All rights reserved.
Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Mysql> CREATE database Word charset = UTF8; Set up a database
Query OK, 1 row Affected (0.00 sec)
Mysql> Grant all on word.* to ' root ' @ ' percent ' identified by ' 123456 '; Authorizing and setting a password
Query OK, 0 rows Affected (0.00 sec)
Mysql> \q//exit
Bye
To modify the WordPress configuration file in the server:
~]# cd/data/application/web/wordpress/
wordpress]# Vim wp-config-sample.php//Modify the sections below to
Then access the 172.16.72.1/wordpress via the NFS client host address, entering the interface to enter the following:
Submitted
When the above situation occurs, we go to the server example to do the following:
wordpress]# Vim wp-config.php
Copy the prompt content in the picture, save the exit, and then click on the site to install, the following interface appears:
To configure yourself:
Click Install wordpress appears below this page:
Click Sign in to use the user you just built:
Go to the following page:
Click to compose an article, then publish it, publish it successfully, and prove that sharing is successful.
Example of sharing Samba and NFS in Linux