Running multiple SFS instances on same box

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

zookeeper
Posts: 13
Joined: 22 Feb 2007, 01:06

Running multiple SFS instances on same box

Post by zookeeper »

Hello, after a quick search I hadn't found any threads on this. If there is please refer me to it? Thanks!

In the FAQ, there is this snippet:
"Can I install SmartFoxServer on more than one machine?
Each server license is valid for a single IP address; if you need to run multiple instances of the server on more than one IP you need to buy more licenses. You can however run multiple instances using the same IP and by configuring each instance to run on a different TCP port."

How would I run multiple instances using the same IP w/ different TCP Ports? Would I need 10 versions of the server folder? So we'd have "C:\Program Files\SmartFoxServerPRO_1.5.5\Server1" to "C:\Program Files\SmartFoxServerPRO_1.5.5\Server10" ? And then each of the \ServerX configs would map to a different port number. And then I could install each \ServerX service?

Has anyone done this in a live situation? It seems to me that one instance with an unlimited concurrent user license may be just as efficient for the physical server box to handle as 10 seperate SFSs running on it...?

Thanks in advance!
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Has anyone done this in a live situation? It seems to me that one instance with an unlimited concurrent user license may be just as efficient for the physical server box to handle as 10 seperate SFSs running on it...?
In general I think you're right. I don't see any particular advantage in running multiple instances in a live environment as this would require multiple JVMs running.

However it can be useful if you need to install extra instances for test purposes etc...

hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
zookeeper
Posts: 13
Joined: 22 Feb 2007, 01:06

Post by zookeeper »

Ok, so I've decided to try this approach on our staging environment. The install goes fine. I had to edit the ServerX/InstallAsService.bat (relative path edit for ServerX) and ServerX/conf/wrapper.conf (unique service names). So now I've got two services running for the two server instances. Server1 has port 9339. Server2 has port 9339. So far so good.
zookeeper
Posts: 13
Joined: 22 Feb 2007, 01:06

Post by zookeeper »

After upgrading to 1.6, when I try to reboot the smart fox service for my second server, I got this log error and then everything starts up just fine. I have also disabled the database portion of smartfox (no zones use it):

STATUS | wrapper | 2008/01/04 16:05:59 | --> Wrapper Started as Service
STATUS | wrapper | 2008/01/04 16:05:59 | Launching a JVM...
INFO | jvm 1 | 2008/01/04 16:05:59 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
INFO | jvm 1 | 2008/01/04 16:05:59 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
INFO | jvm 1 | 2008/01/04 16:05:59 |
INFO | jvm 1 | 2008/01/04 16:06:00 | org.h2.jdbc.JdbcSQLException: Exception opening port 9009 (port may be in use), cause: java.net.BindException: Address already in use: JVM_Bind [90061-60]
INFO | jvm 1 | 2008/01/04 16:06:00 | at org.h2.message.Message.getSQLException(Message.java:84)
INFO | jvm 1 | 2008/01/04 16:06:00 | at org.h2.util.NetUtils.createServerSocketTry(NetUtils.java:54)
INFO | jvm 1 | 2008/01/04 16:06:00 | at org.h2.util.NetUtils.createServerSocket(NetUtils.java:39)
INFO | jvm 1 | 2008/01/04 16:06:00 | at org.h2.server.TcpServer.start(TcpServer.java:125)
INFO | jvm 1 | 2008/01/04 16:06:00 | at org.h2.tools.Server.start(Server.java:362)
INFO | jvm 1 | 2008/01/04 16:06:00 | at it.gotoandplay.smartfoxserver.SmartFoxServer.bootH2Engine(SmartFoxServer.java:510)
INFO | jvm 1 | 2008/01/04 16:06:00 | at it.gotoandplay.smartfoxserver.SmartFoxServer.<init>(SmartFoxServer.java:290)
INFO | jvm 1 | 2008/01/04 16:06:00 | at it.gotoandplay.smartfoxserver.SmartFoxServer.main(SmartFoxServer.java:231)
INFO | jvm 1 | 2008/01/04 16:06:00 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO | jvm 1 | 2008/01/04 16:06:00 | at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
INFO | jvm 1 | 2008/01/04 16:06:00 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
INFO | jvm 1 | 2008/01/04 16:06:00 | at java.lang.reflect.Method.invoke(Unknown Source)
INFO | jvm 1 | 2008/01/04 16:06:00 | at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
INFO | jvm 1 | 2008/01/04 16:06:00 | at java.lang.Thread.run(Unknown Source)
INFO | jvm 1 | 2008/01/04 16:06:00 | Caused by: java.net.BindException: Address already in use: JVM_Bind
INFO | jvm 1 | 2008/01/04 16:06:00 | at java.net.PlainSocketImpl.socketBind(Native Method)
INFO | jvm 1 | 2008/01/04 16:06:00 | at java.net.PlainSocketImpl.bind(Unknown Source)
INFO | jvm 1 | 2008/01/04 16:06:00 | at java.net.ServerSocket.bind(Unknown Source)
INFO | jvm 1 | 2008/01/04 16:06:00 | at java.net.ServerSocket.<init>(Unknown Source)
INFO | jvm 1 | 2008/01/04 16:06:00 | at java.net.ServerSocket.<init>(Unknown Source)
INFO | jvm 1 | 2008/01/04 16:06:00 | at org.h2.util.NetUtils.createServerSocketTry(NetUtils.java:51)
INFO | jvm 1 | 2008/01/04 16:06:00 | ... 12 more


If I try to reboot the server instance remotely, I get this error and it never comes back online.

INFO | jvm 1 | 2008/01/04 16:16:37 | Server Restarting ...
INFO | jvm 1 | 2008/01/04 16:16:37 |
INFO | jvm 1 | 2008/01/04 16:16:37 |
INFO | jvm 1 | 2008/01/04 16:16:37 | 16:16:37.375 - [ WARNING ] > Generic exception while shutting down: java.lang.NullPointerException
INFO | jvm 1 | 2008/01/04 16:16:37 | 16:16:37.375 - [ WARNING ] > Generic Exception in acceptNewConnections():java.nio.channels.ClosedSelectorException
INFO | jvm 1 | 2008/01/04 16:16:37 | java.nio.channels.ClosedSelectorException
INFO | jvm 1 | 2008/01/04 16:16:37 | at sun.nio.ch.SelectorImpl.selectedKeys(Unknown Source)
INFO | jvm 1 | 2008/01/04 16:16:37 | at it.gotoandplay.smartfoxserver.SmartFoxServer.acceptNewConnections(SmartFoxServer.java:681)
INFO | jvm 1 | 2008/01/04 16:16:37 | at it.gotoandplay.smartfoxserver.SmartFoxServer.run(SmartFoxServer.java:637)
INFO | jvm 1 | 2008/01/04 16:16:37 | java.lang.NullPointerException
INFO | jvm 1 | 2008/01/04 16:16:37 | at it.gotoandplay.smartfoxserver.SmartFoxServer.shutDown(SmartFoxServer.java:3186)
INFO | jvm 1 | 2008/01/04 16:16:37 | at it.gotoandplay.smartfoxserver.SmartFoxServer.restart(SmartFoxServer.java:3019)
INFO | jvm 1 | 2008/01/04 16:16:37 | at it.gotoandplay.smartfoxserver.admin.RestartTask.run(RestartTask.java:39)
INFO | jvm 1 | 2008/01/04 16:16:37 | Could not restart server!

The primary instance of smart fox works fine and has none of these errors.


Any clues...? Hmm..

Thanks!
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

The problem is with the database server.
SFS 1.6.0 comes with an embedded database server that runs on the localhost, port 9002.
So if you run multiple instances of SFS you're also running multiple DB instances, but this is not possible because the same TCP port can't be "shared" between two services... hence the error.

At the moment there's no workaround for this, as it's not possible to change the internal DB port. We'll add this feature in the next server patch.
Lapo
--
gotoAndPlay()
...addicted to flash games
zookeeper
Posts: 13
Joined: 22 Feb 2007, 01:06

Post by zookeeper »

Thanks for the reply, Lapo. At the moment only our staging server has this scenario for testing purposes. Luckily, our live situation won't have multiple instance on the same box - if we need to have more than one SFS, we'll get another physical box into the cluster.

Thank you!
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

If you need multiple sfs running on the same machine for testing purposes you could also install the VMWare Player and run the instance in a virtual machine. It's quite handy.

You can also choose from a large selection of pre-made vm-images that you can download and run in the Player.

Links to learn more:
http://www.vmware.com/products/player/
http://www.vmware.com/appliances/
Lapo
--
gotoAndPlay()
...addicted to flash games
ramindeja
Posts: 74
Joined: 31 Mar 2008, 17:54

Post by ramindeja »

Is this fixed in version 1.6.2? In my case I get:

Code: Select all

11:37:37.266 - [ INFO ] > Starting h2 engine...
11:37:37.305 - [ WARNING ] > Cannot start H2 Engine: org.h2.jdbc.JdbcSQLException: Exception opening port 9009 (port may be in use), cause: java.net.BindException: Address already in use [90061-60]
org.h2.jdbc.JdbcSQLException: Exception opening port 9009 (port may be in use), cause: java.net.BindException: Address already in use
I thought may be the patch that you were talking about was available in this version since zookeeper's SFS was 1.6.0.

Cheers.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

You can specify a different port for the DB server to avoid collisions.
Use the something like this in the config.xml, under the <ServerSetup> node:

Code: Select all

<H2EnginePort>9009</H2EnginePort>
The default value is 9009
Lapo
--
gotoAndPlay()
...addicted to flash games
ramindeja
Posts: 74
Joined: 31 Mar 2008, 17:54

Post by ramindeja »

Thanks Lapo, I tried it and it worked.

I had also modified some other ports for jetty etc. When I run the 2nd server I see for example:

SelectChannelConnector on port 8082 and not 8080.

I didn't know if it was necessary or not, just wanted to make sure.


BTW, don't want to push it but one of my threads really needs your brain (BuddyList) ;) Sorry, I tried so many different ways I'm getting woozy!

Cheers
User avatar
marsoups
Posts: 167
Joined: 14 Apr 2008, 03:30

Post by marsoups »

Hi Lapo, or anybody that knows.

I just wanted to confirm if you know if this is a workable solution for this problem, as we want to have a development version of our project happening for our client to view etc., as well as a live version. If we can have both running simultaneously on the same server, then that is great, and we will follow the advice above...

Many thanks for assistance..
Last edited by marsoups on 06 Feb 2009, 08:02, edited 1 time in total.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

There's no problem running 2 SFS servers on the same machine.
You simply need to configure them so that they don't use the same ports.

SmartFoxServer runs by default on port 9339
The second instance should run on another TCP port, let's say 9340 (or any other free port

SmartFoxServer also comes with an embedded Http server (jetty) and database (H2) which also bind TCP ports.

The Http server runs on port (8080), if you don't need it you can turn it off.
The database server runs on port 9009, so if you run a second SFS instance you should give it another port (e.g. 9010)
Lapo
--
gotoAndPlay()
...addicted to flash games
jamieyg3
Posts: 84
Joined: 25 Sep 2008, 16:01

Post by jamieyg3 »

Lapo wrote:The database server runs on port 9009, so if you run a second SFS instance you should give it another port (e.g. 9010)
I am having problems with this

I'm using 1.6.5

and I put this in:

Code: Select all

<SmartFoxConfig>

        <ServerSetup>
                <H2EnginePort>9010</H2EnginePort>
                <ServerIP>*</ServerIP>
                <ServerPort>9340</ServerPort>
I get this error during startup...

Code: Select all

jvm 1    | 13:41:27.065 - [ INFO ] > Starting h2 engine...
jvm 1    | 13:41:27.170 - [ WARNING ] > Cannot start H2 Engine: org.h2.jdbc.JdbcSQLException: Exception opening port 9009 (port may be in use), cause: java.net.BindException: Address already in use [90061-60]
jvm 1    | org.h2.jdbc.JdbcSQLException: Exception opening port 9009 (port may be in use), cause: java.net.BindException: Address already in use [90061-60]
jvm 1    |      at org.h2.message.Message.getSQLException(Message.java:84)
jvm 1    |      at org.h2.util.NetUtils.createServerSocketTry(NetUtils.java:54)
jvm 1    |      at org.h2.util.NetUtils.createServerSocket(NetUtils.java:39)
jvm 1    |      at org.h2.server.TcpServer.start(TcpServer.java:125)
jvm 1    |      at org.h2.tools.Server.start(Server.java:362)
jvm 1    |      at it.gotoandplay.smartfoxserver.SmartFoxServer.bootH2Engine(SmartFoxServer.java:532)
jvm 1    |      at it.gotoandplay.smartfoxserver.SmartFoxServer.run(SmartFoxServer.java:581)
jvm 1    | Caused by: java.net.BindException: Address already in use
jvm 1    |      at java.net.PlainSocketImpl.socketBind(Native Method)
jvm 1    |      at java.net.PlainSocketImpl.bind(Unknown Source)
jvm 1    |      at java.net.ServerSocket.bind(Unknown Source)
jvm 1    |      at java.net.ServerSocket.<init>(Unknown Source)
jvm 1    |      at java.net.ServerSocket.<init>(Unknown Source)
jvm 1    |      at org.h2.util.NetUtils.createServerSocketTry(NetUtils.java:51)
jvm 1    |      ... 5 more
and a bit further down I see this...

Code: Select all

jvm 1    | --- [ Zones & Rooms ] -------------------------------------
jvm 1    |
jvm 1    |      DB Manager Activated ( org.gjt.mm.mysql.Driver )
jvm 1    | java.lang.NullPointerException
jvm 1    |      at it.gotoandplay.smartfoxserver.data.buddylist.persistence.AdvancedBuddyListPersister.checkIfTableExists(AdvancedBuddyListPersister.java:266)
jvm 1    |      at it.gotoandplay.smartfoxserver.data.buddylist.persistence.AdvancedBuddyListPersister.init(AdvancedBuddyListPersister.java:40)
jvm 1    |      at it.gotoandplay.smartfoxserver.SmartFoxServer.setupZone(SmartFoxServer.java:1893)
jvm 1    |      at it.gotoandplay.smartfoxserver.lib.ConfigReader.parse_Zones(ConfigReader.java:796)
jvm 1    |      at it.gotoandplay.smartfoxserver.lib.ConfigReader.readZoneConfig(ConfigReader.java:174)
jvm 1    |      at it.gotoandplay.smartfoxserver.SmartFoxServer.initServerSocket(SmartFoxServer.java:341)
jvm 1    |      at it.gotoandplay.smartfoxserver.SmartFoxServer.run(SmartFoxServer.java:609)
jvm 1    | Problems in config file: null
jvm 1    | it.gotoandplay.smartfoxserver.exceptions.ConfigurationException
jvm 1    |      at it.gotoandplay.smartfoxserver.lib.ConfigReader.readZoneConfig(ConfigReader.java:199)
jvm 1    |      at it.gotoandplay.smartfoxserver.SmartFoxServer.initServerSocket(SmartFoxServer.java:341)
jvm 1    |      at it.gotoandplay.smartfoxserver.SmartFoxServer.run(SmartFoxServer.java:609)
jvm 1    |
jvm 1    | Errors found in configuration files.
jvm 1    | Unable to start the server.
jvm 1    |
jvm 1    |
jvm 1    | Shutting down server...
any help is appreciated!
jamieyg3
Posts: 84
Joined: 25 Sep 2008, 16:01

Post by jamieyg3 »

also i'm a paying customer so I would like to get this fixed asap, thanks.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

As explained above, ( http://forums.smartfoxserver.com/viewto ... 3089#13089 )
please make sure to use a different port for the database server for each SFS instance running on the same machine.
This setting:

Code: Select all

<H2EnginePort>9009</H2EnginePort>  
should be added in the main config.xml file. (under the root node)

9009 is the default value, any other value should work, like 9010, 9011 etc...
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply