搜索

此内容没有您所选择的语言版本。

Chapter 3. Tutorials

download PDF

3.1. Prerequisite

Before undertaking these tutorials, you must configure your environment correctly.

See the OpenShift Primer for instructions.

3.2. Deploy your project using the Red Hat JBoss Data Virtualization for OpenShift image

Use this workflow to create and deploy a project. As an example, the tutorial uses the dynamicvdb-datafederation quickstart which combines data from a relational source (H2) and a Microsoft Excel file. After deploying it, you will learn how to switch data sources.

  1. Create a new project:

    $ oc new-project jdv-app-demo
  2. Create a service account to be used for the Red Hat JBoss Data Virtualization for OpenShift deployment:

    $ oc create serviceaccount datavirt-service-account
  3. Add the view role to the service account:

    $ oc policy add-role-to-user view system:serviceaccount:jdv-app-demo:datavirt-service-account
  4. The Red Hat JBoss Data Virtualization for OpenShift template requires SSL and JGroups keystores.
    (These keystores are required even if the application will not use https.)
    The following commands will prompt you for passwords:

    1. Generate a secure key for the SSL keystore:

      $ keytool -genkeypair -alias https -storetype JKS -keystore keystore.jks
    2. Generate a secure key for the JGroups keystore:

      $ keytool -genseckey -alias jgroups -storetype JCEKS -keystore jgroups.jceks
  5. Use the SSL and JGroup keystore files to create the keystore secret for the project:

    $ oc secret new datavirt-app-secret keystore.jks jgroups.jceks
  6. Create a secret with the datasources.env file:

    git clone https://github.com/jboss-openshift/openshift-quickstarts/blob/master/datavirt/dynamicvdb-datafederation/datasources.env
    $ oc secrets new datavirt-app-config datasources.env
  7. Link the keystore and environment secrets to the service account:

    $ oc secrets link datavirt-service-account datavirt-app-secret datavirt-app-config
  8. Log in to the OpenShift Web Console: https://127.0.0.1:8443
  9. Click jdv-app-demo.
  10. Click Add to Project.
  11. Click Browse Catalog.
  12. Enter datavirt in the Filter by keyword search bar.
  13. Click basic-s2i.
  14. Enter these parameters:
    Git Repository URL: https://github.com/jboss-openshift/openshift-quickstarts
    Git Reference: master
    CONTEXT_DIR: datavirt64/dynamicvdb-datafederation/app
  15. Click Deploy.
  16. Switch to using a MySQL data source instead of H2:

    $ oc env dc/datavirt-app QS_DB_TYPE=mysql5

3.3. How to use a cache as a materialization target

Having deployed the dynamicvdb-datafederation quickstart, you can now deploy a Red Hat JBoss Data Grid instance. This allows you to quickly query the cache for data, without having to go back to the original sources.

You can use any of the Red Hat JBoss Data Grid for OpenShift templates, but it is better to use non-persistent templates as these provide you with clustering and high availability functionality. To obtain them, click here: https://github.com/jboss-container-images/jboss-datavirt-6-openshift-image/tree/datavirt64/resources/openshift/templates

  1. Enter the jdv-app-demo project:

    $ oc project jdv-app-demo
  2. Create a service account for JDG for OpenShift:

    $ oc create serviceaccount datagrid-service-account
  3. Add view role permissions to the service account:

    $ oc policy add-role-to-user view system:serviceaccount:jdv-app-demo:datagrid-service-account
  4. Create the keystore secret for the project:

    $ oc secret new datagrid-app-secret jgroups.jceks
  5. Link the keystore secret to the service account:

    $ oc secrets link datagrid-service-account datagrid-app-secret
  6. Log in to the OpenShift Web Console.
  7. Click the jdv-app-demo project space.
  8. Click Add to Project.
  9. Enter datagrid in the Filter by keyword search bar.
  10. Click the datagrid71-https template.
  11. In the DATAVIRT_CACHE_NAMES environment variable field, enter stockCache.
  12. In the CACHE_TYPE_DEFAULT environment variable field, enter replicated.
  13. Enter these parameters:
    USERNAME: jdg
    PASSWORD: JBoss.123
    JDG User Roles/Groups (ADMIN_GROUP): admin,___schema_manager
    HOTROD_AUTHENTICATION: true
    CONTAINERSECURITYROLE_MAPPER: identity-role-mapper
    CONTAINER_SECURITY_ROLES:"admin=ALL,jdg=ALL"
  14. Click Deploy.
  15. Set JDG as the materialization target:
$ oc env bc/datavirt-app DATAGRID_MATERIALIZATION=true
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.