Bluemix Local:如何将现有的本地DB2数据库添加为服务?

时间:2022-05-31 09:11:43

I am using Bluemix Local and have an existing on-premises database (DB2 LUW) that I want to use with a Cloud Foundry application. How can I make that database "testDB" available as a service, so that my app can use the VCAP_SERVICES variable to access that database?

我正在使用Bluemix Local并且有一个现有的本地数据库(DB2 LUW),我想与Cloud Foundry应用程序一起使用。如何将该数据库“testDB”作为服务提供,以便我的应用程序可以使用VCAP_SERVICES变量来访问该数据库?

Do I need a custom broker or will an user-provided service do the trick?

我是否需要自定义代理或用户提供的服务才能实现?

cf cups db2-testdb only adds a service, but no JDBC properties.

cf cups db2-testdb只添加服务,但没有JDBC属性。

1 个解决方案

#1


3  

The user-provided service is the right choice to make any existing on-premises database, DB2 in your case, available for a Cloud Foundry app on Bluemix Local (actually any Cloud Foundry instance).

用户提供的服务是使任何现有的本地数据库(在您的情况下为DB2)可用于Bluemix Local上的Cloud Foundry应用程序(实际上是任何Cloud Foundry实例)的正确选择。

  1. Log in to Bluemix/Cloud Foundry
  2. 登录Bluemix / Cloud Foundry

  3. Create the user-provided service
  4. 创建用户提供的服务

  5. Bind the service to an app
  6. 将服务绑定到应用程序

You can also update the properties of an user-provided service.

您还可以更新用户提供的服务的属性。

To specify properties during creation use: cf cups db2-testdb -p '{"jdbcURL" : "jdbc:db2://yourMachine.com:50000/TESTDB"}'

要在创建期间指定属性:cf cups db2-testdb -p'{“jdbcURL”:“jdbc:db2://yourMachine.com:50000 / TESTDB”}'

To later on change properties (update-user-provided-service): cf uups db2-testdb -p '{"jdbcURL" : "jdbc:db2://yourMachine2.com:40000/TESTDB02"}'

稍后更改属性(update-user-provided-service):cf uups db2-testdb -p'{“jdbcURL”:“jdbc:db2://yourMachine2.com:40000 / TESTDB02”}'

To bind the service to an app use either the GUI or the following command: cf bind-service yourAppName db2-testdb Your app would then be able to find the service via the VCAP_SERVICES variable and read out the value for jdbcURL. See this blog entry for details.

要将服务绑定到应用程序,请使用GUI或以下命令:cf bind-service yourAppName db2-testdb然后,您的应用程序将能够通过VCAP_SERVICES变量查找服务并读取jdbcURL的值。有关详情,请参阅此博客条目。

#1


3  

The user-provided service is the right choice to make any existing on-premises database, DB2 in your case, available for a Cloud Foundry app on Bluemix Local (actually any Cloud Foundry instance).

用户提供的服务是使任何现有的本地数据库(在您的情况下为DB2)可用于Bluemix Local上的Cloud Foundry应用程序(实际上是任何Cloud Foundry实例)的正确选择。

  1. Log in to Bluemix/Cloud Foundry
  2. 登录Bluemix / Cloud Foundry

  3. Create the user-provided service
  4. 创建用户提供的服务

  5. Bind the service to an app
  6. 将服务绑定到应用程序

You can also update the properties of an user-provided service.

您还可以更新用户提供的服务的属性。

To specify properties during creation use: cf cups db2-testdb -p '{"jdbcURL" : "jdbc:db2://yourMachine.com:50000/TESTDB"}'

要在创建期间指定属性:cf cups db2-testdb -p'{“jdbcURL”:“jdbc:db2://yourMachine.com:50000 / TESTDB”}'

To later on change properties (update-user-provided-service): cf uups db2-testdb -p '{"jdbcURL" : "jdbc:db2://yourMachine2.com:40000/TESTDB02"}'

稍后更改属性(update-user-provided-service):cf uups db2-testdb -p'{“jdbcURL”:“jdbc:db2://yourMachine2.com:40000 / TESTDB02”}'

To bind the service to an app use either the GUI or the following command: cf bind-service yourAppName db2-testdb Your app would then be able to find the service via the VCAP_SERVICES variable and read out the value for jdbcURL. See this blog entry for details.

要将服务绑定到应用程序,请使用GUI或以下命令:cf bind-service yourAppName db2-testdb然后,您的应用程序将能够通过VCAP_SERVICES变量查找服务并读取jdbcURL的值。有关详情,请参阅此博客条目。