NFS Related Introduction
I. Introduction to NFS
1. NFS (Network file System): NFS is a file-sharing protocol and is a file system implemented in the kernel in Unix-like systems.
2. Origin: The earliest was developed by Sun Company, very old, just to achieve file sharing, security control is relatively simple. Version has, NFSV1, NFSV2,NFSV3,NFSV4. V4 version Support Kerberos authentication.
3. RPC (remote Procedure Call): The NFS protocol is implemented based on the PRC (remoted procedure calls).
The basic process is that a client program initiates a process request >RPC the client takes over the request > passes the socket communication to the server side > The server side receives the request to a program execution > executes the result or status back to the client
RPC Daemon Rpcbind listener: 111/tcp and 111/UDP
RPC Remote Call Process Rpc.mount monitoring: 2049/TCP and 2049/UDP
1437440473124205.png
4. For NFS security settings, the native NFS service can only be based on IP authentication. NFSV4 can be certified based on the following two authentication methods
Nis:network Information Service
Kerberos 5. Installation configuration: Nfs-utils package, NFS is the kernel implementation, so only need kit
6. Three key processes:
MOUNTD: Mount the search process, responsible for the client source authentication process
NFSD: File Read and write
Idmapd:id Mapping process
7. configuration file/etc/exports:
Configuration format:
File system client 1 (File system export properties) client 2 (File system export properties)
/var/www/htdocs/discuz/upload 192.168.98.128/24 (Rw,async,no_root_squash) 192.168.98.129/24rw,async,no_root_ Squash)
File Export Properties:
RW Async Sync
Root_squash: Compressed root user, based on IMAPD, converts the root to nfsnobody user when it is accessed over the network
No_root_squash: Do not compress the root user;
All_squash: Compress all users;
Anonuid, Anongid: Specifies the UID and GID that the anonymous user maps to;
Related commands
Showmount
-E: Perform on NFS client, probe the NFS file system exported by a host, use the format "Showmount-e server_ip";
-D: Performed on the server Side of NFS, showing which exported file system has been used by at least one client mount;
-A: Displays all mount sessions on the NFS server side;
Exportfs: The user does not restart the service to re-export the directory
-A: operation of all file systems
-ra: Re-export all file systems
-ua: Cancel import of all file systems
V
: Show more information
Because the NFS worker process Mountd listens to random ports by default, it is possible to consume some important ports, such as 80, so it is sometimes necessary to lock the ports
Implemented in/etc/sysconfig/nfs
Port Rpc.mountd should listen on.
mountd_port=892
NFS Practices
Dual Web server +PHP-FPM + NFS + MySQL build discuz forum for dual Web servers to share back-end data.
<?php
namespace App\http\controllers;
Use Illuminate\http\request;
Use app\http\requests;
Use App\http\controllers\controller;
Use laravel\socialite\contracts\factory as socialite;
Use Illuminate\contracts\auth\guard as Auth;
Class Sociallogincontroller extends Controller
{
/**
* @var socialite
*/
protected $socialite;
/**
* @var User
*/
protected $auth;
/**
* @param socialite $socialite
* @param User $user
* @param Auth $auth
*/
protected $request;
function __construct (socialite $socialite, Auth $auth, Request $request)
{
$this->socialite = $socialite;
$this->auth = $auth;
$this->request = $request;
}
/**
* @param $provider
* @param Request $request
* @return \illuminate\http\redirectresponse|\symfony\component\httpfoundation\redirectresponse
*/
Public Function Login ($provider)
{
return $this->execute ($provider, $this->request->has (' Code '));
}
/**
* @param $provider
* @param $hasCode
* @return \illuminate\http\redirectresponse|\symfony\component\httpfoundation\redirectresponse
*/
Public function Execute ($provider, $hasCode)
{
if (! $hasCode)
{return $this->getauthorization ($provider);
}
$user = $this->socialuser ($provider);
/***************************************************************
/*
/* DD ($user->token); Would return something like this: "Somerandomstring1232323123123"
/*
/***************************************************************/
}
/**
* @param $provider
* @return \symfony\component\httpfoundation\redirectresponse
*/
Public Function getauthorization ($provider)
{
return $this->socialite->driver ($provider)->redirect ();
}
/**
* @param $provider
* @return \laravel\socialite\contracts\user
*/
Public Function Socialuser ($provider)
{
return $this->socialite->driver ($provider)->user ();
}
}
As you can see $user->token returns string which contains access tokens, but in order to do it work we need the token In this format.
<?php
Array:5 [%
How to implement NFS (dual httpd + PHP-FPM + NFS + MySQL build discuz forum)