Social networking Site Deployment--mfs Distributed File System

Source: Internet
Author: User
Tags php language php server nginx server

Case overview

A company's social networking site in the PHP language development, in order to manage the code developed by PHP programmers, the senior leaders asked to build SVN server version control. The first version of the social networking site is deployed on top of the LNMP platform, with an Nginx server and access to the backend's PHP server via the FASTCGI protocol. In order to ensure data security, MySQL database is required to build a master-slave cluster.

The social networking site project contains the user's album feature, allows users to upload photos, upload photos to be stored using shared storage. There are many open source solutions available for shared storage, such as MFS, Fastdfs, and so on. The company decided to use the MFS Distributed file system to implement, and the MFS mounted in the PHP server related directory.

Case implementation

Depending on the company's needs, the implementation process is broadly divided into the following steps.

    • Deploy the SVN server, create an access account for the PHP Programmer's Repo directory, and notify the programmer to import the code.
    • Deploy MySQL master-slave server, create database and table according to PHP Programmer's requirement.
    • Deploy an Nginx server. Deploy the PHP server.
    • Deploy MFS to mount the MFS file system in the relevant directory of the front-end PHP server.
    • Notifies the on-line deployer to be released on-line.
MFS deploy and Mount Master Server1, install MFS
yum install -y zlib-devel gcc gcc-c++      //安装依赖包环境包useradd mfs -s /sbin/nologin -M            
2. Copying files
cd /usr/local/mfs/etc/mfs/cp mfsmaster.cfg.dist mfsmaster.cfg          # 主配置文件cp mfsexports.cfg.dist mfsexports.cfg           # 挂载权限cp mfstopology.cfg.dist mfstopology.cfg           # top架构感知cd /usr/local/mfs/var/mfs/ cp metadata.mfs.empty metadata.mfs        #防断裂
3. Start the Master Server
/usr/local/mfs/sbin/mfsmaster start       //开启/usr/local/mfs/sbin/mfsmaster -s        //停止netstat -antp | grep mfssystemctl stop firewalld.service setenforce 0         //关闭防火墙和安全功能

Build Metalogger Server1, install MFS
yum install -y zlib-devel gcc gcc-c++       //安装依赖包环境包useradd mfs -s /sbin/nologin -M          //创建管理用户tar xzvf mfs-1.6.27-5.tar.gz -C /opt/cd /opt/mfs-1.6.27/./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --disable-mfschunkserver --disable-mfsmountmake && make install
2. Copying files
cd /usr/local/mfs/etc/mfs/cp mfsmaster.cfg.dist mfsmaster.cfg cp mfsexports.cfg.dist mfsexports.cfg cp mfsmetalogger.cfg.dist mfsmetalogger.cfgvim mfsmetalogger.cfg......MASTER_HOST = 192.168.43.118         //IP指向master
3. Start Metalogger Server
/usr/local/mfs/sbin/mfsmetalogger start   //开启/usr/local/mfs/sbin/mfsmetalogger -s    //停止netstat -antp | grep mfssystemctl stop firewalld.service setenforce 0         //关闭防火墙和安全功能

Build Chunk Server1, install MFS
yum install -y zlib-devel gcc gcc-c++        //安装依赖包环境包useradd mfs -s /sbin/nologin -M          
2. Copying files
cd /usr/local/mfs/etc/mfs/ cp mfschunkserver.cfg.dist mfschunkserver.cfgcp mfshdd.cfg.dist mfshdd.cfgvim mfschunkserver.cfg......MASTER_HOST = 192.168.43.118         //IP指向mastervim mfshdd.cfg....../data            //添加一行/data,在这里/data是一个给MFS的分区,生产环境最好使用独立的分区或磁盘挂载到此目录mkdir /data        //创建文件夹chown -R mfs:mfs /data        //属主属组都改为mfs

3. Start Chunk Server
/usr/local/mfs/sbin/mfschunkserver start   //开启/usr/local/mfs/sbin/mfschunkserver start -s    //停止netstat -antp | grep mfssystemctl stop firewalld.service setenforce 0         //关闭防火墙和安全功能

Client Configuration

Here the PHP server is the client role, built on the PHP server

1. Install fuse
yum install -y zlib-devel gcc gcc-c++     //安装依赖包环境包tar xzvf fuse-2.9.2.tar.gz -C /opt        //mfs客户端依赖于fusecd /opt/fuse-2.9.2./configuremake && make install
2. Setting Environment variables
vim /etc/profile#在末尾处插入export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATHsource /etc/profile         //加载立即生效
3. Installing MFS Client
useradd mfs -s /sbin/nologin -M        //创建管理用户tar xzvf mfs-1.6.27-5.tar.gz -C /opt/cd /opt/mfs-1.6.27/./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --disable-mfschunkserver --enable-mfsmount       //注意此处开启客户端make && make install
4. Mount MFS File system

Mount the MFS file system in the/var/www/html/webphp/uploads/photos directory of the front-end PHP server

mkdir -p /var/www/html/webphp/uploads/photos         //创建挂载点modprobe fuse                     //加载fuse模块到内核/usr/local/mfs/bin/mfsmount /var/www/html/webphp/uploads/photos -H 192.168.43.118        //挂载MFS

Social networking Site Deployment--mfs Distributed File System

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.