LINBIT / csync2

file synchronization tool using librsync and current state databases
GNU General Public License v2.0
145 stars 39 forks source link

csync2 not syncing files #16

Closed sburnwal closed 4 years ago

sburnwal commented 5 years ago

I am a bit new to csync but I need help in troubleshooting an issue of csync not syncing files between cluster nodes. We have just one group mentioned in /etc/csync2/csync2.cfg with entries for host, key and include directives. csync2 is running in inet mode. Every minute this command is triggered:

csync2 -D /var/lib/csync2 -N node1 -xv And my xinetd has this config for csync2:

service csync2
{
        flags           = REUSE
        socket_type     = stream
        wait            = no
        user            = root
        group           = root
        server          = /usr/sbin/csync2
        server_args     = -i -N node1
        port            = 30865
        type            = UNLISTED
        disable         = no
}

Some questions I have:

sburnwal commented 5 years ago

I was able to make some progress by enabling debug. In a working setup I see this:

Running recursive check for / ...check.c 391
Database-File: sqlite3:///var/lib/csync2/node1.db3
Opening shared library libsqlite3.so
Reading symbols from shared library libsqlite3.so
SQL: SELECT count(*) from file db.c 213
SQL: SELECT filename from file where filename = '/' OR 1=1 ORDER BY filename db.c 213
Match (+): /var/run/bashroot/home/admin on /var/run/bashroot/home/admin groups.c 54
Match (+): /var/run/bashroot/home/admin on /var/run/bashroot/home/admin/test groups.c 54
Match (+): /var/run/bashroot/home/admin on /var/run/bashroot/home/admin/debug groups.c 54
SQL Query finished. db.c 281
Checking /* .. check.c 339

However, for the non-working case, the 'Match (+) ...' lines are missing for the same configuration. So basically looks like the file table in sqlite is not getting populated. Can someone tell me what could be the issue ?

dannyweldon commented 5 years ago

Do you need to use the -r switch on csync2 to make it recursively scan your folders?

What about if you just run this?

csync2 -xvtr
dannyweldon commented 5 years ago

I do not see csync2 running as a service (nothing like /etc/systemd/system/csync2.conf)

Do you see anything listening on port 30865 (such as xinetd) when you run:

netstat -lntp

xinetd will launch csync2 whenever a connection is made to that port. You should only need the server_args to be -i. Try removing the -N node1 part and send xinetd a SIGHUP.

how how and when does csync detects file changes ? Does this happen because of periodically running the command 'csync2 -D /var/lib/csync2 -N node1 -xv' ?

Yes, it will only detect changes when you run csync2 manually or from cron. It will check the local files against it's database and then connect to the other nodes on port 30865 to sync with them automatically, so you shouldn't need to supply the -N switch, or the -D switch if you are are using the default database location. It will figure out the nodes from your csync2.cfg file.

So you will need to make sure that each host can connect to each other on port 30865, but make sure, of course, that those ports are not exposed to anything outside the local network.

sburnwal commented 4 years ago

Thanks Danny for the help! Our sync dir was set to /var/run/abc. Issue was we had recently upgraded the linux from centos 6 to centos 7 and in the new os /var/run is a symlink to /run and looks like csync somehow did not browse through the symlink dirs. After we changed the sync dir to /run/abc, things worked fine, closing this issue.