• zookeeper 手动T掉已挂节点


    zjtest7-redis:/root/zk# cat test_zk.pl 
    use ZooKeeper;
    use AnyEvent;
    use AE;
    use Data::Dumper;
    use IO::Socket;
         sub check_port {
                          my $server='120.55.118.6';
                          my $port=shift;
                                  $sock = IO::Socket::INET->new(PeerAddr => $server,
                                  PeerPort => $port,
                                  Proto => 'tcp');
                                 if ($sock)
                                    {return 1}
                                 else
                                    {return 0 };
                       }; 
       
        my @port=(2181,2182,2183);
        @zk_port=();
        foreach $port  (@port){
           my $result =&check_port($port);
           if ($result == 1){ push  (@zk_port,$port)};
                     };
        print "@zk_port is @zk_port
    "; 
    
        my @ip_list=();
        if (scalar(@zk_port)==3){
         print "333333333333333333333333
    ";
         $zk = ZooKeeper->new(hosts => '120.55.118.6:2181,120.55.118.6:2182,120.55.118.6:2183') ;
         };
    
        if (scalar(@zk_port)==2){
             print "22222222222222222
    ";
             $zk = ZooKeeper->new(hosts => "120.55.118.6:$zk_port[0],120.55.118.6:$zk_port[1]");
       };   
       #my $zk = ZooKeeper->new(hosts => '120.55.118.6:2182,120.55.118.6:2183') ;
        print "--------------------
    "; 
        eval { 
        my $stat = $zk->exists('/mysql/0001');
        if  ($stat){
             $mysql_ip =   $zk->get('/mysql/0001');
             print $mysql_ip."
    ";
                 }
             else{
                $mysql_ip =   $zk->get('/mysql/0002');
                print $mysql_ip."
    ";
                 };
      
         use DBI;
         my $database='zjzc';  
         my $user="zjzc_app";  
         my $passwd="1234567"; 
         my @arr2=();  
         my $dbh  = DBI->connect("dbi:mysql:database=$database;host=$mysql_ip;port=3306",$user,$passwd,{  
                              RaiseError => 1,  
                              AutoCommit => 0
                               } ) or die "can't connect to database ". DBI-errstr;
        my $hostSql = qq{select  id,name from scan; }; 
        my ($a1, $a2, $a3,$a4,$a5,$a6,$a7,$a8,$a9);  
        my $selStmt = $dbh->prepare($hostSql);  
        $selStmt->execute();  
        $selStmt->bind_columns(undef, $a1, $a2);  
        $selStmt->execute();  
        while( $selStmt->fetch() )
             { push (@arr2, "$a1  $a2  $a3
    " );
             };
            print "@arr2 is @arr2
    ";
            $dbh->disconnect;
            };
    zjtest7-redis:/root/zk# perl test_zk.pl 
    @zk_port is 2182 2183
    22222222222222222
    --------------------
    192.168.32.6
    @arr2 is 1  aaabbb  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe  
     2  cccddeqe 
    
    
    
    
    当zk 节点 比如这里2181 挂后,需要手动程序了T掉已挂节点
    

  • 相关阅读:
    机器学习规则:ML工程最佳实践----rules_of_ml section 2【翻译】
    机器学习规则:ML工程最佳实践----rule_of_ml section 3【翻译】
    知识图谱技术分享会----有关知识图谱构建的部分关键技术简介及思考
    【e2Open】
    【2B】企业供应链管理软件
    【交互】复杂逻辑配置的一个不错的方法(神策数据)
    【视觉】交易数据展示
    【视觉】数据平台
    【设计复盘】APP设计复盘
    【设计规范】腾讯课堂
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350399.html
Copyright © 2020-2023  润新知