zoukankan      html  css  js  c++  java
  • mysql tcp 4层负载

    -bash-4.1# cat /etc/haproxy/haproxy.cfg
    global
            log 127.0.0.1   local3 
            maxconn 65535 
            chroot /usr/local/haproxy
            uid 500
            gid 500
            daemon
    	tune.ssl.default-dh-param 2048
    
    defaults
            log     global
            maxconn 65535
            timeout connect 5000
            timeout client  50000
            timeout server 50000
    
            timeout check   5s
    listen mysql *:3306
    	mode tcp
    	balance roundrobin
    	server mysql1 192.168.32.161:3306 weight 1 check port 3306 maxconn 200
    	server mysql2 192.168.32.64:3306 weight 1 check port 3306 maxconn 200
    -bash-4.1# cat /etc/haproxy/haproxy.cfg
    global
            log 127.0.0.1   local3 
            maxconn 65535 
            chroot /usr/local/haproxy
            uid 500
            gid 500
            daemon
    	tune.ssl.default-dh-param 2048
    
    defaults
            log     global
            maxconn 65535
            timeout connect 5000
            timeout client  50000
            timeout server 50000
    
            timeout check   5s
    listen mysql *:3306
    	mode tcp
    	balance roundrobin
    	server mysql1 192.168.32.161:3306 weight 1 check port 3306 maxconn 200
    	server mysql2 192.168.32.64:3306 weight 1 check port 3306 maxconn 200
    	
    	[root@dr-mysql01 sbin]# cat test.pl 
    use DBI;  
    my $dbUser='DEVOPS';    
    my $user="root";    
    my $passwd="1234567";   
    my @arr2="";    
    my $dbh  = DBI->connect("dbi:mysql:database=DEVOPS;host=192.168.32.152;port=3306",$user,$passwd) or die "can't connect to database ". DBI-errstr;  
    my $hostSql = qq{select  username,password,authority from  user };   
    my ($a1, $a2, $a3,$a4,$a5,$a6,$a7,$a8,$a9);    
    my $selStmt = $dbh->prepare($hostSql);    
    $selStmt->execute();    
    $selStmt->bind_columns(undef, $a1, $a2, $a3);    
    $selStmt->execute();    
    while( $selStmt->fetch() ){ push (@arr2, "$a1  $a2  $a3
    " );  
    };  
    print "@arr2 is @arr2
    "
    [root@dr-mysql01 sbin]# perl test.pl 
    @arr2 is  liu  1234567  1
    
    [root@dr-mysql01 sbin]# perl test.pl 
    @arr2 is  aa  1  1
    	
    	
    	
    	
    	
    	
    	
    	
    	
    	
      
  • 相关阅读:
    网上购物商城管理系统-毕业设计
    中国购物管理系统-毕业设计
    网上购物管理系统-毕业设计
    网上商城管理系统-课程设计
    公益捐赠管理系统-毕业设计
    校园图书捐赠管理系统-毕业设计
    电子商务商城管理系统-毕业设计
    超市会员管理系统-毕业设计
    天猫商城管理系统-毕业设计
    高校校园设备管理系统-毕业设计
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6200055.html
Copyright © 2011-2022 走看看