• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Lsyncd : Examples of Syncing With Cloud Server & Local Host

By Abhishek Ghosh July 5, 2014 11:16 pm Updated on July 5, 2014

Lsyncd : Examples of Syncing With Cloud Server & Local Host

Advertisement

Lsyncd is tool for automatically live mirroring as daemon. Here are Lsyncd usage examples of Syncing and how to configure the excellent tool. The new users who are not aware what are daemons can read this article. On the guide to Setup Separate Database Server on Rackspace Cloud, we have upgraded from usual one server setup used for developmental works. Forget about Database Server for now. There are multiple ways to use multiple main server to balance the load on individual server, like using Pacemaker Heartbeat for High Availability Cloud, using a fully separate server for WP-Admin and so on. Approaches are varied and tailored to custom need.

 

Lsyncd is a Live Syncing or Mirroring Daemon, after proper configuration; the tool watches a directory, aggregates and combines events for a few seconds and then spawns process(es) to synchronize the changes. Lsyncd is a light-weight live mirroring tool suitable for advanced usage on server. Official repository lives here :

Vim
1
2
3
4
# goggle code
https://code.google.com/p/lsyncd/
# github
https://github.com/axkibe/lsyncd

 

Lsyncd : Examples of Syncing With Cloud Server

 

Automation is becoming an important service and we can combine it with Chef Software and OpenStack Cloud, here is cookbook :

Advertisement

---

Vim
1
https://github.com/dgivens/chef-lsyncd

On Rackspace Deployments, there is ready made blueprint which uses Lsyncd. Only if the reader wants to learn or do manual configuration, these commands are needed on Rackspace. Do not run commands blindly, please read the full article first at least once.

Traditionally we can install lsyncd with the following commands and read the examples provided :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
# We are assuming that you are logged in as root
# or has root privilege, do an update if not done recently
apt-get update
# and install lsyncd
apt-get install lsyncd
# docs are here
cd /usr/share/doc/lsyncd/examples && ls
# output
lbash.lua  lgforce.lua      lpostcmd.lua  lrsyncssh.lua
lecho.lua  limagemagic.lua  lrsync.lua
# open the lrsync.lua file
nano lrsync.lua

The above is very painful way to use lsyncd as an automated service which will run on the master server / main server and copy things to the slave server(s). So practically, we will not use apt-get install lsyncd command but will wget the latest version (this is what recommended by Rackspace) and build from source :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
# We are assuming that you are logged in as root
# do an update if not done recently
apt-get update
# install dependencies
apt-get install -y lua5.1 liblua5.1-dev pkg-config rsync asciidoc
cd /var/tmp
# please check the latest version manually and wget
wget http://lsyncd.googlecode.com/files/lsyncd-2.1.5.tar.gz
# 150 kb download, do not worry
tar -xzvf lsyncd-2.1.5.tar.gz
cd lsyncd-2.1.5
export CFLAGS="-march=native -O2"
./configure && make && make install

While writing the guide, I actually used Mac to test, so the screen shot is of OS X 10.9.x’s local computer not of server. I wget-ed it Safari ( pun intended) to test the link of tar ball, so view this one :

Lsyncd Examples of Syncing With Cloud Server Local Host

We deliberately used the same method described by Rackspace to avoid inconvenience by Rackspace (for managed) if you are playing for some reason. Only we used different versions. There is no configuration file in the package, we need to create it :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
nano /etc/init/lsyncd.conf
# example
# copy below this line
description "lsyncd file syncronizer"
start on (starting network-interface
    or starting network-manager
    or starting networking)
stop on runlevel [!2345]
    expect fork
    respawn
        respawn limit 10 5
exec /usr/local/bin/lsyncd /etc/lsyncd.lua
# stop copying at the above line
# symlink to make it auto start
ln -s /lib/init/upstart-job /etc/init.d/lsyncd

We will create a configuration file called “lsyncd.conf.lua” :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
nano /etc/lsyncd.conf.lua
# example code after this line taking you are using Ubuntu 14.04
 
   cat << EOF > /etc/lsyncd.lua
   settings {
        logfile = "/var/log/lsyncd/lsyncd.log",
        statusFile = "/var/log/lsyncd/lsyncd-status.log",
        statusInterval = 20
    }
sync {
    default.rsync,
    source="/var/www/html",
    target="your.rackspace.service-net.ip.address:/var/www/html",
    rsync = {
        compress = true,
        acls = true,
        verbose = true,
        rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no" }
}
EOF

Lua is Language :

Vim
1
http://www.lua.org/start.html

We need to create one more file for Log Rotation at /etc/logrotate.d/lsyncd :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
nano /etc/logrotate.d/lsyncd
# copy after this line
cat << EOF > /etc/logrotate.d/lsyncd
   /var/log/lsyncd/*log {
        missingok
        notifempty
        sharedscripts
        postrotate
        if [ -f /var/lock/lsyncd ]; then
            /sbin/service lsyncd restart > /dev/null 2>/dev/null || true
        fi
        endscript
    }
    EOF

Start the service :

Vim
1
2
3
4
5
start lsyncd
# may be you want to reboot softly
reboot
# touch it to make working
touch /var/www/html/*

But, understand why your other server will accept files? It is the same situation like we had to do for SSH to Server Without Entering Password From Mac (OS X). So, practically do it in cool head :

Vim
1
2
# on main server
ssh-keygen -t rya

Frankly, working on command line is pathetic, login to the main server using FileZilla, cd to ~/.ssh/ id_rsa, copy id_rsa.pub to your local computer. Again, open another session on Filezilla to login to the slave server, upload the file /root/.ssh/ and change the name to master.pub – Slave will have Master pub file on root. SSH to slave server, and run this :

Vim
1
cat ~/.ssh/master.pub >> ~/.ssh/authorized_keys

Now, exit from all sessions. Freshly open one terminal (to avoid human error due to complex steps), ssh to the master server. From the master server, ssh to the slave server – you will get the prompt to accept key, type yes and hit enter.

 

Lsyncd : Examples of Syncing With Cloud Server with Local Computer

 

Basic principle is same but the configuration of Log Rotation and other configuration will change slightly as probably most of us do not use our computers as servers!

Tagged With example lsync d conf , lsyncd autostart , Lsyncd Manual , lsyncd version 2 1 5 configuration file examples , paperuri:(cdd46801cf929c62b8cdb0e0db95d61c)

This Article Has Been Shared 480 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Lsyncd : Examples of Syncing With Cloud Server & Local Host

  • Cloud Computing Privacy and how to protect Privacy in the Cloud

    Cloud Computing Privacy issues makes many administrators skeptical. Here are some tips how to avoid the security loop holes in Cloud Computing.

  • Apple Inc. and Cloud Computing

    Apple Inc. and Cloud Computing means growing and always planning to upgrade a separate from the others service, both in execution as well as by technology.

  • How to Get Started with Cloud Server

    How to Get Started with Cloud Server – be it Rackspace or Amazon or any brand which basically delivers Cloud Server as IaaS so you can allocate RAM yourself.

  • Google Compute Engine : Get Started

    Google Compute Engine has a provision to get a limited free preview after filling a survey like form. Let us look at the form as well as the technical backend.

  • Amazon Cloud Computing : Why it is a Danger to Hosting and Web Services

    Amazon Cloud Computing is a Danger to Hosting and Web Services. What must be clear is that Amazon is expanding rapidly, perhaps too much which is never good.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Cyberpunk Aesthetics: What’s in it Special January 27, 2023
  • How to Do Electrical Layout Plan for Adding Smart Switches January 26, 2023
  • What is a Data Mesh? January 25, 2023
  • What is Vehicular Ad-Hoc Network? January 24, 2023
  • Difference Between Panel Light, COB Light, Track Light January 21, 2023

About This Article

Cite this article as: Abhishek Ghosh, "Lsyncd : Examples of Syncing With Cloud Server & Local Host," in The Customize Windows, July 5, 2014, January 28, 2023, https://thecustomizewindows.com/2014/07/lsyncd-examples-syncing-cloud-server-local-host/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT