WebLogic domain configuration policy

The domain contains the configuration information of the BEA WebLogic Server instance. It contains configuration information about servers, clusters, and machines. The domain also contains configuration information about resources, such as Java Database Connectivity (JDBC), connection pools, JDBC data sources, connection factories, and Java Message Service (JMS) queues. In addition, the domain contains configuration information about the application deployed on the instance. The domain configuration information is stored in the config.xml file. In this article, I will evaluate various strategies for WebLogic domain configuration.

  You can directly manipulate the config.xml file (for example, manually edit the file). But most of the tools reviewed in this article will indirectly manipulate config.xml. Most tools (for example, WebLogic Console) deal with Java Management Extensions (JMX) Management Beans (MBeans). The WebLogic Server instance saves the state of the MBean in the config.xml file.

The domain configuration and JMX
  config.xml file contains persistent information about the WebLogic Server instance. When the WebLogic Server instance starts, WebLogic Server reads the config.xml file and deploys resources and applications. Resources and applications have corresponding MBeans. The server accesses configuration information through these MBeans. There are many different types of MBeans. In this article, I mainly discuss the MBean corresponding to the entry in the config.xml file.
  If the attribute value of the Mbean is changed at runtime, the new value will be saved in the config.xml file, making it a persistent value. For example, if you modify the attribute value of the Mbean in the WebLogic Server Console, the attribute value will also be saved in the config.xml file. Therefore, during the server restart, the configuration attribute value can be used because the configuration attribute value is persistently stored in the config.xml file.
  The following section describes various methods of domain creation and configuration, and categorizes the different available options.
Numerous options
  Fortunately, there are many different ways to create and configure domains. The most common way to create a domain is to use the Domain Configuration Wizard (domain configuration wizard), and the most common way to configure a domain is to use the WebLogic Console. There are many other methods available, including:

 

  • Use the domain configuration wizard
  • Use domain configuration templates
  • Use silent script
  • Use WLShell script
  • Use WLST script
  • Direct use of Java coding and JMX application programming interface (API)
  • Use token substitution (for example, Bedrock)
  • Use weblogic administrator commands
  • Use wlconfig and wldeploy Ant tasks
  • Manually edit the config.xml file

  The following is a way to classify the above options according to the technology used in the configuration domain:

  • 手动:WebLogic Console、Complete Domain Configuration Wizard
  • Templates: custom symbol substitution scripts (for example, using Ant), Bedrock, full templates, extended templates
  • Script: Silent, WLShell, WLST, Ant
  • Programming in Java

  Another way to categorize the above options is based on whether they are released with the WebLogic platform:

  • Included (and supported): WebLogic Console, full Domain Configuration Wizard, full template, extended template, silent script, Ant
  • Others: WL Shell, WLST, custom symbol replacement script, Bedrock

  Another way to classify the above options is to modify the options according to whether the server is online or offline. When the server instance is running, make online modifications. The JMX Mbean is modified online by the server and saved in the config.xml file. When the server is running, it is recommended not to modify the config.xml file directly.

  • Online: WebLogic Console, ANT, WLST
  • Offline: Complete Domain Configuration Wizard, complete template, extended template, silent script, WLShell, custom symbol replacement script, Bedrock

  To illustrate the various strategies for domain configuration, you will create a domain and modify it.

Advanced goals
  use different domain creation and configuration strategies, you will achieve the following goals: please do not follow these steps immediately. Later, I will ask you to create and configure a domain with a different strategy each time:

  1. Create WebLogic Workshop domain
  2. Change the debugging level of the server to the information level
  3. Change the server to enable debugging to standard output (stdout)
  4. Configure a JDBC connection pool named semJDBCConnectionPool
  5. Configure a JDBC data source named jdbc/semJDBCDataSource, and its JNDI name is jdbc/semJDBCDataSource
  6. Configure a JMS connection factory named semJMSConnectionFactory
  7. Configure a JMSJDBCStore named semJMSJDBCStore
  8. Configure a JMSServer named semJMSServer
  9. Configure a semJMSServe warehouse named semJMSJDBCStore
  10. Configure a JMS queue named PersonQueue, whose JNDI name is jms/PersonQueue
  11. Deploy the sample application: SEMApp Enterprise ARchive (EAR)
  12. Test the application, verify the domain configuration

  For each strategy, certain steps such as domain creation, database configuration, and verification configuration are common. The following sections describe these steps.

Domain creation
  Using the Domain Configuration Wizard, follow these steps to create a WebLogic Workshop domain. Please do not proceed with these steps immediately. Later, when I explain the different strategies in detail, I will ask you to perform these steps:

  1. Start the Domain Configuration Wizard (for example, on Windows, select Start> All Programs> BEA WebLogic Platform> Configuration Wizard)
  2. Select Create a new WebLogic Configuration, and click Next
  3. Select Basic WebLogic Workshop Domain, and click Next
  4. Select Express, and click Next
  5. Specify the User name as system
  6. Specify User password and Confirm user password as password, and click Next
  7. Select Development Mode, and click Next
  8. Specify the Configuration Name as some meaningful name, and click Create
  9. Click Done

  Before you can configure the domain, you need to configure the database. The database configuration occurs after the domain is created and before the domain is configured.

Database configuration
  All examples use PointBase as the database. Start the instance of WebLogic Server (Workshop domain) also started PointBase. In the PointBase instance, create users, schemas, and tables. Please do not proceed with these steps immediately. Later, when I explain the different strategies in detail, I will ask you to perform these steps:

  1. Verify that an instance of WebLogic Server is running
  2. Start the PointBase console (for example, on Windows, select Start> All Programs> BEA WebLogic Platform> Examples> WebLogic Workshop> PointBase Console)
  3. In the Connect to the database dialog box, specify the following
  4. The URL of the verification database is: jdbc:pointbase:server://localhost:9093/workshop
  5. Verify that User is WebLogic
  6. Specify Password as WebLogic
  7. Create a new user (for example, Ctrl+u), the user name is sem, the password is also sem
  8. Disconnect from the database (DBA menu and Disconnect from Database)
  9. Use sem as User and sem as Password to connect to the database (DBA menu and Connect to Database or F3)
  10. Create a pattern (for example, Ctrl + h) and name it sem
  11. Copy and paste the contents of db/sem.sql into the Enter SQL Commands window
  12. Select the Execute All toolbar entry
  13. Verify that sem mode has been used for production

  Once the domain is created, the database is configured, and to configure the domain with resources and sample applications, the setup process needs to be verified.

Verify domain configuration
  To verify that the created and configured domain is correct, please run a simple Junit test program. The included source code example contains a sample application and an Ant file to run Junit tests. Copy sample-build.properties to build.properties and edit the entries in build.properties to suit your environment. build.properties only needs to be created once. Once you have created and configured a domain, I will ask you to call the following command:

ant - v code fact.

  If the test program runs successfully, the application deployment is correct and the resource configuration is correct. If there is any exception and the test fails, the application or resource is not configured or deployed incorrectly. Carefully check and analyze the stack trace, and debug the problem.

  Once the test program runs successfully, close the WebLogic Server instance (for example, domain directory/stopWebLogic.bat or sh). Always use scripts instead of drastic means (such as ctrl+c) to shut down WebLogic Server.

Manual Express (Express) configuration
  Use the steps described in the domain creation section to create a new domain with SEMDomain-Manual-Express as the configuration name. Start the WebLogic Server instance and configure the database using the steps described in the database configuration section.
  In many different projects, I have successfully completed many manual configurations using the WebLogic Server Console.

Change logging level

  1. Make sure WebLogic Server is running
  2. Start the WebLogic Server Console (for example: http://localhost:7001/console)
  3. Log in to the console
  4. Choose Servers / cgServer
  5. Select the Logging tab
  6. Check the Debug to Stdout checkbox
  7. From the drop-down list, select Stdout Severity Threshold as Info
  8. Choose Apply

Configure connection pool

  1. Make sure WebLogic Server is running
  2. Start the WebLogic Server console (for example: http://localhost:7001/console)
  3. Log in to the console
  4. Select Services/JDBC/Connection Pools
  5. 选择Configure a new JDBC Connection Pool
  6. Select PointBase from the Database Type drop-down list
  7. From Database Driver, select PointBase's Driver (Type 4) Versions: 4.X
  8. Choose Continue
  9. Specify Name as semJDBCConnectionPool
  10. Specify the Database Name as workshop
  11. Specify Host Name as localhost
  12. Specify Port as 9093
  13. Specify Database User Name as sem
  14. Specify Password as sem
  15. Specify Confirm Password as sem
  16. Choose Continue
  17. Test driver configuration
  18. Create and deploy

Configure data source

  1. Make sure WebLogic Server is running
  2. Start the WebLogic Server console (for example: http://localhost:7001/console)
  3. Log in to the console
  4. Choose Services / JDBC / Data Sources
  5. 选择Configure a new JDBC data Source
  6. Specify Name as jdbc/semJDBCDataSource
  7. Specify JNDI Name as jdbc/semJDBCDataSource
  8. 选择Emulate Two-Phase Commit for non-XA Driver
  9. Choose Continue
  10. Specify the Pool Name as semJDBCConnectionPool
  11. Choose Continue
  12. Click Create to determine the target of the data source

Configure JMS connection factory

  1. Make sure WebLogic Server is running
  2. Start the WebLogic Server console (for example: http://localhost:7001/console)
  3. Log in to the console
  4. Select Services / JMS / Connection Factories
  5. Choose Configure a new JMS Connection Factory
  6. Specify Name as semJMSConnectionFactory
  7. Specify JNDI Name as jms/semJMSConnectionFactory
  8. Choose Create
  9. As a target and deploy on cgServer
  10. Select the Configuration tab
  11. Select the Transactions sub-tab
  12. 选择XA Connection Factory Enabled
  13. Choose Apply

Configure JMS JDBC library

  1. Make sure WebLogic Server is running
  2. Start the WebLogic Server console (for example: http://localhost:7001/console)
  3. Log in to the console
  4. Select Services / JMS / Stores in the left navigation pane
  5. Choose Configure a new JMS JDBC Store
  6. Specify Name as semJMSJDBCStore
  7. Select Connection Pool as semJDBCConnectionPool
  8. Choose Create

Configure JMS server

  1. Make sure WebLogic Server is running
  2. Start the WebLogic Server console (for example: http://localhost:7001/console)
  3. Log in to the console
  4. In the navigation pane on the left, select Services / JMS / Stores
  5. Choose Configure a new JMS Server
  6. Specify Name as semJMSServer
  7. By selecting from the drop-down list, specify Persistence Store as semJMSJDBCStore
  8. Choose Create
  9. Set the target of semJMSServer to cgServer

Configure JMS queue

  1. Make sure WebLogic Server is running
  2. Start the WebLogic Server console (for example: http://localhost:7001/console)
  3. Log in to the console
  4. In the left navigation pane, select Services/JMS/Servers/semJMSServer /Destinations
  5. Choose Configure a new JMS Queue
  6. Specify Name as PersonQueue
  7. Specify JNDI Name as jms/PersonQueue
  8. Select create
  9. Select the Redelivery sub-tab
  10. Specify the Redelivery Limit as 3
  11. Choose Apply

  Now, you have completed the configuration of application resources. But before deploying the application, you still need to configure resources related to the workshop.

Configure resources related to the workshop

  1. Make sure WebLogic Server is running
  2. Start the WebLogic Server console (for example: http://localhost:7001/console)
  3. Log in to the console
  4. In the left navigation pane, select Services/JMS/Servers/semJMSServer/ Destinations
  5. Choose Configure a new JMS Queue
  6. Specify Name as SEMAppWeb.queue.AsyncDispatcher_error
  7. Specify JNDI Name as SEMAppWeb.queue.AsyncDispatcher_error
  8. Choose Create
  9. Select the Redelivery sub-tab
  10. Specify the Redelivery Limit as 0
  11. Choose Apply
  12. In the left navigation pane, select Services/JMS/Servers/semJMSServer/ Destinations
  13. Choose Configure a new JMS Queue
  14. Specify Name as SEMAppWeb.queue.AsyncDispatcher
  15. Specify JNDI Name as SEMAppWeb.queue.AsyncDispatcher
  16. Choose Create
  17. Select the Redelivery sub-tab
  18. Select Error Destination as SEMAppWeb.queue.AsyncDispatcher_error
  19. Choose Apply

  Now you are ready to deploy the application.

Deploy the application

  1. Make sure WebLogic Server is running
  2. Start the WebLogic Server console (for example: http://localhost:7001/console)
  3. Log in to the console
  4. In the left navigation pane, select Deployments/Applications
  5. Choose Deploy a new Application
  6. Browse to the location of the SEMApp.ear file
  7. Choose SEMApp.ear
  8. Choose Continue
  9. Choose Deploy

  Once the application is successfully deployed, restart the server. Run the test program as described in the Verify Domain Configuration section.
  There are also other manual strategies that utilize the Domain Configuration Wizard. One option is to create and configure a brand new domain by selecting the Custom option (rather than Express). When the wizard prompts you to create resources, such as JDBC Connection Pools, follow the steps to create and deploy resources. Another option is to use the Domain Configuration Wizard to configure an already created domain. In Step 1 of the Domain Configuration Wizard, select Extend an existing WebLogic configuration. The process of creating the above domain is left as an exercise. But using these strategies may not be able to complete all the configurations, such as the configuration of the Redelivery attribute of the destination.
  In order to successfully use the manual strategy, the project needs to save a configuration guide. This configuration guide contains step-by-step instructions as described above. However, the manual configuration process is tedious and time-consuming. Setting up another domain requires additional time and effort, and more importantly, the process is also prone to errors. Minor configuration errors, such as misspelled JNDI names, can lead to a lot of troubleshooting and debugging.
  Automated domain creation and configuration options should be preferred. Java is a powerful language, and you can directly manipulate MBeans with Java. But this method is a low-level method. There are other alternative methods, such as templates and scripts. In manual templates, config.xml is templated with tags. Substitute the actual value for the tag later. The manual template method requires a very in-depth and thorough understanding of the config.xml file. In some projects, I have used manual templates. Bedrock is an Ant-based tool that supports such templates. However, Bedrock does not appear to be effectively maintained. Another important template technique is to use domain templates. This technique does not require in-depth knowledge of config.xml. The creation of templates is well supported by configuring the template building tool. The next section discusses how to use the configuration template building tool to automatically configure domains through templates.

Domain template
  When you manually create a domain, you use a workshop template. But what is a template? The template is a Java ARchive (JAR) file that contains configuration information, and is a relevant fragment of the config.xml file. There are two types of templates: full templates and extended templates. Using the full template, a new domain can be created. The workshop template used above is an example of a complete template. Using an extended template, you can extend a domain. The DefaultWebApp template used later is an example of an extended template.
  How to create a template? There is a special tool called configuration template generator that can help with this, whether it is a full template or an extended template. There are two ways to create a template. The first method is to extend an extended template. The second method is to create a template based on an existing domain. In the next section, you will create a complete template based on an existing domain.

Complete template     In
  this section, I will give an example of how to create a complete template based on an existing, pre-configured and working domain. Follow these steps to create a complete template:

  1. Start the configuration template builder (on Windows, select Start> All Programs> BEA WebLogic Platform> Other Development Tools> Configuration Template Builder)
  2. Select Create a Configuration Template, and click Next
  3. Select Basic WebLogic Workshop Domain, and click Next
  4. Select an existing, pre-configured and working SEM domain (for example, SEMDomain-Manual-Express), and click Next
  5. Specify Name as SEMTemplate- Complete
  6. Specify Author (for example, Bart)
  7. Specify Category (for example, SEM)
  8. Specify Descrīption and click Next
  9. Click Next in the subsequent dialog box and take the default value
  10. In Create Template, specify a name for the template (for example, SEMTemplate- Complete), observe and remember the location of the template JAR file %BEA_HOME%/user_templates/, and click Create
  11. Click Done

  Now, create a new domain based on the complete template. Follow these steps to create a complete domain:

Domain creation based on full template

  1. Start the domain configuration wizard (on Windows, select Start> All Programs> BEA WebLogic Platform> Configuration Wizard)
  2. Select Create a new WebLogic Configuration, and click Next
  3. Browse to the location of the full template (%BEA_HOME%/user_templates) instead of selecting one of the default templates
  4. Select SEMTemplate-Complete, and click Next
  5. Click Next in the subsequent dialog box and take the default value
  6. Specify the Configuration Name as something meaningful (for example, SEMDomain-Complete), and click Create
  7. Click Done

  However, starting the WebLogic Server instance in this domain failed. The encrypted security credentials conflict. Manually modify the config.xml file as follows:

modify config.xml

  1. Modify the value of the Credential attribute of the SecurityConfiguration element to ""
  2. Modify the value of the Credential attribute of the EmbeddedLDAP element to ""
  3. Modify the value of the cgPool Password attribute to "weblogic"
  4. Change the value of the semJDBCConnectionPool Password property to "sem"

  Follow the steps described in the Verify Domain Configuration section to verify that the domain is working properly.
  Another important template strategy is to create an extended template, such as an extended template that extends the DefaultWebApp template and configures all necessary resources. Create the extension template, create a domain, and use the extension template to extend the domain as an exercise.

Conclusion
  Manually editing the config.xml file for domain configuration is an error-prone and dangerous method. The other extreme method-configuring domains by writing Java code is tedious. Common alternative methods include using WebLogic Console, Domain Configuration Wizard to configure the domain. However, these two alternative methods are manual, may be repetitive, and time-consuming. When exploring automation solutions, I evaluated the template approach. Please pay attention to my next article, which will evaluate scripting strategies. I hope this article will help you be prepared when choosing tools and techniques to automate domain configuration.

 

Guess you like

Origin blog.csdn.net/jifeijixufly/article/details/5219224