4.4. csync2 - cluster synchronization tool

简介:

homepage: http://oss.linbit.com/

4.4.1. server

过程 4.3. Install and setup csync2 on Ubuntu

  1. installation

    $ sudo apt-get install csync2 sqlite3 openssl xinetd
    			

    The following line will be added to your /etc/inetd.conf file:

    $ cat /etc/inetd.conf
    csync2          stream  tcp     nowait  root    /usr/sbin/csync2        csync2 -i			
    			

    If you are indeed using xinetd, you will have to convert the above into /etc/xinetd.conf format, and add it manually.

    service csync2
    {
    	disable = no
    	protocol = tcp
    	socket_type = stream
    	wait = no
    	user = root
    	server = /usr/sbin/csync2
    	server_args = -i
    }			
    			

    /etc/services

    $ cat /etc/services |grep csync2
    csync2          30865/tcp                       # cluster synchronization tool
    			
  2. create a self-signed SSL certificate for csync2

    sudo openssl genrsa -out /etc/csync2_ssl_key.pem 1024
    sudo openssl req -new -key /etc/csync2_ssl_key.pem -out /etc/csync2_ssl_cert.csr
    sudo openssl x509 -req -days 600 -in /etc/csync2_ssl_cert.csr -signkey /etc/csync2_ssl_key.pem -out /etc/csync2_ssl_cert.pem			
    			

    $ sudo csync2 -k /etc/csync2_ssl_cert.key			
    			
  3. After having done everything, we are now going to configure Csync2 so that we can determine which files are going to be synchronized.

    For this example, we are going to synchronize /etc/apache2 and /etc/mysql. For that we open /etc/csync2.cfg and we configure it like this:

    $ sudo vim /etc/csync2.cfg
    # please see the REAMDE file how to configure csync2
    
    group testing #group name, we can have multiple groups
    {
        host master; #master server
        host (slave); #slave server
        #host (node1);
    
        key /etc/csync2_ssl_cert.key;
    
        include /etc/apache2/;
        include /home/neo;
    
        backup-directory /var/backups/csync2;
        backup-generations 3;
        auto none; #no automatic sync
    }
    			
  4. hosts

    $ sudo vim /etc/hosts			
    192.168.245.131 slave			
    			
  5. restart

    $ sudo /etc/init.d/xinetd restart			
    			

4.4.2. node

过程 4.4. node

  1. login to slave node

    neo@slave:~$ sudo vim /etc/hosts			
    192.168.245.129 master			
    			
  2. install

    $ sudo apt-get install csync2 xinetd			
    			
  3. copy config file from master

    neo@slave:~$  sudo scp root@master:/etc/csync2* /etc/			
    			
  4. restart

    neo@slave:~$ sudo /etc/init.d/xinetd restart
    			

4.4.3. test

过程 4.5. testing

  1. master

    neo@master:/etc/apache2$ sudo touch test.master
    neo@master:/etc/apache2$ sudo csync2 -x
    				
  2. node

    neo@slave:/etc/apache2$ ls test.master -l
    -rw-r--r-- 1 root root 0 2008-10-31 06:37 test.master				
    				

4.4.4. Advanced Configuration

例 4.7. /etc/csync2.cfg

$ sudo cat /etc/csync2.cfg

# please see the REAMDE file how to configure csync2
# group name, we can have multiple groups

group www {
    host master;
    host (slave);

    key /etc/csync2_ssl_cert.key;

    include /etc/apache2/;
    include /etc/csync2.cfg;
    include /var/www;
    include %homedir%/neo;
    exclude %homedir%/neo/temp;
    exclude *~ .*;

action
{
        pattern /etc/apache2/httpd.conf;
        pattern /etc/apache2/sites-available/*;
        exec "/usr/sbin/apache2ctl graceful";
        logfile "/var/log/csync2_action.log";
        do-local;
}

    backup-directory /var/backups/csync2;
    backup-generations 3;
    auto none;
}

prefix homedir
{
        on *: /home;
}			
			

4.4.5. 编译安装

过程 4.6. 

  • # yum install byacc -y
    				
    				
    # tar zxvf librsync-0.9.7.tar.gz
    # cd librsync-0.9.7
    ./configure --prefix=/usr/local/librsync-0.9.7
    # make && make install
    				
    				
    # www.sqlite.org
    # wget http://www.sqlite.org/sqlite-3.7.2.tar.gz
    # tar zxvf sqlite-3.7.2.tar.gz
    				
    # www.gnu.org/software/gnutls/
    # wget http://ftp.gnu.org/pub/gnu/gnutls/gnutls-2.10.1.tar.bz2
    # tar jxvf gnutls-2.10.1.tar.bz2
    				
    # wget http://oss.linbit.com/csync2/csync2-1.34.tar.gz
    # tar csync2-1.34.tar.gz
    # ./configure --prefix=/usr/local/csync2-1.34 --with-librsync-source=/usr/local/src/librsync-0.9.7.tar.gz --with-libsqlite-source=/usr/local/src/sqlite-3.7.2.tar.gz --disable-gnutls
    				




原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

目录
相关文章
|
9月前
|
SQL Windows Perl
Configuring Automated Maintenance Tasks
Configuring Automated Maintenance Tasks
53 0
|
资源调度
yarn 错误:There appears to be trouble with your network connection. Retrying…
yarn 错误:There appears to be trouble with your network connection. Retrying…
1435 0
|
5月前
|
SQL Java
flywa报错Detected resolved migration not applied to database: 20221103.10000
flywa报错Detected resolved migration not applied to database: 20221103.10000
95 2
|
7月前
|
数据库 开发工具 开发者
【Python】已解决:You have 18 unapplied migration(s). Your project may not work properly until you apply t
【Python】已解决:You have 18 unapplied migration(s). Your project may not work properly until you apply t
296 0
|
9月前
error: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
error: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
204 0
This job is stuck, because the project doesn‘t have any runners online assigned to it. Go to Runners
This job is stuck, because the project doesn‘t have any runners online assigned to it. Go to Runners
This job is stuck, because the project doesn‘t have any runners online assigned to it. Go to Runners
|
消息中间件 数据库管理
Mnesia reports that this RabbitMQ cluster has experienced a network partition.
Mnesia reports that this RabbitMQ cluster has experienced a network partition.
207 0
|
索引
问题复盘:Kibana did not load properly. Check the server output for more information
问题复盘:Kibana did not load properly. Check the server output for more information
473 0
问题复盘:Kibana did not load properly. Check the server output for more information
|
网络协议 Apache 开发工具