NFS shared directory and mount

Source: Internet
Author: User
Tags mysql host wordpress database

Experimental content :

(1) NFS server Export/data/application/web, in the directory to provide WordPress;

(2) NFS Client Mounts NFS Server exported file system to/var/www/html;

(3) the client (lamp) to deploy WordPress, and let its normal access, to ensure that the normal post, upload pictures;

(4) Client 2 (lamp), Mount NFS server exported file system to/var/www/html, check that its WordPress can be accessed, to ensure that the normal post, upload pictures;




Here are 3 hosts for experiments:

#服务端主机IP为: 172.16.100.32 provides directory sharing, provides MySQL database

#客户端主机IP为: 172.16.100.31 Mount Directory

#客户端主机IP为: 172.16.100.33 Mount Directory

First server-side host installation Nfs-utils

[[email protected] ~]# yum install nfs-utils should be installed by default

#然后创建一个需要导出的目录

[email protected] ~]# Mkdir-pv/data/application/web

#编辑配置文件/etc/exports

[email protected] ~]# vim/etc/exports

#表示要导出共享的目录 and which IP address the client can mount, this is all clients of the 172.16 segment, and has read and write permissions

650) this.width=650; "Style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat Center;border : 1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>650" this.width=650; "title=" 1.jpg "src=" http://s4.51cto.com/wyfs02/M00/84/74/wKioL1eQylOx_CE-AAAW631VadQ952.jpg "alt=" Wkiol1eqylox_ Ce-aaaw631vadq952.jpg "/>

#在服务端上创建用户并且赋予权限;

[[email protected] ~]# useradd Apache View ID number

[email protected] ~]# setfacl-m u:apache:rwx/data/application/web

#查看一下apache的ID

[[email protected] ~]# ID Apache

uid=1003 (Apache) gid=1003 (Apache) groups=1003 (Apache) Remember the ID number, etc. will go to the client to change


#重启服务, no restart is recommended in the production environment, here is a command to export all

[email protected] ~]# Exportfs-ar

Mount-t equivalent to Mount.nfs by command.

[email protected] ~]# mount-t NFS 172.16.100.32:/data/application/web/var/www/html

#格式: The IP of the mounted host and the directory path shared by the server is followed by which directory is attached to the client

#可以用mount命令查看是否挂载成功以及详细的信息;

[email protected] ~]# mount

172.16.100.32:/data/application/web on/var/www/html type NFS4 (rw,relatime,vers=4.0,rsize=262144,wsize=262144, Namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.16.100.31,local_lock=none,addr= 172.16.100.32)

#但是现在客户端上的用户还没有对这个/var/www/html Directory has write permission;

the ID number of the #apache must be the same as the ID number of the user who owns the server, so that the server-side user ID can be mapped to the client user ID.


#其实还有一个方法, you can specify the users and groups running httpd to change in the main configuration file

650) this.width=650; "title=" 1.jpg "src=" Http://s2.51cto.com/wyfs02/M01/84/74/wKiom1eQymngASDJAAAbF8w9wXM532.jpg " alt= "Wkiom1eqymngasdjaaabf8w9wxm532.jpg"/>

650) this.width=650; "Style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat Center;border : 1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/> Temporarily do not use this method


#先把pache的ID号改成和服务端一样的ID号 so there's permission to mount the directory.

[email protected] ~]# usermod-u 1003 Apache

[email protected] ~]# groupmod-g 1003 Apache


#如果想查看服务端有哪些目录可以挂载以及已经挂载了哪些可以用命令showmount-e view;

[email protected] html]# showmount-e 172.16.100.32

Export list for 172.16.100.32:

/data/application/web 172.16.0.0/16

#下面我们在服务端上提供wordpress文件, and then have its client configured and allowed to access it normally;

Installing the HTTPD Service

#在mariadb中创建数据库以及用户名密码为wordpress提供;

Advanced MySQL then the following

Mysql> GRANT all on wpdb.* to ' wpuser ' @ ' 172.16.%.% ' identified by ' wppass ';

mysql> FLUSH privileges;

mysql> CREATE DATABASE wpdb;


#修改wordpress配置文件

[email protected] ~]$ vim/var/www/html/wordpress/wp-config.php

* * MySQL Settings-specific information from the host you are using * *//

/** Name of WordPress database */

Define (' db_name ', ' wpdb ');

/** MySQL Database user name */

Define (' Db_user ', ' wpuser ');

/** MySQL Database password */

Define (' Db_password ', ' wppass ');

/** MySQL Host */

Define (' Db_host ', ' 172.16.100.32 '); This point is to the server host IP

/** The default text encoding when creating data tables */

Define (' Db_charset ', ' UTF8 ');

/** the database collation type. If you are unsure do not change */

Define (' db_collate ', ');

Verify that you can access and use it correctly

650) this.width=650; "Style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat Center;border : 1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>650" this.width=650; "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd; "Src="/e/u261/ Themes/default/images/spacer.gif "alt=" Spacer.gif "/>650" this.width=650; "title=" 1.jpg "src="/http S3.51cto.com/wyfs02/m01/84/74/wkiol1eqyn2r7vvgaac2cg5yvba242.jpg "alt=" Wkiol1eqyn2r7vvgaac2cg5yvba242.jpg "/>

650) this.width=650; "title=" 1.jpg "src=" Http://s4.51cto.com/wyfs02/M02/84/74/wKiom1eQypGwdf8HAAC2hHusE2U290.jpg " alt= "Wkiom1eqypgwdf8haac2hhuse2u290.jpg"/>

have succeeded;

#下面我们继续第2台客户机, and the first host step as follows I will simply write down the steps;

[[email protected] yum.repos.d]# yum install httpd php php-mysql installation RPM Package

#先把pache的ID号改成和服务端一样的ID号 so there's permission to mount the directory.

[email protected] ~]# usermod-u 1003 Apache

[email protected] ~]# groupmod-g 1003 Apache


[[email protected] yum.repos.d]# systemctl start httpd start service

[[email protected] yum.repos.d]# systemctl start mariadb start service

# mount the server-side exported directory ; mount-t equivalent to Mount.nfs by command

[email protected] ~]# mount-t NFS 172.16.100.32:/data/application/web/var/www/html

#格式: The IP of the mounted host and the directory path shared by the server is followed by which directory is attached to the client

#可以用mount命令查看是否挂载成功以及详细的信息;

[email protected] ~]# Mount

172.16.100.32:/data/application/web on/var/www/html type NFS4 (rw,relatime,vers=4.0,rsize=262144,wsize=262144, Namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.16.100.33,local_lock=none,addr= 172.16.100.32)

#因为共享的目录里面提供了wordpress以及里面的配置第一台客户端已经配置好了, so there is no need to reconfigure it;


#然后即可登录测试是否可登录第2台客户机, whether the blog can be sent, data storage is available;

650) this.width=650; "Style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat Center;border : 1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>650" this.width=650; "title=" 1.jpg "src=" http://s3.51cto.com/wyfs02/M01/84/74/wKioL1eQyqSS0IK_AACJcoK8ywc155.jpg "alt=" Wkiol1eqyqss0ik_ Aacjcok8ywc155.jpg "/>

650) this.width=650; "title=" 1.jpg "src=" Http://s3.51cto.com/wyfs02/M01/84/74/wKiom1eQyr2DB-65AACo7djD8OY014.jpg " alt= "Wkiom1eqyr2db-65aaco7djd8oy014.jpg"/>

#登录成功, because the first client is already installed and the file is shared so you can see the 1 post from the client

650) this.width=650; "Style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat Center;border : 1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>

#下面我们在发一篇文章如果可以发图片则大功告成;

650) this.width=650; "Style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat Center;border : 1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>650" this.width=650; "title=" 1.jpg "src=" http://s5.51cto.com/wyfs02/M02/84/74/wKioL1eQytHzrGzBAADnWDZ-fn0960.jpg "alt=" Wkiol1eqythzrgzbaadnwdz-fn0960.jpg "/>

Success


This article is from the "11332618" blog, please be sure to keep this source http://11342618.blog.51cto.com/11332618/1828596

NFS shared directory and mount

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.