perl 安装Net::ZooKeeper

<pre name="code" class="python"><pre name="code" class="python"> use Net::ZooKeeper qw(:node_flags :acls);

  my $zkh = Net::ZooKeeper->new('localhost:7000');
  
  
zjzc01:/zookeeper/server1# cd src
zjzc01:/zookeeper/server1/src# cd c
zjzc01:/zookeeper/server1/src/c# ls
acinclude.m4    c-doc.Doxyfile  config.guess  configure.ac  INSTALL     Makefile.am  README         zookeeper.vcproj
aclocal.m4      ChangeLog       config.h.in   depcomp       install-sh  Makefile.in  src
aminclude.am    Cli.vcproj      config.sub    generated     LICENSE     missing      tests
autom4te.cache  compile         configure     include       ltmain.sh   NOTICE.txt   zookeeper.sln
zjzc01:/zookeeper/server1/src/c# ./configure

zjzc01:/zookeeper/server1/src/c# make

zjzc01:/zookeeper/server1/src/c# make install

zjzc01:/zookeeper/server1/src/c# ./cli_mt 192.168.32.34:2181
Watcher SESSION_EVENT state = CONNECTED_STATE
Got a new session id: 0x15436e4ca970005
ls /
time = 3 msec
/: rc = 0
	dubbo
	zookeeper
time = 3 msec

[root@rocket c]# ./configure

[root@rocket c]# make

[root@rocket c]# make install


然后再安装模块:
zjzc01:/root# cpan Net::ZooKeeper

查看模块安装:

zjzc01:/usr/local/perl/lib/site_perl/5.22.1/Test/TCP# perldoc -l Net::ZooKeeper
/usr/local/perl/lib/site_perl/5.22.1/x86_64-linux/Net/ZooKeeper.pm

zjzc01:/root# cat zook.pl 
  use Net::ZooKeeper qw(:node_flags :acls);

  my $zkh = Net::ZooKeeper->new('192.168.32.34:2181');

  $zkh->create('/foo', 'bar',
               'flags' => ZOO_EPHEMERAL,
               'acl' => ZOO_OPEN_ACL_UNSAFE) or
    die("unable to create node /foo: " . $zkh->get_error() . "\n");

  print "node /foo has value: " . $zkh->get('/foo') . "\n"
zjzc01:/root# perl zook.pl 
node /foo has value: bar








[zk: localhost:2181(CONNECTED) 16] create /zk "mydata"
Created /zk
[zk: localhost:2181(CONNECTED) 17] get /zk
mydata
cZxid = 0x1000000ef
ctime = Thu Apr 21 13:08:24 CST 2016
mZxid = 0x1000000ef
mtime = Thu Apr 21 13:08:24 CST 2016
pZxid = 0x1000000ef
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 6
numChildren = 0

zjzc01:/root# cat zook.pl 
  use Net::ZooKeeper qw(:node_flags :acls);

  my $zkh = Net::ZooKeeper->new('192.168.32.34:2181');

  $zkh->create('/foo', 'xxxxyyyy',
               'flags' => ZOO_EPHEMERAL,
               'acl' => ZOO_OPEN_ACL_UNSAFE) or
    die("unable to create node /foo: " . $zkh->get_error() . "\n");

  print "node /foo has value: " . $zkh->get('/foo') . "\n";
  print "node /zk has value: " . $zkh->get('/zk') . "\n";
  print "node /liu has value: " . $zkh->get('/liu') . "\n"
zjzc01:/root# perl zook.pl 
node /foo has value: xxxxyyyy
node /zk has value: mydata
node /liu has value: testdata112233


 
 
 

你可能感兴趣的:(perl 安装Net::ZooKeeper)