过程 71.3. Install and setup csync2 on Ubuntu
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
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
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 }
hosts
$ sudo vim /etc/hosts 192.168.245.131 slave
restart
$ sudo /etc/init.d/xinetd restart
例 71.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; }
过程 71.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 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。