Go to content Go to menu Go to search

csync2 на CentOS7

Установка из репозитория:

Install the EPEL repository, you may try typing yum install epel-release. I think at least Centos 7 has it out of the box.

Install the okay-release RPM. Type:
Centos 6 on 32 bits: rpm -ivh http://repo.okay.com.mx/centos/6/i386/release/okay-release-1-1.noarch.rpm
Centos 6 on 64 bits: rpm -ivh http://repo.okay.com.mx/centos/6/x86_64/release/okay-release-1-1.noarch.rpm
Centos 7 on 64 bits: rpm -ivh http://repo.okay.com.mx/centos/7/x86_64/release/okay-release-1-1.noarch.rpm

yum install xinetd csync2

Установка из исходников:

yum -y install epel-release
yum -y groupinstall "Development Tools"
yum -y install librsync-devel
yum -y install gnutls-devel
yum -y install sqlite-devel
cd /usr/local/src
wget http://oss.linbit.com/csync2/csync2-2.0.tar.gz
tar -xz -f ./csync2-2.0.tar.gz && cd csync2-2.0/
./configure --prefix='/usr/local/csync2'
make
make install
ln -s /usr/local/csync2/sbin/* /sbin/
ln -s /usr/local/csync2/etc/csync2.cfg /etc
mkdir /usr/local/csync2/backups

Настройка

На одном сервере генерируем сертификаты и копируем на все ноды:

cd /usr/local/csync2/etc
openssl genrsa -out csync2_ssl_key.pem 1024
openssl req -new -key csync2_ssl_key.pem -out csync2_ssl_cert.csr
openssl x509 -req -days 600 -in csync2_ssl_cert.csr -signkey csync2_ssl_key.pem -out csync2_ssl_cert.pem
csync2 -k /etc/csync2.cluster.key

scp ./csync2_* root@node2:/usr/local/csync2/etc/
scp /etc/csync2.cluster.key root@node2:/etc/csync2.cluster.key

Пример минимального конфига /etc/csync2.cfg

group all {
    host gw gw1;
    key /etc/csync2.cluster.key;
    backup-directory /usr/local/csync2/backups;
    backup-generations 3;
    auto younger;

    include /usr/local/csync2/etc/csync2.cfg;
    include /tmp/1;


    action {
        pattern /tmp/11/*;
        exec "/etc/init.d/nginx reload";
        logfile "/var/log/csync2.log";
    }
}

Добавляем в xinetd

файл /etc/xinetd.d/csync2

# default: on
# description: csync2
service csync2
{
    flags       = REUSE
    socket_type = stream
    wait        = no
    user        = root
    group       = root
    server      = /usr/local/csync2/sbin/csync2
    server_args = -i -l
    #log_on_failure += USERID
    disable     = no
    # only_from = 192.168.199.3 192.168.199.4
}

Проверим наличие сервиса в /etc/services

# cat /etc/services | grep csync2
csync2          30865/tcp

Запускаем

systemctl restart xinetd

Проверяем

csync2 -xvd

Добавляем в cron /etc/cron.d/csync2

PATH=/sbin:/usr/sbin:/bin:/usr/bin
#m   h  dom mon dow user   command
*/10 *  *   *   *   root   date +%Y-%m-%d\ %H\:%M >> /var/log/csync2.log; /sbin/csync2 -xv >> /var/log/csync2.log 2>&1

Ротация лога:

/etc/logrotate.d/csync2

/var/log/csync2.log {
    missingok
    notifempty
    rotate 2
    size 100k
}


при публикации материалов с данного сайта обратная ссылка на сайт обязательна.
valynkin.ru © no rights reserved