HOW TO CONNECT TO A FIREBIRD DATABASE ON AN AMAZON EC2 WINDOWS SERVER INSTANCE

HOW TO CONNECT TO A FIREBIRD DATABASE ON AN AMAZON EC2 WINDOWS SERVER INSTANCE

Just worked this out - might be useful to others. 

To connect to a remote database file on an Amazon EC2 Windows server instance*, do the following...*

1.  Go to the AWS dashboard, log in to your Amazon account and go to Networks and Security|Security Groups
    These AWS Security Groups are  bit like a firewall for your Amazon servers and other services. (NB  They are geographic region specific)

2. Chose the Security Group to which your EC2 instance belongs and select the Inbound and then Outbound rules listing

3.  Add to each Inbound and Outbound rules listing a rule to allow a TCP communication through Port 3050 (default port for Firebird)
     setting from any IP address (0.0.0.0/0) or your own computer's specific IP address if you want to restrict access to just yourself

4.  Make sure the EC2 instance running of course

5.  Connect to the EC2 instance with RDP and look at the Windows desktop, on which the EC2 server's public IP address is written.
     Copy down with IP address

6.  Open up the EC2 servers Windows Control Panel (right click the Windows icon bottom left corner and click control Panel) and then
     Open up the EC2 Windows server's own firewall

7.  Select Advanced settings on the left hand side and then for both Inbound Rules and Outbound Rules make a new rule to permit
     access via port 3050 for Firebird (New Rule|Port|TCP|Specific Remote Port)

8.  Make sure that the correct version of Firebird is installed and running on the EC2 server (download from www.firebirdsql.org)

9.  Close the RDP connnection and go to your own computer's Firewall and also set ports 3050 inbound and outbound open as you did
     for the EC2 server's firewall.

10.Open your Delphi application and set its TFDConnection.parameters as follows:

     Database=12.345.67.89:c:\pathtoyourdatabase\databaefilename.fdb
     User_Name=SYSDBA
     Password=masterkey
     DriverID=FB

11.Also set the FDConnection.VendorLib := c:\pathtoyourlocalVendorLib\fbclient.dll  (this is on your client computer)

12.FDConnection.connected := true

and so connect to your remote database on the EC2 cloud.

Seems to work well for me.  For better security obviously change the user name and password on the Firebird server on the EC2 instance.
You do not need firebird running on your own computer, but do need the Firebird vendor library fbclient.dll as specified above.  Also
consider limiting the AWS Security Group rules to just the few  IP addresses your users will use if possible.

Cheers,

Martin
http://www.firebirdsql.org

Comments

  1. Hi!

    If this is for your education, before selecting a platform, I would educate myself if I were you.

    What I'd do as a start is a simple Indy server accepting TCP commands.
    I would use the JVCL string holder component for the queries and have commands which CRUD into the DB from the client.
    Then I would start using the TClientDataset's delta for updates on the server side. After that, I'd create a specialised XML file to transmit and use the XML converter bundled with many Delphi versions to transform the CDS delta into something else. This will give you an idea of how things work, what is good, what is not so good, etc. ti will, in other words, allow you to understand the mechanics.

    Once you have a good grasp of the issues (of which there are many...) the platform selection process is pretty simple. Here's a "Select the platform 101":

    - How many concurrent users will you have?
    - Will my APIs be stable or change often?
    - What is the speed of the framework? Does it support the amount of
      concurrent connections I need without blowing up?
    - Does it support my database?
    - Does it make changing library easy?
    - How much does it cost?

    All of the above factors are important from the user/business
    perspective. Then there are the technical ones:

    - Do I want to use the "old Delphi" style for some reason?
    - Do I have to integrate or make integration possible with
      legacy Delphi applications?
    - Does it make using complementary libraries easy?
    - Do I want to abide by DDD?
    - Do I need to unit-test (stuff like DataSnap and RemObjects makes
      unit-testing very hard)?

    When you have the list of what's important for you, you can examine what you really need. Here's a list of frameworks you might want to look at:

    - Old Datasnap (totally discouraged, COM-based)
    - New Datasnap (performance and stability issues when lots of
      connections present)
    - RemObjects (very good quality, highly recommended if your API is
      stable and does not need to change every few months)
    - RTC SDK (very good quality, highly recommended if you think that your
      APIs will change frequently)
    - mORMot (very good quality, highly recommended if you are looking at
      using DDD)

    There are other things you could look at, but I think most people here will agree with my assessment. Obviously, if anybody's got other frameworks I am missing, feel free to add to the list :)

    A

    ReplyDelete
  2. Hi Andrea,
    Thanks for your comprehensive advice.  Will play with the basic Indy components, then it seems Datasnap might be appropriate. I have much to learn. 
    Cheers,
    Martin

    ReplyDelete
  3. MSG Endo did you notice that the only ones where I didn't put "highly recommended" are both DataSnap? :) That was not a mistake :)

    A

    ReplyDelete

Post a Comment