Walkthrough: Accessing Multiple Microsoft Dynamics NAV Databases from a Single Microsoft Dynamics NAV Server Computer

Walkthrough: Accessing Multiple Microsoft Dynamics NAV Databases from a Single Microsoft Dynamics NAV Server Computer

Microsoft Dynamics Nav 2009

In Microsoft Dynamics NAV 2009, to connect to more than one database from the same computer running Microsoft Dynamics NAV Server, you must create two distinct instances of Microsoft Dynamics NAV Server. You cannot create the second instance using Microsoft Dynamics NAV Setup.

The computer running Microsoft Dynamics NAV Server is the middle tier between the client and the database and runs as a service within the Windows Communication Framework. Before you can connect the RoleTailored client to a second database through a single Microsoft Dynamics NAV Server computer, you must create a second Microsoft Dynamics NAV Server service on that server computer.

This walkthrough is a step-by-step guide to installing two instances of Microsoft Dynamics NAV Server on a single server computer. This walkthrough illustrates the following tasks:

  • Creating the second Microsoft Dynamics NAV Server service with the sc utility.

  • Configuring the second service.

  • Connecting to either Microsoft Dynamics NAV Server service with the RoleTailored client.

  • Testing the second service.

Prerequisites

To complete this walkthrough, you will need:

  • Microsoft SQL Server 2008 or SQL Server 2005 on a computer running Windows Server 2008 or Windows Server 2003.

  • Microsoft Dynamics NAV 2009 Database Components and the first Microsoft Dynamics NAV Server on the same server computer.

  • RoleTailored client on a separate computer to test the installation.

  • Simon, the IT professional at CRONUS International, is developing new page objects for a customer but does not want to deploy the new pages directly to a production environment. He decides to create one database for developing new page objects and another database for testing them with the RoleTailored client. He wants to host both databases on the same server computer.

  • Simon knows that he must install multiple computers running Microsoft Dynamics NAV Server to achieve this result. Simon also knows that he can only create the second service using the service create (sc) utility at the command prompt.

Simon creates a second service by running the sc command at the command prompt. When he runs this command, he creates a second service that appears in the Services snap-in in Control Panel.

To create a second service

  1. In Control Panel, click Administrative Tools, and then click Services to open the Services snap-in.

  2. In the list of services, right-click Microsoft Dynamics NAV Server, and then click Stop.

  3. Navigate to the Microsoft Dynamics NAV Service directory. This directory is typically located at C:\Program Files\Microsoft Dynamics NAV\60\.

  4. Copy the service directory and paste it into the same directory. Rename the copy from Copy of Service to Service2.

  5. At the command prompt, type the sc command to create a new service. Copy the following command and paste it at the command prompt. Replace <computername> with the actual computer name.

    sc \\<computername> create MicrosoftDynamicsNAVServer$NAV2 binpath= "C:\Program Files\Microsoft Dynamics NAV\60\Service2\Microsoft.Dynamics.Nav.Server.exe $NAV2" DisplayName= "Microsoft Dynamics NAV Server Instance 2" start= auto type= own depend= NetTcpPortSharing
    
    NoteNote

    You can also specify a login account for the service as part of the sc command using the obj parameter, such as:

    obj= "NT Authority\NetworkService"
    
  6. If the command succeeds, then you receive the following message:

    [SC] CreateService SUCCESS

    In the Services snap-in, you see your second service, Microsoft Dynamics NAV Server Instance 2, in the list.

  7. Double-click the new service to open a Properties dialog box for the new service, and then click the Log On tab.

    The default setting is for the service to log on with the Local System Account. Setup configures the original Microsoft Dynamics NAV Server service to use the Network Service account. This walkthrough also uses the Network Service account for the second service. For improved security, you should use a dedicated domain user account. For information on how to configure a Microsoft Dynamics NAV Server service to use a domain user account, see Walkthrough: Installing the Three Tiers on Three Computers.

  8. Click This account on the Log On tab.

  9. Type NT Authority\NetworkService in the first text box.

  10. Clear the entries in the Password and Confirm password fields.

  11. Click OK to exit the Properties dialog box for the new service.

  12. Right-click Microsoft Dynamics NAV Server Instance 2, and then click Start to verify that the service is configured correctly.

  13. Right-click Microsoft Dynamics NAV Server Instance 2 again, and then click Stop.

Before Simon can start to use the second service, he must create a name for the new server instance. He must also activate port sharing so that multiple clients can share the same port number.

To create a name for the server instance

  1. Use Notepad or another text editor and open the CustomSettings.config file in the Service2 directory. The default path for this file is C:\Program Files\Microsoft Dynamics NAV\60\Service2\Custom.Settings.config.

  2. Locate the following line:

    <add key="ServerInstance" value="DynamicsNAV" />
    

    Replace DynamicsNAV with DynamicsNAV2, which is the name for your new server instance.

  3. Save your changes, and then close the editor.

To activate port sharing

  1. Return to the Services snap-in.

  2. Right-click Net.Tcp Port Sharing Service, and then click Properties.

  3. On the General tab, set Startup type to Manual.

  4. Click OK to close the Properties window.

  5. Right-click Net.Tcp Port Sharing, and then click Start.

    You have now activated port sharing over the TCP/IP protocol.

NoteNote

You can also specify a separate port number for each Microsoft Dynamics NAV Server service. You then do not need to implement TCP port sharing.

You may run into permission issues with port sharing when you use different service accounts for different server instances. See Configuring the Net.TCP Port Sharing Service. And to read how one user resolved this issue, see this blog post.

To reconfigure the original Microsoft Dynamics NAV Server service to use TCP port sharing, you must use the sc command to delete the service and then use it again to recreate the service with the proper configuration.

To recreate the original Microsoft Dynamics NAV Server service

  1. At the command prompt, type the following command to delete the Microsoft Dynamics NAV Server service:

    sc delete MicrosoftDynamicsNavServer
    
    NoteNote

    If you attempt to delete a service while it is running, then the service is marked for deletion but is not deleted until you restart the computer.

  2. At the command prompt, recreate the original Microsoft Dynamics NAV Server service with the option for TCP port sharing:

    sc \\<computername> create MicrosoftDynamicsNAVServer binpath= "C:\Program Files\Microsoft Dynamics NAV\60\Service\Microsoft.Dynamics.Nav.Server.exe" DisplayName= "Microsoft Dynamics NAV Server" start= auto type= own depend= NetTcpPortSharing
    
  3. If the service has been created successfully, then you receive the following message:

    [SC] CreateService SUCCESS
    
  4. If the Services snap-in is still open, then close it and reopen it to update the information in the snap-in. Otherwise, reopen the Services snap-in.

  5. Double-click Microsoft Dynamics NAV Server to open the Properties dialog box for the service, and then click the Log On tab.

  6. Click This account on the Log On tab.

  7. Type NT Authority\NetworkService in the first text box.

  8. Clear the entries in both the Password and Confirm password fields.

  9. Click OK to exit the Properties dialog box for the new service.

  10. In the Services snap-in, right-click Microsoft Dynamics NAV Server, and then click Start.

  11. Right-click Microsoft Dynamics NAV Server Instance 2, and then click Start.

    You now have two instances of the Microsoft Dynamics NAV Server service running on the same computer.

Simon wants to test his second service by connecting to it from the RoleTailored client and by making a change to the data in one database.

To connect the RoleTailored client to a second service.

  1. Open the RoleTailored client that you have installed on a separate computer.

  2. In the Role Center menu bar, click Microsoft Dynamics NAV, and then click Select Server.

  3. In Server Name, add the number 2 to the DynamicsNAV value so that it is DynamicsNAV2.

  4. Click Connect.

  5. Select CRONUS International Ltd. from the Companies list.

    Unless you have already installed additional databases, the demo database is the only one available and is automatically selected.

    Click Connect, and then start working with your database.

You can adapt the procedure that is described in this walkthrough to create a second Microsoft Dynamics NAV Web services server on a single computer. Whether a service that you create manually is a standard Microsoft Dynamics NAV Server service or a Microsoft Dynamics NAV Web services service is determined by the name you give the service. If the name starts with "MicrosoftDynamicsNavWS", then the resulting service will be a Web service. If the name starts with anything else, then it will be a standard Microsoft Dynamics NAV Server service, which is a service serving RoleTailored clients.

For more information, see Creating a web service manually, the importance of the name you give it, and a few small things to remember on the Microsoft Dynamics NAV Team Blog.

Simon is satisfied that the two Microsoft Dynamics NAV Server services are working correctly. The next steps that he could take are:

  • Setting up two SQL Server databases on the computer running SQL Server.

  • Configuring the two Microsoft Dynamics NAV Server services to connect to different databases.

Community Additions

ADD
Show:
© 2016 Microsoft