Very useful post by Microsoft Dynamics NAV Team Blog about few NAV 2013 Services on same server and NAV 2013 port sharing
link: http://blogs.msdn.com/b/nav/archive/2012/10/18/how-to-have-few-microsoft-dynamics-nav-2013-services-on-the-same-server.aspx
FEW NAV SERVICES
With Microsoft Dynamics NAV 2013 we have few solutions how to create new NAV service (NST). First NAV 2013 Service we already have installed by NAV DVD and now we want to have mor
1) If we want to have few instances of service tier connected to the same or different db. Then we can:
- a. Use Microsoft Dynamics NAV Administration Tools (Administration console) as described at http://msdn.microsoft.com/en-us/library/hh165851(v=nav.70).aspx . With it we can create new instance of the same service as it is described at http://msdn.microsoft.com/en-us/library/hh168936(v=nav.70).aspx .
- b. Use Microsoft Dynamics NAV Windows PowerShell Cmdlets. This can be done by running Microsoft Dynamics NAV Shell and execute cmdlet “New-NAVServerInstance” as it is described at http://msdn.microsoft.com/en-us/library/hh173394(v=nav.70).aspx . Required parameters can be find by execute “Get-Help New-NAVServerInstance –full” in shell. But for example if I want to create new instance named “TestNAV70” then I execute:
New-NAVServerInstance -ServerInstance TestNAV70 -ClientServicesPort 7600 -ManagementServicesPort 7601 -ODataServicesPort 7602 -SOAPServicesPort 7603
Four ports parameters are required to add here.
There will be new folder TestNAV70 created in c:\Program Files\Microsoft Dynamics NAV\70\Service\Instances and it includes two configuration files.
This instance will be visible in Microsoft Dynamics NAV Administration Tools, where you can change database name, start, stop service etc.
Users now can connect to these instances and work with RTC.
Advantages: easy/simple creation, usage and administration. For example, have customer db and want to see how report works on it in comparing to Cronus: create new instance, point it to customer db, run RTC using these ports and connect to required service.
Disadvantages: Used another ports – RTC configs need to be modified. Firewall need to be configured. Used the same binaries.
2) If we want to have fully separate services (including binaries):
- a. We can use the same way as it was in NAV 2009 – use sc.exe utility and execute it with parameters as it is described at http://blogs.msdn.com/b/nav/archive/2009/10/20/creating-a-web-service-manually-the-importance-of-what-name-you-give-it-and-a-few-small-things-to-remember.aspx or at http://blogs.msdn.com/b/freddyk/archive/2008/10/29/multiple-service-tiers.aspx
- b. Or use Windows power shell “New-Service” tasklet like:
New-Service -Name 'MicrosoftDynamicsNAVServer$TestNAV70' -BinaryPathName '"D:\NAV 7\Service\Microsoft.Dynamics.Nav.Server.exe" $TestNAV70 /config "D:\NAV 7\Service\Microsoft.Dynamics.NAV.Server.exe.config"' -DependsOn 'NetTcpPortSharing' -Description 'Service handling TestNAV70' -DisplayName 'Microsoft Dynamics NAV 70 Server [TestNAV70]' -StartupType Manual
Here my new service is ‘TestNAV70’ and binaries are in folder ‘D:\NAV 7\Service’. Service depends on 'NetTcpPortSharing'.
Now I can modify servise CustomSettings.Config file to force to connect to required db, use required ports, name service instance (for example ‘NAV70Test’). ATTENTION: when RTC connects to service instance, it must to use in service CustomSettings.Config file described ports and service instance name (Not windows service name used in service creation TestNAV70, but service instance name – NAV70Test).
Advantages: Can use different binaries (builds or versions); can share the same ports between few services – users can use the same client config file, just change service instance name.
Disadvantages: Not easy to create and configure.
In both ways created services can be managed using Microsoft Dynamics NAV Administration Tools, so it is very easy modify services for any further needs. However if we try to remove service by using function “Remove”, then tools uninstall service and remove folder (including all binaries) and this can be problem if we have few services based on the same binaries folder.
PORT SHARING
Few Microsoft Dynamics NAV 2013 services can share the same TCP communication ports (Attention: do not mix it with NAV 2009). However, here are few tricks need to do before we use port sharing
1) Windows service NetTcpPortSharing must to run on computer where NAV services are running. By default this service is not started, so you need to set service “startup type” to “Automatic” and start it.
2) Any NAV 2013 service need to be modified by adding dependency (DependsOn) – Net.Tcp Port Sharing Service. This can be done in few ways:
- a. During service install add parameter “-DependsOn 'NetTcpPortSharing'”
- b. Use sc.exe utility to modify existing services like: sc.exe config ‘MicrosoftDynamicsNAVServer$NAV70’ depend= NetTcpPortSharing
- c. Modify windows registry key using regedit utility. Go to HKLM\System\CurrentControlSet\Services\MicrosoftDynamcisNAVServer$NAV70; and add/modify key DependOnService = NetTcpPortSha
by Gedas Busniauskas, Microsoft Lithuania, Microsoft Customer Service and Support (CSS) EMEA