In some cases, to achieve load balancing for multiple Windows servers, sharing is required to make the upload space for pictures and attachments.
This is the time to use techniques such as Samba, IIS virtual directories, etc.
The Web server uses upload as the uploaded directory and now requires 2 servers for load balancing, using a Samba server in the background as a file share store
1. Creating a Samba File server
Uninstalling the old Samba components, CentOS 6 installs the 3.6 version by default
For a in ' Rpm-qa|grep samba '; Do rpm-e--nodeps $a;d One
2. Installing Samba 4
Yum-y Install SAMBA4 Samba-common samba4-client
3. Create a shared user
Description: Because Windows is not directly mapped as a site in IIS under a site, you must use a directory such as the original \\192.168.10.2\sns\upload, where the user accessing the share is the user of the application pool.
There are 2 options available at this time:
A.samba use anonymous access to read and write
B. Modifying a site application pool user to access a Samba user
For simplicity we use Samba anonymous access in a read-write way to configure
Create system users and groups for sharing
Groupadd-g 8800 Smbgroup
Useradd-g smbgroup-s/sbin/nologin-d/dev/null smbuser
Create a shared directory
Mkdir/data/share
Chown-r Smbuser.smbgroup/data/share
Chmod-r 755 Smbuser.smbgroup/data/share
4. Configure Samba
/etc/samba/smb.conf
[global] workgroup = workgroup server string = FileServer #hosts allow = 127. 192.168.10 Log file = /var/log/samba/log.%m max log size = 50 security = user passdb backend = tdbsam map to guest = bad user guest account = smbuser create mask = 0775 force create mode = 0775 directory mask = 0775 force directory mode = 0775 unix charset = cp936 dos charset = cp936 use sendfile=yes write raw = yes read raw = yes max xmit=65535 aio read size = 16384 aio write size = 16384[upload] comment = sns Path = /var/www/html/upload browseable = no guest ok = yes writable = yes #valid users = @smbgroup
Description: This value has been deprecated in the Samba 4 version of Share,server. Therefore, configuring anonymous access requires
Security = User Map to Guest = Bad user
5. Test Samba
[[email protected] samba]# testparmload smb config files from /etc/ samba/smb.confprocessing section "[Upload]" Loaded services file ok. Server role: role_standalonepress enter to see a dump of your service definitions# Global parameters[global] dos charset = cp936 unix charset = cp936 server string = fileserver security = USER map to guest = Bad User guest account = smbuser log file = /var/log/samba/log.%m max log size = 50 max xmit = 65535 idmap config * : backend = tdb create mask = 0775 force create mode = 0775 directory mask = 0775 force directory mode = 0775 aio read size = 16384 aio write size = 16384 use sendfile = yes[upload] comment = sns path = /var/www/html/upload read only = no guest ok = Yes browseable = no
6. Set up the start-up service and boot
/ETC/INIT.D/NMB start/etc/init.d/smb startchkconfig NMB onchkconfig SMB on
Part Two: Windows IIS uses shares as a path
Example:
I need to create a PDF virtual path under the Signpdf path of the site
1. Click "Site"-the corresponding signpdf directory, right click on "Signpdf", select "Create virtual directory"
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/86/7A/wKioL1fAAubi488tAABKWHQp_Ww911.png "title=" Qq20160826164735.png "alt=" Wkiol1faaubi488taabkwhqp_ww911.png "/>
2. Enter the alias, we enter "PDF" here, and then select the corresponding physical path.
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/86/7B/wKiom1fAA2qy5LSdAAAV2EfHiEI649.png "title=" 2.png " alt= "Wkiom1faa2qy5lsdaaav2efhiei649.png"/>
Attention:
The physical path here, if shared, cannot use the path of the disk map, for example, I map the share to Z disk, where the z-disk selection is invalid, must use the shared full path
If Samba is not using anonymous access, you will need to select "Connect as", set the corresponding user and password, where users need to add their own to the Windows system, and the user name password can access the share.
|
Problem:
1. After configuring samba, it is found in the directory established on Node A that the B node cannot write because 2 users are consistent but the user's group is inconsistent. For example, a server host named Servera,b Server host name is ServerB, so the rights of a node in Samba is the SERVERA\SMBUSER,B server corresponding to the permissions is Serverb\smbuser, This is an issue that causes 2 server permissions to be inconsistent.
Add in smb.conf
Create mask = 0775 force Create mode = 0775 Directory mask = 0775 force directory mode = 0775
Then restart the service
This article is from "Maple Night" blog, please be sure to keep this source http://fengwan.blog.51cto.com/508652/1843034
CentOS 6.8 Installs Samba 4 as a Windows Shared server