开发者

How can I run multiple instances of TeamCity on the same server?

I am on Windows and trying to run multiple (currently two) instances of TeamCity on the same server. I chose not to install the Windows services and instead run the server via runAll.bat start command. When I ran the installer I chose different ports, names and paths for each one. The first server starts successfully, but the second one does not - I see the tomcat window showing up, but it's gone after a while, though the build agent window stays. Here's some output:

c:\Tools\TeamCity\bin>runAll.bat start
starting TeamCity server and agent...
Using CATALINA_BASE:   "c:\Tools\TeamCity\bin\.."
Using CATA开发者_如何学CLINA_HOME:   "c:\Tools\TeamCity\bin\.."
Using CATALINA_TMPDIR: "c:\Tools\TeamCity\bin\..\temp"
Using JRE_HOME:        "c:\Tools\TeamCity\bin\..\jre"
Using CLASSPATH:       "c:\Tools\TeamCity\bin\..\bin\bootstrap.jar"
Starting TeamCity Build Agent Launcher...
Agent home directory is C:\Tools\TeamCity\buildAgent
Current JRE version is 1.6

c:\Tools\TeamCity\bin>cd c:\Tools\TeamCity2\bin

c:\Tools\TeamCity2\bin>runAll.bat start
starting TeamCity server and agent...
Using CATALINA_BASE:   "c:\Tools\TeamCity2\bin\.."
Using CATALINA_HOME:   "c:\Tools\TeamCity2\bin\.."
Using CATALINA_TMPDIR: "c:\Tools\TeamCity2\bin\..\temp"
Using JRE_HOME:        "c:\Tools\TeamCity2\bin\..\jre"
Using CLASSPATH:       "c:\Tools\TeamCity2\bin\..\bin\bootstrap.jar"
Starting TeamCity Build Agent Launcher...
Agent home directory is C:\Tools\TeamCity2\buildAgent
Current JRE version is 1.6


You need to edit conf\server.xml for the second Tomcat/TeamCity instance so that it uses different ports or binds to different network interfaces, changing the following ports should be enough:

  • Server port="8005"
  • Connector port="8080"

Two servers cannot share the same database, so you must configure them to use different locations via TEAMCITY_DATA_PATH environment variable.

If you also want to run multiple agents on the same machine, refer to my answer here.


It is possible to make more than one TeamCity server run on the same Windows box as Windows services.

The following procedure assumes you want to install 3 instances of TeamCity named TeamCity1, TeamCity2, and TeamCity3 on ports 8080, 8081, and 8082 respectively. If you change any of these details, make sure you remain consistant with the change throughout the procedure. Each instance MUST run under a different Windows user account for this procedure to work. This was done with TeamCity 7.1, I am not sure if it works with other versions.

Here is the procedure:

  1. Install TeamCity, choose "C:\TeamCity1" as the destination folder.

  2. Uncheck the Build Agent (both Windows Service and Core) - these will be installed later.

  3. Uncheck the Windows Service for Server, but leave the Core checked.

  4. Use "C:\TeamCity1\TeamCityData\" as the configuration directory.

  5. Choose a unique port for this instance. I chose 8080, 8081, and 8082.

  6. Repeat steps 1-5 as many times as desired, changing the to TeamCity2, TeamCity3, etc. and changing the port each time.

  7. Go to Computer Management in Administrative Tools and create 1 unique Windows user account for each service (i.e. TeamCity1, TeamCity2, and TeamCity3). Make sure the passwords do not expire. For now, make sure each user has enough permission to log onto Windows.

  8. Open an elevated command prompt by going to All programs > Accessories > Command Prompt, right clicking, and choose "Run as Administrator".

  9. Run the commands at the end of this procedure for each instance of TeamCity, replacing the number 1 with the appropriate TeamCity instance.

  10. You need to add "Logon as a service" right for each account. The easy way to do this is to open Services from Administrative Tools, right click each service, go to the Log On tab, retype the password in both boxes, and click Apply.

  11. Logoff the machine and login as "TeamCity1".

  12. Go to Control Panel > User Accounts > User Accounts > Change my environment variables.

  13. Add a new User variable by clicking New... Name it TEAMCITY_DATA_PATH with a value of C:\TeamCity1\TeamCityData.

  14. Repeat steps 11-13 for each instance of TeamCity.

  15. Logoff and log back in with the Administrator account.

  16. Go back into the environment variables dialog and delete the System variable (not User variable) named TEAMCITY_DATA_PATH.

  17. If desired, change the permissions for each TeamCity user account so they do not have permission to log in.

  18. Open C:\TeamCity1\conf\server.xml and C:\TeamCity1\conf\server-standard.xml and change the server port=8105 to another port of your choosing. Ensure you use the SAME PORT in both files. Repeat for each instance of TeamCity.

  19. Start each service and connect with your browser to configure the data directory for each one. I had to stop all of the teamcity service instances except the current one or I got a "client not authenticated" error during the build process, but once completed they seem to work okay.

  20. Configure database access as appropriate.

  21. Use these instructions to install multiple build agents on the same machine. I don't believe it is possible to share an agent between TeamCity instances as communication is 2-way and there doesn't seem to be a way to configure more than one port, so it is probably best to install the agents to C:\TeamCity1\buildAgent1\ named TeamCity1BuildAgent1, C:\TeamCity1\buildAgent2\ named TeamCity1BuildAgent2, C:\TeamCity2\buildAgent1\ named TeamCity2BuildAgent1, etc.

  22. If you want to use standard ports for each TeamCity instance (80 and/or 443), follow these instructions to use IIS as a proxy for Tomcat.

Run these commands at step #9 above

sc create TeamCity1 binPath= "\"C:\TeamCity1\bin\TeamCityService.exe\" jetservice \"/settings=C:\TeamCity1\conf\teamcity-server-service.xml\" \"/LogFile=C:\TeamCity1\logs\teamcity-winservice.log\"" DisplayName= "TeamCity Server 1" start= auto obj= ".\TeamCity1" password= "Password1"

sc description "TeamCity1" "JetBrains TeamCity server service 1"

NOTE: teamcity is misspelled as "teamicty" as the name of the config file in some builds. 
This is a TeamCity bug, make sure you correct the file name before 
executing these commands.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜