CentOS 7에 Zookeeper 3.4.9 C client library 빌드 하기

주키퍼 C 라이브러리 빌드

$ wget http://apache.org/dist/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz $ tar -xvzf zookeeper-3.4.9.tar.gz $ cd zookeeper-3.4.9/src/c # cppunit 없으면 설치 $ yum -y install cppunit-devel # autoconf 버전은 2.59이상이어야 한다. # 버전 확인법 autoconf -V $ autoreconf -if $ ./configure $ make $ make install


샘플 코드

샘플 실행

$ g++ -std=c++11 hellozookeeper.cpp -o hellozookeeper -lzookeeper_mt ./hellozookeeper 2016-09-23 10:28:45,856:27919(0x7f348e9d0740):ZOO_INFO@log_env@726: Client environment:zookeeper.version=zookeeper C client 3.4.9 2016-09-23 10:28:45,856:27919(0x7f348e9d0740):ZOO_INFO@log_env@730: Client environment:host.name=CRD-AP-GMS00001 2016-09-23 10:28:45,856:27919(0x7f348e9d0740):ZOO_INFO@log_env@737: Client environment:os.name=Linux 2016-09-23 10:28:45,856:27919(0x7f348e9d0740):ZOO_INFO@log_env@738: Client environment:os.arch=3.10.0-229.el7.x86_64 2016-09-23 10:28:45,856:27919(0x7f348e9d0740):ZOO_INFO@log_env@739: Client environment:os.version=#1 SMP Fri Mar 6 11:36:42 UTC 2015 2016-09-23 10:28:45,856:27919(0x7f348e9d0740):ZOO_INFO@log_env@747: Client environment:user.name=root 2016-09-23 10:28:45,857:27919(0x7f348e9d0740):ZOO_INFO@log_env@755: Client environment:user.home=/root 2016-09-23 10:28:45,857:27919(0x7f348e9d0740):ZOO_INFO@log_env@767: Client environment:user.dir=/tmp/project/hellozookeeper 2016-09-23 10:28:45,857:27919(0x7f348e9d0740):ZOO_INFO@zookeeper_init@800: Initiating client connection, host=172.20.30.141:2181 sessionTimeout=10000 watcher=0x401228 sessionId=0 sessionPasswd=<null> context=(nil) flags=0 2016-09-23 10:28:45,857:27919(0x7f348d51c700):ZOO_INFO@check_events@1728: initiated connection to server [172.20.30.141:2181] 2016-09-23 10:28:45,865:27919(0x7f348d51c700):ZOO_INFO@check_events@1775: session establishment complete on server [172.20.30.141:2181], sessionId=0x157509d62b6000b, negotiated timeout=10000 state:ZOO_CONNECTED_STATE event:ZOO_SESSION_EVENT myData:testall 2016-09-23 10:28:55,871:27919(0x7f348e9d0740):ZOO_INFO@zookeeper_close@2527: Closing zookeeper sessionId=0x157509d62b6000b to [172.20.30.141:2181]