Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 3. Tutorials
3.1. Prerequisite Link kopierenLink in die Zwischenablage kopiert!
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 Link kopierenLink in die Zwischenablage kopiert!
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.
Create a new project:
oc new-project jdv-app-demo
$ oc new-project jdv-app-demo
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a service account to be used for the Red Hat JBoss Data Virtualization for OpenShift deployment:
oc create serviceaccount datavirt-service-account
$ oc create serviceaccount datavirt-service-account
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the view role to the service account:
oc policy add-role-to-user view system:serviceaccount:jdv-app-demo:datavirt-service-account
$ oc policy add-role-to-user view system:serviceaccount:jdv-app-demo:datavirt-service-account
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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:
Generate a secure key for the SSL keystore:
keytool -genkeypair -alias https -storetype JKS -keystore keystore.jks
$ keytool -genkeypair -alias https -storetype JKS -keystore keystore.jks
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Generate a secure key for the JGroups keystore:
keytool -genseckey -alias jgroups -storetype JCEKS -keystore jgroups.jceks
$ keytool -genseckey -alias jgroups -storetype JCEKS -keystore jgroups.jceks
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
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
$ oc secret new datavirt-app-secret keystore.jks jgroups.jceks
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a secret with the datasources.env file:
git clone https://github.com/jboss-openshift/openshift-quickstarts/blob/master/datavirt/dynamicvdb-datafederation/datasources.env
git clone https://github.com/jboss-openshift/openshift-quickstarts/blob/master/datavirt/dynamicvdb-datafederation/datasources.env
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc secrets new datavirt-app-config datasources.env
$ oc secrets new datavirt-app-config datasources.env
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Link the keystore and environment secrets to the service account:
oc secrets link datavirt-service-account datavirt-app-secret datavirt-app-config
$ oc secrets link datavirt-service-account datavirt-app-secret datavirt-app-config
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Log in to the OpenShift Web Console: https://127.0.0.1:8443
- Click jdv-app-demo.
- Click Add to Project.
- Click Browse Catalog.
- Enter datavirt in the Filter by keyword search bar.
- Click basic-s2i.
-
Enter these parameters:
Git Repository URL: https://github.com/jboss-openshift/openshift-quickstarts
Git Reference: master
CONTEXT_DIR: datavirt64/dynamicvdb-datafederation/app - Click Deploy.
Switch to using a MySQL data source instead of H2:
oc env dc/datavirt-app QS_DB_TYPE=mysql5
$ oc env dc/datavirt-app QS_DB_TYPE=mysql5
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.3. How to use a cache as a materialization target Link kopierenLink in die Zwischenablage kopiert!
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
Enter the jdv-app-demo project:
oc project jdv-app-demo
$ oc project jdv-app-demo
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a service account for JDG for OpenShift:
oc create serviceaccount datagrid-service-account
$ oc create serviceaccount datagrid-service-account
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add view role permissions to the service account:
oc policy add-role-to-user view system:serviceaccount:jdv-app-demo:datagrid-service-account
$ oc policy add-role-to-user view system:serviceaccount:jdv-app-demo:datagrid-service-account
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the keystore secret for the project:
oc secret new datagrid-app-secret jgroups.jceks
$ oc secret new datagrid-app-secret jgroups.jceks
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Link the keystore secret to the service account:
oc secrets link datagrid-service-account datagrid-app-secret
$ oc secrets link datagrid-service-account datagrid-app-secret
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Log in to the OpenShift Web Console.
- Click the jdv-app-demo project space.
- Click Add to Project.
- Enter datagrid in the Filter by keyword search bar.
- Click the datagrid71-https template.
- In the DATAVIRT_CACHE_NAMES environment variable field, enter stockCache.
- In the CACHE_TYPE_DEFAULT environment variable field, enter replicated.
-
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"
- Click Deploy.
- Set JDG as the materialization target:
oc env bc/datavirt-app DATAGRID_MATERIALIZATION=true
$ oc env bc/datavirt-app DATAGRID_MATERIALIZATION=true