Solved

lsyncd rsync web servers.

Posted on 2013-05-24
11
2,182 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 18

Author Comment

by:Andrew Davis
Comment Utility
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
Comment Utility
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Good fun was had by all.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now