Bitbucket を SQL Server に接続する

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

This page describes how to connect Bitbucket Data Center and Server to a Microsoft SQL Server database. You can connect Bitbucket to a SQL server either at install time using the Setup Wizard, or later using the Using the Database Migration Wizard. These instructions assume that you already have SQL Server installed and running.

The overall process for using a SQL Server database with Bitbucket is:

  • install SQL Server where it is accessible to Bitbucket
  • create a database and user on the SQL Server instance for Bitbucket to use
  • install Bitbucket on Windows, or on Linux or Mac. See the Bitbucket installation guide

See Supported platforms for the versions of SQL Server supported by Bitbucket.

前提条件

現在のデータベースのバックアップ

If you are migrating your data from the internal Bitbucket database, back up the home directory.

If you are migrating your Bitbucket data from a different external database, back up that database by following the instructions provided by the database vendor before proceeding with these instructions.

データの復元とバックアップ」を参照してください。

Create the Bitbucket database

Before you can use Bitbucket with SQL Server, you must set up SQL Server as follows:

ステップ注意
データベースの作成e.g. bitbucket. Remember this database name for the connection step below.
照合タイプの設定大文字と小文字を区別する必要があります。例: 'SQL_Latin1_General_CP1_CS_AS' (CS = Case Sensitive)。
分離レベルの設定分離レベル "Read Committed with Row Versioning" を使用するようにデータベースを設定します。
データベース ユーザーの作成

e.g. bitbucketuser. This database user should not be the database owner, but should be in the db_owner role. It needs to be in this role during setup and at all points when Bitbucket is running due to the way it interacts with the database. See SQL Server Startup Errors. Remember this database user name for the connection step below.

データベース ユーザーの権限の設定

The Bitbucket database user has permission to connect to the database, and to create and drop tables, indexes and other constraints, and insert and delete data, in the newly-created database.

Enable TCP/IPTCP/IP が SQL Server で有効になっており、SQL Server が適切なポートでリッスン (SQL Server インストールの既定の設定では 1433) していることを確認します。以降の接続ステップ用にこのポート番号を記憶しておいてください。
認証モードの確認

Ensure that SQL Server is operating in the appropriate authentication mode. By default, SQL Server operates in 'Windows Authentication Mode'. However, if your user is not associated with a trusted SQL connection, 'Microsoft SQL Server, Error: 18452' is received during Bitbucket startup, and you will need to change the authentication mode to 'Mixed Authentication Mode'.

Bitbucket instances running on Windows are also able to support SQL Server databases running in 'Windows Authentication Mode'. This is described at the bottom of this page and it has to be manually configured: Use Integrated Authentication (Optional)

SET NOCOUNT がオフになっていることの確認SET NOCOUNT オプションがオフになっていることを確認します。SQL Server Management Studio で次のように実行できます。
  1. [Tools] > [Options] > [Query Execution] > [SQL Server] > [Advanced] の順に移動します。SET NOCOUNT オプションがクリアされていることを確認します。
  2. 次に、[Server] > [Properties] > [Connections] > [Default Connections] プロパティ ボックスに移動し、no count オプションをクリアします。

Note that Bitbucket will generally require about 25–30 connections to the database.

Note also that Bitbucket requires the database to keep idle connections alive for at least 10 minutes. If the database is configured with less than a 10 minute connection timeout, there will be seemingly random connection errors

Here is an example of how to create and configure the SQL Server database from the command line. When Bitbucket and SQL Server run on the same physical computer (accessible through localhost), run the following commands (replacing bitbucketuser and password with your own values):

SQL Server> CREATE DATABASE bitbucket
SQL Server> GO
SQL Server> USE bitbucket
SQL Server> GO
SQL Server> ALTER DATABASE bitbucket SET ALLOW_SNAPSHOT_ISOLATION ON
SQL Server> GO
SQL Server> ALTER DATABASE bitbucket SET READ_COMMITTED_SNAPSHOT ON
SQL Server> GO
SQL Server> ALTER DATABASE bitbucket COLLATE SQL_Latin1_General_CP1_CS_AS
SQL Server> GO
SQL Server> SET NOCOUNT OFF
SQL Server> GO
SQL Server> USE master
SQL Server> GO
SQL Server> CREATE LOGIN bitbucketuser WITH PASSWORD=N'password', DEFAULT_DATABASE=bitbucket, CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
SQL Server> GO
SQL Server> ALTER AUTHORIZATION ON DATABASE::bitbucket TO bitbucketuser
SQL Server> GO

This creates an empty SQL Server database with the name bitbucket, and a user that can log in from the host that Bitbucket is running on who has full access to the newly created database. In particular, the user should be allowed to create and drop tables, indexes and other constraints.

Connect Bitbucket to the SQL Server database

You can now connect Bitbucket to the SQL Server database, either:

  • インストール時にセットアップ ウィザードを実行する場合
  • 埋め込みデータベースまたは別の外部データベースから SQL Server に移行したい場合。

インストール時にセットアップ ウィザードを実行する場合

  1. "Database" 手順で [External] を選択します。
  2. Database Type に [SQL Server] を選択します。
  3. フォームに入力します。詳細は、以下の表を参照してください。
  4. Click Next, and follow the instructions in the Bitbucket Setup Wizard.

SQL Server に移行する場合

  1. In the Bitbucket administration area, click Database (under 'Settings').
  2. [データベースの移行] をクリックします。
  3. Database Type に [SQL Server] を選択します。
  4. フォームに入力します。詳細は、以下の表を参照してください。
  5. [移行の開始] をクリックします。


ホスト名

データベース サーバーを実行するコンピューターのホスト名または IP アドレス。

ポート

The TCP port with which Bitbucket can connect to the database server. The default value of 1433 is the default port that SQL Server runs against. You can change that if you know the port that your SQL Server instance is using.

データベース名

The name of the database that Bitbucket should connect to.

データベース ユーザー名

The username that Bitbucket should use to access the database.

データベース パスワード

The password that Bitbucket should use to access the database.

名前付きインスタンス

If you have a named instance on your server, you will need to manually edit the bitbucket.properties file as described on the Connecting to named instances in SQL Server from Bitbucket Server Knowledge Base article.

"Windows Authentication Mode" または統合認証を使用する (オプション)

Windows authentication is only available for Bitbucket instances running on Windows. It cannot be used on Linux because Microsoft does not provide shared objects for it. You will either need to run Bitbucket on Windows, allowing you to use Windows security, or you will need to enable mixed-mode authentication for SQL Server if you are running Bitbucket on Linux. Unfortunately, there are no other options at this time.

統合認証はネイティブの DLL を使用してログイン済みのユーザーの資格情報にアクセスし、SQL Server で認証します。32 ビットと 64 ビット システム用の両方のネイティブ DLL がディストリビューションに含まれ、Microsoft からパッケージ全体をダウンロードする必要はありません。

Bitbucket does not currently support configuring the system to use integrated authentication from the UI (Vote for it! STASH-3035 - Getting issue details... STATUS ). This means you can't currently migrate to SQL Server with integrated authentication, nor can you configure Bitbucket to use SQL Server with integrated authentication during initial setup. However, if Bitbucket has already been configured to use SQL Server (for example, when the Setup Wizard was run at first use), you can enable integrated authentication by directly modifying Bitbucket's configuration, as follows:

  1. Based on the JVM being used to run Bitbucket, rename either the x64 or x86 DLL to sqljdbc_auth.dll in lib/native. Note that running on Windows x64 does not require the use of the x64 DLL; you should only use the x64 DLL if you are also using a 64-bit JVM.
  2. In _start-webapp.bat, a JVM_LIBRARY_PATH variable has already been defined. Simply remove the leading rem . Note that if you are putting the native DLL in an alternative location, you may need to change the value to point to your own path. The value of the JVM_LIBRARY_PATH variable will automatically be included in the command line when Tomcat is run using start-bitbucket.bat.
  3. Edit the %BITBUCKET_HOME%\shared\bitbucket.properties file to include ;integratedSecurity=true in the jdbc.url line. Note that jdbc.user and jdbc.password will no longer be used to supply credentials but they must still be defined – Bitbucket will fail to start if these properties are removed.
  4. Ensure the Bitbucket process or service is running as the correct user to access SQL Server.  (Note that this user is generally a Windows Domain User Account, but should not be a member of any administrators groups, that is local, domain, or enterprise.)

ネイティブの DLL を使用するのではなく、Kerberos 経由で統合認証を設定することもできます。この方法の詳細は JDBC ドキュメントに含まれています。

JDBC ドライバのインストール

This section is only relevant to some distributions of Bitbucket, for example if you are running Bitbucket via the Atlassian Plugin SDK, or have built Bitbucket from source.

If the SQL Server JDBC driver is not bundled with Bitbucket, you will need to download and install the driver yourself.

  1. 適切な JDBC ドライバを Microsoft のダウンロード サイトからダウンロードします。
  2. Install the driver file to your <Bitbucket home directory> /lib directory (for Bitbucket 2.1 or later).
  3. Stop, then restart, Bitbucket. See Start and stop Bitbucket.

If Bitbucket was configured to use Microsoft SQL Server by manually entering a JDBC URL, please refer to this guide.

最終更新日: 2023 年 1 月 4 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.