Este contenido no está disponible en el idioma seleccionado.
Chapter 3. Tutorials
These tutorials follow on from and assume an OpenShift Container Platform 3.9 instance similar to that created in OpenShift Container Platform 3.9 Getting Started.
In this tutorial you prepare and deploy a multiple-node AMQ Broker instance with persistent storage.
3.1. Preparing the AMQ Broker deployment Copiar enlaceEnlace copiado en el portapapeles!
Procedure
At a command prompt, create a new project:
$ oc new-project amq-demoCreate a service account to be used for the AMQ Broker deployment:
$ echo '{"kind": "ServiceAccount", "apiVersion": "v1", "metadata": {"name": "amq-service-account"}}' | oc create -f -Add the view role to the service account. The view role enables the service account to view all the resources in the amq-demo namespace, which is necessary for managing the cluster when using the OpenShift dns-ping protocol for discovering the mesh endpoints.
$ oc policy add-role-to-user view system:serviceaccount:amq-demo:amq-service-accountAMQ Broker requires a broker keystore, a client keystore, and a client truststore that includes the broker keystore. This example uses Java Keytool, a package included with the Java Development Kit, to generate dummy credentials for use with the AMQ Broker installation.
Generate a self-signed certificate for the broker keystore:
$ keytool -genkey -alias broker -keyalg RSA -keystore broker.ksExport the certificate so that it can be shared with clients:
$ keytool -export -alias broker -keystore broker.ks -file broker_certGenerate a self-signed certificate for the client keystore:
$ keytool -genkey -alias client -keyalg RSA -keystore client.ksCreate a client truststore that imports the broker certificate:
$ keytool -import -alias broker -keystore client.ts -file broker_certUse the broker keystore file to create the AMQ Broker secret:
$ oc secrets new amq-app-secret broker.ksAdd the secret to the service account created earlier:
$ oc secrets add sa/amq-service-account secret/amq-app-secret
3.2. Deploying the image and template Copiar enlaceEnlace copiado en el portapapeles!
Procedure
-
Navigate to the OpenShift web console and log in, selecting the
amq-demoproject space. - Click Add to Project > Browse catalog to list all of the default image streams and templates.
-
Use the Filter search bar to limit the list to those that match
amq. You might need to click See all to show the desired application template. Select a template. This example uses the
amq-broker-71-persistence-ssl.yamltemplate to allow for persistent storage and SSL.Expand Table 3.1. Example template Environment variable Value APPLICATION_NAME
broker
AMQ_TRANSPORTS
openwire
AMQ_USER
amq-demo-user
AMQ_PASSWORD
password
VOLUME_CAPACITY
512Mi
AMQ_KEYSTORE_TRUSTSTORE_DIR
/etc/amq-secret-volume
AMQ_TRUSTSTORE
broker.ts
AMQ_TRUSTSTORE_PASSWORD
password
AMQ_KEYSTORE
broker.ks
AMQ_KEYSTORE_PASSWORD
password
IMAGE_STREAM_NAMESPACE
openshift
3.3. Post-deployment Copiar enlaceEnlace copiado en el portapapeles!
3.3.1. Creating a route Copiar enlaceEnlace copiado en el portapapeles!
You must create a route for the broker so that clients outside of OpenShift Container Platform can connect using SSL. By default, the OpenWire protocol uses the 61617/TCP port.
Only one broker can be scaled up. You cannot scale up multiple brokers.
Procedure
- Click Create a Route and from the Service drop-down menu, click broker-amq-tcp-ssl.
- Select the Secure route check box to display the TLS parameters.
- From the TLS Termination drop-down menu, click Passthrough. This selection relays all communication to AMQ Broker without the OpenShift router decrypting and resending it.
Clients can now connect to the broker by specifying the following in their configuration:
factory.setBrokerURL("failover://ssl://broker-amq-demo.example.com:443");
3.3.1.1. Monitoring AMQ Broker Copiar enlaceEnlace copiado en el portapapeles!
This tutorial demonstrates how to monitor AMQ Broker.
Prerequisite
You must have created a project and a service account, and added the view role to the service account for AMQ Broker deployment. For more information see Preparing the AMQ Broker deployment.
Procedure
At the command line, go to your project:
$ oc project monitoramqDeploy a new broker instance to the
monitoramqproject, using theamq-broker-71-basictemplate from theopenshiftnamespace:$ oc process openshift//amq-broker-71-basic -p APPLICATION_NAME=broker -p AMQ_USER=admin -p AMQ_PASSWORD=admin -p AMQ_QUEUES=TESTQUEUE -n monitoramq | oc create -f - services "broker-amq-amqp" created services "broker-amq-mqtt" created services "broker-amq-stomp" created services "broker-amq-tcp" created deploymentconfigs "broker-amq" createdGet the list of running pods:
$ oc get pods NAME READY STATUS RESTARTS AGE broker-amq-1-ftqmk 1/1 Running 0 14dRun the
oc logscommand:oc logs -f broker-amq-1-ftqmk Running /amq-broker-71-openshift image, version 1.3-5 INFO: Loading '/opt/amq/bin/env' INFO: Using java '/usr/lib/jvm/java-1.8.0/bin/java' INFO: Starting in foreground, this is just for debugging purposes (stop process by pressing CTRL+C) ... INFO | Listening for connections at: tcp://broker-amq-1-ftqmk:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600 INFO | Connector openwire started INFO | Starting OpenShift discovery agent for service broker-amq-tcp transport type tcp INFO | Network Connector DiscoveryNetworkConnector:NC:BrokerService[broker-amq-1-ftqmk] started INFO | Apache ActiveMQ 5.11.0.redhat-621084 (broker-amq-1-ftqmk, ID:broker-amq-1-ftqmk-41433-1491445582960-0:1) started INFO | For help or more information please see: http://activemq.apache.org WARN | Store limit is 102400 mb (current store usage is 0 mb). The data directory: /opt/amq/data/kahadb only has 9684 mb of usable space - resetting to maximum available disk space: 9684 mb WARN | Temporary Store limit is 51200 mb, whilst the temporary data directory: /opt/amq/data/broker-amq-1-ftqmk/tmp_storage only has 9684 mb of usable space - resetting to maximum available 9684 mb.Run your query to monitor your broker for
MaxConsumers:$ curl -k -u admin:admin http://console-broker.monitoramq.apps.example.com/console/jolokia/read/org.apache.activemq.artemis:broker=%22broker%22,component=addresses,address=%22TESTQUEUE%22,subcomponent=queues,routing-type=%22anycast%22,queue=%22TESTQUEUE%22/MaxConsumers {"request":{"mbean":"org.apache.activemq.artemis:address=\"TESTQUEUE\",broker=\"broker\",component=addresses,queue=\"TESTQUEUE\",routing-type=\"anycast\",subcomponent=queues","attribute":"MaxConsumers","type":"read"},"value":-1,"timestamp":1528297825,"status":200}