vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Forum and Server Management (https://vborg.vbsupport.ru/forumdisplay.php?f=232)
-   -   Multiple hostnames in the config.php for load balancing / round robin (https://vborg.vbsupport.ru/showthread.php?t=241933)

SnapOff Racing 05-05-2010 09:27 PM

Multiple hostnames in the config.php for load balancing / round robin
 
I am wondering if under the ****** MASTER DATABASE SERVER NAME AND PORT ****** I can add multiple hostnames that will point to one server that is hosting the database but yet that same server has 3 different WAN connections pointing to it. So basically it would look like this in config.php

// ****** MASTER DATABASE SERVER NAME AND PORT ******
// This is the hostname or IP address and port of the database server.
// If you are unsure of what to put here, leave the default values.
$config['MasterServer']['servername'] = '123.123.123.1';
$config['MasterServer']['servername'] = '123.123.123.2';
$config['MasterServer']['servername'] = '123.123.123.3';
$config['MasterServer']['port'] = 3306;

Will vbulletin automatically round robin these entries or will it only use the first connection and then just ignore the rest??

Dismounted 05-06-2010 06:13 AM

That will use whichever you place last. Use:
PHP Code:

$servers = array(
    
'123.123.123.1',
    
'123.123.123.2',
    
'123.123.123.3'
);
$serv_index mt_rand(0, (count($servers) - 1)); 

$config['MasterServer']['servername'] = $servers[$serv_index]; 


Angel-Wings 05-06-2010 11:11 AM

Hmm - and if you use instead of some PHP function a real loadbalancer ? Then you can do real load-balancing based on the load of the backends instead of just plain rotating between the backeneds.

SnapOff Racing 05-06-2010 06:04 PM

Quote:

Originally Posted by Dismounted (Post 2032457)
That will use whichever you place last. Use:
PHP Code:

$servers = array(
    
'123.123.123.1',
    
'123.123.123.2',
    
'123.123.123.3'
);
$serv_index mt_rand(0, (count($servers) - 1)); 

$config['MasterServer']['servername'] = $servers[$serv_index]; 


Excellent Thank You for that. I will give it a try :up:

--------------- Added [DATE]1273190169[/DATE] at [TIME]1273190169[/TIME] ---------------

Alright I tried that script you posted and it works but if I pull any of the connections the forum stops working. Could you double check the script for me and make certain that a character wasn't accidentally overlooked somewhere?

Dismounted 05-07-2010 06:13 AM

Quote:

Originally Posted by SnapOff Racing (Post 2032717)
Alright I tried that script you posted and it works but if I pull any of the connections the forum stops working. Could you double check the script for me and make certain that a character wasn't accidentally overlooked somewhere?

What do you mean by 'pulling any of the connections'?

Angel-Wings 05-07-2010 05:34 PM

Quote:

Originally Posted by SnapOff Racing (Post 2032717)
Alright I tried that script you posted and it works but if I pull any of the connections the forum stops working. Could you double check the script for me and make certain that a character wasn't accidentally overlooked somewhere?

Well - you may use that PHP code or read the official MySQL documentation since there's already a tool doing exactly what you're looking for. ;)
But if you prefer PHP - ok - your choice

SnapOff Racing 05-08-2010 05:14 AM

Quote:

Originally Posted by Dismounted (Post 2032974)
What do you mean by 'pulling any of the connections'?

Ok it's like this, I am running a local webserver with 5 separate internet connections going into one server. They are all run into one router that does the load balancing. But what I wanna do is put my forum on a different server but still host the database from here. So in the config.php file I need to be able to tell it that I have 5 separate connections that it can choose to connect to. I tried using the script you provided which seems to work but if I pull one of the 5 local connections offline then everything stops working where really it should just skip to the next connection if it sees that connection is down. Basically a failover.

Dismounted 05-08-2010 09:57 AM

That's difficult to achieve due to the current internal design of vBulletin. It assumes that only one server exists, and this is merely a hacked-up way of getting around that. A solution would be to comment out that server's IP in config.php whenever you take it offline.

Angel-Wings 05-08-2010 11:28 AM

Thanks for ignoring me but still mysqlproxy can do exactly what you're looking for

SnapOff Racing 05-08-2010 10:31 PM

Quote:

Originally Posted by Dismounted (Post 2033651)
That's difficult to achieve due to the current internal design of vBulletin. It assumes that only one server exists, and this is merely a hacked-up way of getting around that. A solution would be to comment out that server's IP in config.php whenever you take it offline.

Ahhh that makes sense, I suppose that would work then. I was also just thinking of creating a new domain specifically for the MySQL database and then just put that one single domain in the config.php then use DNS to round robin the IP Addresses.

But so the script you provided should work just fine with all the connections working then correct? vBulletin will then round robin all of the addresses that I put in that array correct?

Quote:

Originally Posted by Angel-Wings (Post 2033682)
Thanks for ignoring me but still mysqlproxy can do exactly what you're looking for

Sorry but your post wasn't really all that specific on how this could help my situation. You simply just said I should read the MySQL documentation but didn't specify what exactly I should be looking for. Hence the reason for my paying attention to Dismounted's posts as he has given me something to work with :)


All times are GMT. The time now is 12:57 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01030 seconds
  • Memory Usage 1,748KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete