Solved

lsyncd rsync web servers.

Posted on 2013-05-24
11
2,250 Views
Last Modified: 2013-05-24
Hi guys,
Very new to Linux, so be gentle and spell things out for me ;)

System
2 x Centos servers (Master, Slave)

both host the same website sitting behind a loadbalancer (Least active connections).

I keep the servers in replicating the Master to the Slave.
Using Lsyncd.

Issue:-
all is working, however when files/directories transfer to the slave their owner and group change to root:root.
I can fix it by using chown, but would like it if they kept there owner:group (they are same on both machines) or inherited from their parent directory. Either would do.

here is a copy of /etc/lsyncd.lua
settings {
   logfile = "/var/log/lsyncd/lsyncd.log",
   statusFile = "/var/log/lsyncd/lsyncd-status.log",
   statusInterval = 2
}

sync {
	default.rsync,
	source="/home/mysite/public_html/",
	target="10.176.6.23:/home/mysite/public_html/",
	excludeFrom="/etc/lsyncd-excludes.txt",
	rsync = {
		compress = true,
		acls = true,
		verbose = true,
		rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"
	}
}

Open in new window


Any assistance would be appreciated.

Cheers
Andrew
0
Comment
Question by:Andrew Davis
  • 7
  • 4
11 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39194022
Include

rsyncOpts="-lptgoD"

inside this block:


rsync = {
            compress = true,
            acls = true,
            verbose = true,
            rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"
            rsyncOpts="-lptgoD"
      }


See "man rsync" for the meaning of the single option letters.

In brief:

l = copy symlinks as symlinks
p = preserve permissions
t = preserve modification times
g = preserve group
o = preserve owner
D = preserve device files / preserve special files

This will have no effect on existing files, so best start over with empty target directories.
0
 
LVL 18

Author Comment

by:Andrew Davis
ID: 39194474
now i get the error:

Starting lsyncd: Error: error loading /etc/lsyncd.lua: /etc/lsyncd.lua:17: '}' expected (to close '{' at line 12) near 'rsyncOpts'

Double checked all the close brackets are there, an if i just delete the line rsyncOpts="-lptgoD"

I can then start the service again. Makes no sense. If it matters I am using nano to edit.

Cheers
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39194500
Sorry, I made a mistake when posting the example - there is a comma missing past
rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"

rsync = {
            compress = true,
            acls = true,
            verbose = true,
            rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no",
            rsyncOpts="-lptgoD"
      }
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 18

Author Comment

by:Andrew Davis
ID: 39194516
That makes sense ;)

Now i get

Starting lsyncd: Error: error preparing /etc/lsyncd.lua: Parameter "rsync.rsyncOpts" unknown. (if this is not a typo add it to checkgauge)

Duh :(
0
 
LVL 18

Author Comment

by:Andrew Davis
ID: 39194539
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39194575
OK,

seems the've introduced a new set of parameters with lsyncd 2.1.

So try the single options as described in your link, like "owner", "perms" etc.

You could also try "archive=true" which should include all required flags (if it's at all comparable to the rsync option "--archive", that is).
0
 
LVL 18

Author Comment

by:Andrew Davis
ID: 39194586
tried

owner = true,
perms = true

This did the owner but not the group :(
Would be nice if they gave you a bit of a description as to what each setting is.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 39194605
Strange.

Maybe they just forgot to mention "group" in their docs??

I'd try "group=true" and also "archive=true" and see what happens.
0
 
LVL 18

Author Comment

by:Andrew Davis
ID: 39194613
Thanks heaps for your assistance.

I tried the Archive = True (it wasnt mentioned either) and this worked.
I will give "group" a try out of curiosity. Hell what else am i going to do while waiting for SQL replications ;)

Cheers
Andrew
0
 
LVL 18

Author Comment

by:Andrew Davis
ID: 39194627
Yep Group works as well.

Any idea where i am likely to find a complete table with explanations?

Cheers
0
 
LVL 18

Author Closing Comment

by:Andrew Davis
ID: 39194630
Good fun was had by all.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document is written for Red Hat Enterprise Linux AS release 4 and ORACLE 10g.  Earlier releases can be installed using this document as well however there are some additional steps for packages to be installed see Metalink. Disclaimer: I hav…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question