How to test NFS shared sessions?

Source: Internet
Author: User
How to test NFS shared sessions? -- Linux Enterprise Application-Linux server application information. For details, refer to the following section. My two servers are configured according to the NFS shared session below. How can I test whether session NFS sharing is successful or whether session sharing has been successful ???????
First, modify the session. save_path option of php. ini as follows:

Session. save_path = "2;/tmp/php_sess" (remove the semicolon)

The session is stored in the "/tmp/php_sess" directory and divided into two sub-directories. Each sub-directory has 16 sub-directories.


2. assume that the main directory of php is/usr/local/server/php/, create a file/usr/local/server/php/include/php/ext/session/mod_files.sh, the content is as follows:
#! /Bin/sh
# NAME
# Mod_files.sh-Update of the php-source/ext/session/mod_files.sh
#
# SYNOPSIS
# Mod_files.sh basedir depth [numberofsubdirs]
#
# DESCRIPTION
# This script creates the directories tree used by php to store the session files
# (See php. ini-'session. save_path 'option)
#
# Example: if you want php to store the session files in a directory tree
# Of 3 levels of depth containing 32 directories in each directory,
# First, put the setting bellow in the php. ini file:
#
# Session. save_path = "3;/tmp/session"
#
# Now create the basedir directory: 'mkdir/tmp/session'
#
# Then, call this scrip with the following arguments:
#
#./Mod_files.sh./mod_files.sh/tmp/session 3 32

If test "$2" = ""; then
Echo "usage: $0 basedir depth [numberofsubdirs]"
Echo "numberofsubdirs: if unset, defaults to 16. if 32, 32 subdirs, if 64, 64 subdirs ."
Exit 1
Fi

If test "$2" = "0"; then
Exit 0
Fi

Hash_chars = "0 1 2 3 4 5 6 7 8 9 a B c d e f"
If [! -Z $3]; then
If test "$3"-a "$3"-eq "32"; then
Hash_chars = "$ hash_chars g h I j k l m n o p q r s t u v"
If test "$3"-eq "64"; then
Hash_chars = "$ hash_chars w x y z a B c d e f g h I J K L M N O P Q R S T U V W X Y Z -,"
Fi
Fi
Fi

For I in $ hash_chars; do
Newpath = "$1/$ I"
Mkdir $ newpath | exit 1
Sh $0 $ newpath 'expr $2-1' $3
Done



3. After being set to executable, run the following command to create a hash directory:

# Cd/usr/local/server/php/include/php/ext/session/
#./Mod_files.sh/tmp/php_sess 2 16


4. Now, we can set up NFS sharing. Assume that there are three hosts with ip addresses 192.168.0.1 (host name svr1), 192.168.0.2 (host name svr2), and 192.168.0.3 (host name svr3). Now let 192.168.0.1 provide NFS sharing service, configure/etc/exports and add the following content:
/Tmp/php_sess/svr * (rw, no_root_squash)

5. Restart the nfs service to provide NFS sharing for the other two hosts.
Run the following commands on svr2 and svr3 to mount NFS:
# Mkdir/tmp/php_sess
# Mount svr1:/tmp/php_sess (if not, use the IP address)

The disadvantage of using NFS to store sessions is that sessions cannot be automatically cleared after expiration. You must set the recycle mechanism on your own. We can use crontab to periodically recycle sessions. Use the following shell command:
Find/tmp/php_sess-mmin + 30 | xargs rm-fr
Delete the session file 30 minutes ago, add/modify the above content to php. ini on other hosts, and then restart the WEB
Related Article

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.