Finally the help of IT is here

Blog of computer solutions.

Remote Desktop without NLB load balancing.

Written by on January albertfr 7th, 2012

Hello,

Today we will Explain how to do a load balancing terminal server without NLB product. Only using Round Robin DNS, some scripts and 1 GPO in Active Directory.

The system is composed by the Following elements:

Terminal Servers (A) and (B) are Windows Server 2008 R2 With the following características:

It has in the Same LAN to Avoid client-server over WAN latency.

 

You use ThinPrint Application Server Engine 8.6 Between traffic to compress spooler terminal server and client. It's perfect to print using WAN environment.

 

Both Terminal Servers can do load balancing and failover.

 

Uses Microsoft Office 2007 (Word, Excel, Powerpoint).

Balancing and failover system

The solution I we have CHOSEN will use a single batch file (CMD) Which server controlling users are going to connect using a DNS round robin register (Which adds balancing) and, if it fails will try to connect to other servers (failover). Here you have a picture With The schema:

 

NLBwithRoundRobin_2

With This We Improve the standard method Round Robin DNS functionality Because this method every time you request name, you get an ip address defined in the cluster, Even if server is working or not.

With this script Also the last server is controlled HAD That user logged on. This is to Maintain session connection is broken if user log off Before.

This system use 3 scripts:

Connection Script (Used to start from client application.)

Launches an RDP connection file Depending on the Following algorithm:

 

  • Check if user has a disconnected session on the current system to connect to the Same server. This Requires a data generated for Logon script (Which saves the current logged on server). If user closes the application, Then logoff script, will remove that data.

 

  • If a disconnected session does not exist, it tries to connect to Round Robin DNS name. This answers a different DNS name from a defined IP pool (Which are the terminal servers) using the round robin method.

 

  • If it can not connect, it retries the Same name Requesting the next server on the pool.

This is the script (ConnecttoRDP.CMD):

@ ECHO OFF

SET profilePath = <Your Desired Server with LAN profiles connectivty>
SET RRAPPSERVER = <DNS Server Name by Round Robin activated>
LogPath =% SET profilePath% _Logs
SET LOGLASTSERVER LogPath%% =% Username% _LastServer.txt
SET LOGCONNECTION LogPath%% =% Username% _Connection.txt
SET RDPPATH = <server connection>. Rdp
SET RRTRIES = 10

ECHO Connecting, please wait ........
REM ECHO.

ECHO STARTING CONNECTION SCRIPT ...>% LOGCONNECTION%

IF NOT EXIST% LOGLASTSERVER% (
ECHO exists not last server log >>% LOGCONNECTION%
GOTO RRNAME
)

SET / p LASTSERVER = <% LOGLASTSERVER%
SET =% LASTSERVER LASTSERVER: =%
Last Used ECHO server LASTSERVER WAS%%% >>% LOGCONNECTION

IF EXIST% LASTSERVER%. <YourDomain>. Com% RDPPATH% (
Connecting to last server ECHO ^ Used (% LASTSERVER% ^) >>% LOGCONNECTION% ...
MSTSC% LASTSERVER%. <YourDomain>. Com% RDPPATH%
GOTO END
) ELSE (ECHO Last Used server not available! >>% LOGCONNECTION%)

: RRNAME

FOR / L%% G IN (1,1,% RRTRIES%) DO (
Connection RRAPPSERVER% ECHO%%% Attempt # LOGCONNECTION% >>% T
IPCONFIG / FLUSHDNS> NUL
IF EXIST%%% RRAPPSERVER RDPPATH% (
ECHO RRAPPSERVER Connected to%%% >>% LOGCONNECTION
MSTSC% RRAPPSERVER RDPPATH%%%
GOTO END
)
)
ECHO Unable to connect! LOGCONNECTION% >>%
ECHO Unable to connect! Press any key to try again ...
PAUSE> NUL
GOTO RRNAME

: END
CONNECTION SCRIPT END ECHO. LOGCONNECTION% >>%

You need to create an icon in every user Desktop with this script. For example an icon named Connection pointing to <Desiredserverprofiles_ConnectionConnecttoRDP.CMD

Logon Script (Login.cmd)

  • It's Executed on Terminal Servers users log on process.

 

  • Restores previous application settings. If Any previous data does not exist it sets the minimum ones (database connection string, ...).

This is the script:

@ Echo off
SET FILESERVER = <yourdesiredserver> profiles
LogPath =% SET FILESERVER% _Logs
SET LOGLASTSERVER LogPath%% =% Username% _LastServer.txt
SET LOGFILE =% Username%%% LogPath. Txt
SET FILESERVER userPath =% USERNAME%%%
SET userPath USERWINDOWSPATH =% WINDOWS%
SET USERPROFILEWINDOWSDIR =% USERPROFILE% WINDOWS
SET CUSTOMREGFILEPERUSER userPath% =% USER_REGISTRY_CUSTOM.reg
SET REGISTRYBACKUP userPath% =% BACKUP_REGISTRY.reg

IF NOT EXIST%% MKDIR% LogPath LogPath%

LOGIN SCRIPT START ECHO 1.1>% LOGFILE%

echo / | set / p =% COMPUTERNAME%>% LOGLASTSERVER%

ECHO CHECKING IF EXISTS% USERWINDOWSPATH% ... >>% LOGFILE%
IF EXIST% USERWINDOWSPATH% (
ECHO COPYING FOLDER WINDOWS USER PROFILE ... >>% LOGFILE%
COPY%%% USERWINDOWSPATH USERPROFILEWINDOWSDIR% / Y> NUL
) ELSE (ECHO NO, IT DOES NOT EXIST >>% LOGFILE%)

ECHO CHECKING IF EXISTS% REGISTRYBACKUP% ... >>% LOGFILE%
IF EXIST% REGISTRYBACKUP% (
ECHO YES, IT EXIST! RESTORING BACKUP USER REGISTRY ... >>% LOGFILE%
regedit / S% REGISTRYBACKUP%
GOTO END
) ELSE (ECHO NO, IT DOES NOT EXIST >>% LOGFILE%)

ECHO NEW USER ... >>% LOGFILE%
ECHO CHECKING IF EXISTS% userPath% ... >>% LOGFILE%
IF NOT EXIST% userPath% (
ECHO NO, IT DOES NOT EXIST! CREATING DIRECTORY ... >>% LOGFILE%
UserPath% MKDIR%
)

ECHO Creating standard settings ... >>% LOGFILE%
REG ADD HKCUSoftware <Your Desired Registry Keys> / v TYPE_CONNEXION / t REG_SZ / d "<text>" / f
REG ADD HKCUSoftware <Your Desired Registry Keys> / v TYPE_CONNEXION / t REG_SZ / d "<text>" / f

: END
REG ADD HKCUSoftware <Your Desired Registry Keys> / v TYPE_CONNEXION / t REG_SZ / d "<text>" / f
REG ADD HKCUSoftware <Your Desired Registry Keys> / v TYPE_CONNEXION / t REG_SZ / d "<text>" / f
ECHO Disabling language bar ... >>% LOGFILE%
REG ADD HKCUSoftwareMicrosoftCTF / v LangBar / t REG_DWORD / d "3" / f

ECHO CHECKING IF EXISTS% CUSTOMREGFILEPERUSER% ... >>% LOGFILE%
IF EXIST% CUSTOMREGFILEPERUSER% (
ECHO YES, IT EXIST! APPLYING CUSTOM USER REGISTRY SETTINGS ... >>% LOGFILE%
regedit / S% CUSTOMREGFILEPERUSER%
) ELSE (ECHO NO, IT DOES NOT EXIST >>% LOGFILE%)

ECHO LOGON SCRIPT END >>% LOGFILE%

Logoff Script (Logoff.cmd)

  • Backup current settings. Settings of Windows user profile folder.

This is the script:

@ Echo off
SET FILESERVER = <yourdesiredserver> profiles
LogPath =% SET FILESERVER% _Logs
SET LOGFILE =% Username%%% LogPath. Txt
SET LOGLASTSERVER LogPath%% =% Username% _LastServer.txt
SET FILESERVER userPath =% USERNAME%%%
SET userPath USERWINDOWSPATH =% WINDOWS%
SET USERPROFILEWINDOWSDIR =% USERPROFILE% WINDOWS
SET REGISTRYBACKUP userPath% =% BACKUP_REGISTRY.reg
SET REGISTRYHIVE = Desired <Your HKEY_CURRENT_USERSoftware Keys> Registry

IF NOT EXIST%% MKDIR% LogPath LogPath%

ECHO. >>% LOGFILE%
LOGOFF SCRIPT START ECHO >>% LOGFILE% 1.1

ECHO CHECKING IF EXISTS% userPath% ... >>% LOGFILE%
IF NOT EXIST% userPath% (
ECHO NO, IT NOT EXIST! CREATING DIRECTORY ... >>% LOGFILE%
UserPath% MKDIR%
) ELSE (ECHO YES, IT EXIST >>% LOGFILE%)

ECHO CHECKING IF EXISTS% USERWINDOWSPATH% ... >>% LOGFILE%
IF NOT EXIST% USERWINDOWSPATH% (
ECHO YES, IT EXIST >>% LOGFILE%
USERWINDOWSPATH% MKDIR%
) ELSE (ECHO YES, IT EXIST >>% LOGFILE%)

ECHO COPYING FOLDER WINDOWS USER PROFILE ... >>% LOGFILE%
COPY%%% USERPROFILEWINDOWSDIR USERWINDOWSPATH% / Y >>% LOGFILE%

ECHO EXPORTING REGISTRY SETTINGS ... >>% LOGFILE%
regedit.exe / e% REGISTRYBACKUP REGISTRYHIVE%%%

Removing LAST ECHO SERVER INFO ... >>% LOGFILE%
DEL / Q% LOGLASTSERVER%

LOGOFF SCRIPT END ECHO

When we saw scripts WAS working Windows XP computers That does not work as expected using Round Robin DNS Name.

This Occurs Because when to check if Terminal server node is alive, we try to see if a file exists in a network share. It worked on Windows computers but not 7 in Windows XP.

To Solve this problem We had to add the Following registry values ​​in Both terminal servers (A and B):

HKLMSYSTEMCurrentControlSetServiceslanmanserverparameters

DisableStrictNameChecking (type DWORD) to 1.

NOTE: To be Applied Requires a reboot.

You need to create new GPO (Group Policy Object) and terminal servers move to new computer object in Active Directory OU Structure to Apply this GPO.

NLBwithRoundRobin_3

OK. Now You have Desired Load Balancing and failover without NLB Terminal Servers.

 

If you grant Requires to Single Sign On Those properties on Terminal Server connections please read next article:

http://www.megacrack.es/2012/01/07/how-to-do-single-sign-on-on-terminal-server-connections/

That's all folks. We are waiting your comments bellow. We hope this information will be usable for you.

See you soon MegaCracks.

Related Posts Plugin for WordPress, Blogger ...
Tags: , , , , ,


Leave a Reply

XHTML: You can use in Original tags: <a href="" title=""> <abbr title = ""> <acronym title = ""> <b> <blockquote cite = ""> <cite> <code> <del datetime = ""> <em> <i> <q cite = ""> <s> <strike> <strong>