Click here to Skip to main content
15,891,372 members
Articles / Database Development / SQL Server
Tip/Trick

Name resolving problem with DTC (Distributed Transaction Coordinator)

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
7 Jan 2012CPOL2 min read 16.6K   1  
A solution for the name resolving problem with DTC.

If you have two servers (or more) in different networks and the DNS is not configured, does not exist, or is not used for any other case (like security or restrict access), you have a problem with the DTC when you try to INSERT, UPDATE, or DELETE data on a database server (or any other case).


The explanation for this is: imagine you have three layers of testing software environment of your software as in the example below:


Server 1 (Database server, for the example SQL SERVER)
ip address: 192.168.1.1
name: DBSERVER

Server 2 (Application Server, IIS 7, 7,5)
ip address: 10.150.40.21
name: APPSERVER

Client (your PC) both servers and your application are configured to use DTC.


If you try to execute the application hosted in server 2, the SELECT instructions work fine, but if you try to INSERT, DELETE, or UPDATE on the database, your application throws an unknown error related to a service, a method, or something in your applicattion. This error is provocated by DTC, because DTC uses a name resolving for communication with the other server if the operation tries to modify, add, or delete data.


In that case, you need to configure your DNS to quickly solve the problem. In case your network doesn't have a DNS server or the server (or both of them) doesn't have a DNS configured on the NIC's for any reason, you have a simple solution.


You need to modify two files in Windows (networks and hosts), on this path:


%WINDIR%\System32\Drivers\etc

In the networks file, you have a structure like this:


-----------------------------------------------------------------------
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This file contains network name/network number mappings for 
# local networks. Network numbers are recognized in dotted decimal form.
#
# Format:
#
# <network name="">  <network number="">     [aliases...]  [#<comment>]
#
# For example:
#
#    loopback     127
#    campus       284.122.107
#    london       284.122.108

loopback                 127
-----------------------------------------------------------------------

In DBSERVER, at the bottom of the file, you need to add a new network with the IP address of the other server, without the last octect of the IP address like this:


DBNETWORK 10.150.40

DBNETWORK is the name of the network (any other can work, you don't need to use the original network name to do this) and 10.150.40 is the range of this network.


Save and close the file, and then you need to edit the hosts file, this file has a structure like this:


-----------------------------------------------------------------------
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost

127.0.0.1       localhost
---------------------------------------------------------------------

In this file, you need to add the IP address and the name of the other server at the bottom of the file like this:


10.150.40.21  APPSERVER

You need to use the real name server in this case. Save and close the file, and next, do the same on the APPSERVER with the configuration of the DBSERVER. The network name on the other server, setup as APPNETWORK (or any other name).


Save these files on the other server and try to ping, and that's OK. Ping to the other server (with name server) is now working, with this, DTC can resolve locally the name of the other server without DNS.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Kibernum S.A.
Chile Chile
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --