Connecting to named instances in SQL Server from Bitbucket Data Center
Summary
When using named instances you will need to specify the URL slightly differently in the connection properties. This issue will be addressed through BSERV-3759 - Getting issue details... STATUS
You could try one of the 2 options below:
- Linking an empty instance to a SQL Server Named Instance
- Migrating from H2 to SQL Server
Solution
Linking an empty instance to a SQL Server Named Instance
In this scenario, after executing the procedure below, you will have your Bitbucket Data Center instance linked to a new and empty Named Instance database.
To perform this, either you currently have no data at all stored in your Bitbucket Data Center instance (or they are not relevant) and the repositories could be either discarded or they could be manually imported into the new instance linked to your SQL Server later on.
Before performing the procedure below, please make sure you have an empty database that is configured according to the documentation: Connecting Bitbucket Server to SQL Server. Make sure you can connect to it with a third-party tool before proceeding.
- Before proceeding, back up your instance data.
Procedure:
Create/edit the
bitbucket.properties
within your$BITBUCKET_HOME/shared
with the following content:jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver jdbc.url=jdbc:sqlserver://<hostname>\\<instance_name>;databaseName=<database_name> jdbc.user=bitbucket jdbc.password=bitbucket
Alternatively, use the URL below in case the one above does not work:
jdbc.url=jdbc:sqlserver://<hostname>;instanceName=<instance_name>;databaseName=<database_name>;
- Tweak the parameters
jdbc.url, jdbc.user and jdbc.password
accordingly. - As soon as you restart Bitbucket Server, it will try to connect to the database using the parameters above. If this step is successful, it won't detect anything in there as the database is empty. Bitbucket Server will "think", then, that this is a new installation and you will have to go through the process again.
- In case of failure, you can always remove
bitbucket.properties
and it will use the H2. - In major failures, use the backup client to restore your instance.
Do not put the port 1433 in a hostname in JDBC URL as it points directly to the Default Instance and <instance_name> parameter will be ignored.
A migration from H2 to SQL Server
Due to BSERV-3759, it is not possible to migrate a SQL Server Named instance Using the Database Migration Wizard.
An alternative is to use our backup client and perform a current backup of your instance.
You can later on Restore Bitbucket Server into a newly created DB instance pointing now to your newly created SQL Server empty database passing the parameters below during the restore (configuration below is related to the backup/restore client):
jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.url=jdbc:sqlserver://<hostname>\\<instance_name>;databaseName=<database_name>
jdbc.user=bitbucket
jdbc.password=bitbucket
Alternatively use the URL below in case the one above does not work:
jdbc.url=jdbc:sqlserver://<hostname>;instanceName=<instance_name>;databaseName=<database_name>;
In $BITBUCKET_HOME/shared/bitbucket.properties
, please add the following for the jdbc.url
:
jdbc.url=jdbc:sqlserver://<hostname>\\<instance_name>;databaseName=<database_name>
i.e.
jdbc.url=jdbc:sqlserver://localhost\\MSSQL13;databaseName=bitbucket
Alternatively:
jdbc.url=jdbc:sqlserver://<hostname>;instanceName=<instance_name>;databaseName=<database_name>;
i.e.
jdbc.url=jdbc:sqlserver://localhost;instanceName=MSSQL13;databaseName=bitbucket;