====== Как собрать csync2 под CentOS 6.0 x86_64 ======
Для начала добавляем отсутствующие пакеты для сборки:
yum install -y sqlite-devel librsync librsync-devel
Сам проект вроде как живет по адресу [[http://oss.linbit.com/csync2]]
Сначала берем последнюю версию csync2
# cd ~
# mkdir git
# cd git
# git clone http://git.linbit.com/csync2.git
Initialized empty Git repository in /home/linko/git/csync2/.git/
Выясняем, что мы там скачали
# cd csync2
# cat csync2.spec | grep -e ^Version -e ^Release
Version: 2.0
Release: 0.1.rc1
Значит, будем строить версию csync2-2.0
# cd ..
# cp -R csync2 csync2-2.0
# rm -R csync2-2.0/.git
csync2.spec в оригинальной поставке кривая. Кривость заключается в том, что там нет генерации сертификатов, патча для xinetd и все пихается в /etc, а не в /etc/csync2, а так же нет очистки каталога со своими данными.
Делаем свою **csync2.spec**, ее надо разместить в файле ~/rpmbuild/SPECS/csync2.spec
Summary: Cluster synchronization tool
Name: csync2
Version: 2.0
Release: 0.1.rc1
Group: Applications/System
License: GPLv2+
URL: http://oss.linbit.com/csync2/
Source0: csync2-%{version}.tar.gz
Source1: csync2-README.quickstart
Patch0: csync2-fix-xinetd.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
Requires(post): openssl
Requires: xinetd
BuildRequires: sqlite-devel sqlite librsync gnutls-devel librsync-devel
%description
Csync2 is a cluster synchronization tool. It can be used to keep files on
multiple hosts in a cluster in sync. Csync2 can handle complex setups with
much more than just 2 hosts, handle file deletions and can detect conflicts.
It is expedient for HA-clusters, HPC-clusters, COWs and server farms.
%prep
%setup -q
%patch0 -p1 -b .fix-xinetd
install -p -m 644 %{SOURCE1} README.quickstart
%build
%configure --sysconfdir=%{_sysconfdir}/csync2
make %{?_smp_mflags}
%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
mkdir -p %{buildroot}%{_var}/lib/csync2
install -p -D -m 644 csync2.xinetd %{buildroot}%{_sysconfdir}/xinetd.d/csync2
# We need these empty files to be able to %%ghost them
touch %{buildroot}%{_sysconfdir}/csync2/csync2_ssl_key.pem
touch %{buildroot}%{_sysconfdir}/csync2/csync2_ssl_cert.pem
%clean
rm -rf %{buildroot}
%post
umask 077
if [ ! -f %{_sysconfdir}/csync2/csync2_ssl_key.pem ]; then
/usr/bin/openssl genrsa -rand /proc/apm:/proc/cpuinfo:/proc/dma:/proc/filesystems:/proc/interrupts:/proc/ioports:/proc/pci:/proc/rtc:/proc/uptime 1024 > %{_sysconfdir}/csync2/csync2_ssl_key.pem 2>/dev/null
fi
FQDN=`hostname`
if [ "x${FQDN}" = "x" ]; then
FQDN=localhost.localdomain
fi
if [ ! -f %{_sysconfdir}/csync2/csync2_ssl_cert.pem ]; then
cat << EOF | /usr/bin/openssl req -new -key %{_sysconfdir}/csync2/csync2_ssl_key.pem -x509 -days 3000 -out %{_sysconfdir}/csync2/csync2_ssl_cert.pem 2>/dev/null
--
SomeState
SomeCity
SomeOrganization
EOF
fi
%preun
# Cleanup all databases upon last removal
if [ $1 -eq 0 ]; then
%{__rm} -f %{_var}/lib/csync2/*
fi
%files
%defattr(-,root,root,-)
%doc README README.quickstart AUTHORS COPYING
%dir %{_sysconfdir}/csync2/
%config(noreplace) %{_sysconfdir}/csync2/csync2.cfg
%config(noreplace) %{_sysconfdir}/xinetd.d/csync2
%ghost %config %{_sysconfdir}/csync2/csync2_ssl_key.pem
%ghost %config %{_sysconfdir}/csync2/csync2_ssl_cert.pem
%{_sbindir}/csync2
%{_sbindir}/csync2-compare
%{_mandir}/man1/csync2.1*
%dir %{_var}/lib/csync2/
%changelog
* Tue Nov 13 2007 Matthias Saou 1.34-4
- Change configuration directory to be /etc/csync2/ since the program requires
quite a few files, and putting all of them in /etc/ was messy.
- Include certificate generation upon package installation, based on mod_ssl.
- Rewrite the csync2-README.quickstart file.
- Remove db files upon last removal.
* Tue Nov 13 2007 Matthias Saou 1.34-1
- Take ownership of the package.
- Update to 1.34.
* Tue Mar 27 2007 1.33-5
- Fix ownership of documentation directory (bz 233954)
* Thu Jan 25 2007 1.33-4
- Included a README.fedora with instructions on how to create a self-signed
certificate
- Included a mkcert.sh script to create a self-signed certificate
- Removed the creation of ssl certificate from the %%install section
* Wed Jan 22 2007 1.33-3
- Fixed the xinetd file so there's no need to specify the port in /etc/services
- Create ssl certificates
* Mon Jan 22 2007 1.33-2
- Some cleanups as per bz review 223633
* Sat Jan 20 2007 1.33-1
- Initial import
Так же туда же в каталог ~/rpmbuild/SOURCES надо положить еще два файла: **~/rpmbuild/SOURCES/csync2-fix-xinetd.patch**:
--- csync2-1.33/csync2.xinetd.fix-xinetd 2007-01-24 21:18:04.000000000 +0100
+++ csync2-1.33/csync2.xinetd 2007-01-24 21:19:47.000000000 +0100
@@ -1,4 +1,4 @@
-# default: on
+# default: off
# description: csync2
service csync2
{
@@ -9,7 +9,9 @@
group = root
server = /usr/sbin/csync2
server_args = -i
+ port = 30865
+ type = UNLISTED
#log_on_failure += USERID
- disable = no
+ disable = yes
# only_from = 192.168.199.3 192.168.199.4
}
FIXME В связи с тем, что в виках режутся табы, а патч без этого не работает, при этом надо что бы файл был не в виде прикрепленного файла а как текст на вики страницах, приходится изголяться так:
echo "LS0tIGNzeW5jMi0xLjMzL2NzeW5jMi54aW5ldGQuZml4LXhpbmV0ZCAgICAgICAg
MjAwNy0wMS0yNCAyMToxODowNC4wMDAwMDAwMDAgKzAxMDAKKysrIGNzeW5jMi0x
LjMzL2NzeW5jMi54aW5ldGQgICAyMDA3LTAxLTI0IDIxOjE5OjQ3LjAwMDAwMDAw
MCArMDEwMApAQCAtMSw0ICsxLDQgQEAKLSMgZGVmYXVsdDogb24KKyMgZGVmYXVs
dDogb2ZmCiAjIGRlc2NyaXB0aW9uOiBjc3luYzIKIHNlcnZpY2UgY3N5bmMyCiB7
CkBAIC05LDcgKzksOSBAQAogCWdyb3VwCQk9IHJvb3QKIAlzZXJ2ZXIJCT0gL3Vz
ci9zYmluL2NzeW5jMgogCXNlcnZlcl9hcmdzCT0gLWkKKwlwb3J0CQk9IDMwODY1
CisJdHlwZQkJPSBVTkxJU1RFRAogCSNsb2dfb25fZmFpbHVyZQkrPSBVU0VSSUQK
LQlkaXNhYmxlCQk9IG5vCisJZGlzYWJsZQkJPSB5ZXMKIAkjIG9ubHlfZnJvbQk9
IDE5Mi4xNjguMTk5LjMgMTkyLjE2OC4xOTkuNAogfQo=" | openssl base64 -d > ~/rpmbuild/SOURCES/csync2-fix-xinetd.patch
И файл **~/rpmbuild/SOURCES/csync2-README.quickstart**
Getting started with csync2 :
There's no need to define the port for csync2 in /etc/services, although the
manual says so. Port 30865/tcp is defined in /etc/xinetd.d/csync2. All commands
detailed here need to be executed as root, so be extra careful.
The config file for csync2 is /etc/csync2/csync2.cfg. Here is an example :
mygroup {
host host1;
host host2;
key /etc/csync2/mygroup.key;
include /etc/csync2/csync2.cfg;
include /etc/testfile;
}
This will sync the csync2 configuration and /etc/testfile between host1 and
host2. Create the file on host1. Note that hostnames need to be the FQDN
returned by "hostname".
Generate the pre-shared key used for authentication :
csync2 -k /etc/csync2/mygroup.key
Copy the configuration file and the pre-shared key to host2:
scp /etc/csync2/csync2.cfg /etc/csync2/mygroup.key host2:/etc/csync2/
The SSL key and certificate are generated upon package installation, but you
can replace them with your own if you like. The files are :
/etc/csync2/csync2_ssl_key.pem
/etc/csync2/csync2_ssl_cert.pem
The csync2 service is disabled by default. To start it on both your hosts :
chkconfig csync2 on
chkconfig --level 345 xinetd on
service xinetd restart
If you are running iptables, you need to open tcp port 30865 on both hosts so
that the other host can connect.
Now you should be able to run and initial verbose sync on both hosts :
csync2 -xv
Once everything looks good, you can add a file with the following line as
/etc/cron.d/csync2 or add it to /etc/crontab :
*/5 * * * * root csync2 -x
Happy syncing!
Делаем хитрый финт ушами что бы появился файл **configure**, иначе собираться ничего не будет:
# cd ~/git/csync2-2.0
# ./autogen.sh
Создаем архив с исходниками
# cd ~/git
# tar -pczf csync2-2.0.tar.gz csync2-2.0
Подсовываем его в каталог **~/rpmbuild/SOURCES**
# cp csync2-2.0.tar.gz ~/rpmbuild/SOURCES
Заходим в каталог с **csync2.spec** и строим .rpm файл.
# cd ~/rpmbuild/SPECS/
# rpmbuild -bp csync2.spec
# rpmbuild -ba csync2.spec
В случае успеха у нас должно получится в каталоге **~/rpmbuild/RPMS/x86_64** два rpm файла:
* csync2-2.0-0.1.rc1.x86_64.rpm
* csync2-debuginfo-2.0-0.1.rc1.x86_64.rpm
Которые можно устанавливать.
======= Дополнение =======
Если собирать rpm из git сразу - то работать не будет.
Как оказалось, там сейчас бага, которая описана поссылкам
* [[http://lists.linbit.com/pipermail/csync2/2011-July/000763.html]]
* [[http://git.linbit.com/?p=csync2.git;a=commit;h=2d459f6cab22b9c4f682b02b6b21e12cf27c23df]]
Далее - собирается все без поддержки ssl, поэтому надо в начало конфигурационного файла добавить
nossl * *;