JBOSS AS7 data source configuration one-stop + jersey key points of application release

Source: Internet
Author: User

MySQL section:


1. Download MySQL 5.5.x or later


Download the mysql-5.5.x-linux2.6-x86_64.tar.tar.gz to the/opt directory


2. decompress and configure (x is the actual version)
[Html]
1), tar zxvf mysql-5.5.x-linux2.6-x86_64.tar.tar.gz
2) cd/opt
(3), mv mysql-5.5.x-linux2.6-x86_64 mysql
4), cd/opt/mysql
5) create a MySQL user and group.
A. groupadd mysql
B. useradd-r-g mysql

1), tar zxvf mysql-5.5.x-linux2.6-x86_64.tar.tar.gz
2) cd/opt
(3), mv mysql-5.5.x-linux2.6-x86_64 mysql
4), cd/opt/mysql
5) create a MySQL user and group.
A. groupadd mysql
B. useradd-r-g mysql

6) Configure mysql
[Html]
A. chown-R mysql.
B. chgrp-R mysql.
C,./scripts/mysql_install_db -- user = mysql
D. cd support-files/
E. cp my-medium.cnf my. cnf
F, cp my. cnf/etc/
G. cp mysql. server mysqld
H. Modify the mysqld configuration and configure the corresponding file path for basedir and datadir in the file.
Command vim mysqld
Example:
Basedir =/opt/mysql
Datadir =/opt/mysql/data
I. Copy mysqld to the default startup directory/etc/init. d; cp mysqld/etc/init. d/
J. cd/etc/init. d
K. chkconfig mysqld on
L, cd/opt/mysql
M, chown-R root.
N, chown-R mysql data

A. chown-R mysql.
B. chgrp-R mysql.
C,./scripts/mysql_install_db -- user = mysql
D. cd support-files/
E. cp my-medium.cnf my. cnf
F, cp my. cnf/etc/
G. cp mysql. server mysqld
H. Modify the mysqld configuration and configure the corresponding file path for basedir and datadir in the file.
Command vim mysqld
Example:
Basedir =/opt/mysql
Datadir =/opt/mysql/data
I. Copy mysqld to the default startup directory/etc/init. d; cp mysqld/etc/init. d/
J. cd/etc/init. d
K. chkconfig mysqld on
L, cd/opt/mysql
M, chown-R root.
N, chown-R mysql data

3. Start MySQL.


[Html]
Service mysqld start

Service mysqld start


4. Configure MySQL
1) change the password
[Html]
A. cd/opt/mysql/bin
B../mysqladmin-u root-p password New password

A. cd/opt/mysql/bin
B../mysqladmin-u root-p password New password

2) Configure Access Permissions
[Html]
A. cd/opt/mysql/bin
B../mysql-u root-p
C. grant all privileges on *. * TO 'root' @ '%' identified by 'Password' with grant option;
D. Restart MySQL. Service mysqld restart

A. cd/opt/mysql/bin
B../mysql-u root-p
C. grant all privileges on *. * TO 'root' @ '%' identified by 'Password' with grant option;
D. Restart MySQL. Service mysqld restart

 

5. Use a remote client to add a global database. Database Name: uec_cloud encoding: UTF-8 (utf-8-bin)


JBOSS (standalone mode) part:


1. Create a Driver Module

Target: mysql driver module com. mysql
1. Create a module directory structure
Create a folder in the $ JBOSS_HOME/modules directory, and create the following directory structure: $ JBOSS_HOME/modules/com/mysql/main
[Html]
1), cd $ JBOSS_HOME/modules/com
2) mkdir-p mysql/main

1), cd $ JBOSS_HOME/modules/com
2) mkdir-p mysql/main

2. Copy the jar file to the Module Directory.

Copy mysql-connector-java-5.1.21-bin.jar to $ JBOSS_HOME/modules/com/mysql/main

 


[Html]
Scp mysql-connector-java-5.1.21-bin.jar root @ ip:/opt/jboss-as-7.1.1.Final/modules/com/mysql/main

Scp mysql-connector-java-5.1.21-bin.jar root @ ip:/opt/jboss-as-7.1.1.Final/modules/com/mysql/main

 

3. Configure module. xml
Create a module. xml file in the $ JBOSS_HOME/modules/com/mysql/main directory. The content is as follows:


[Html]
Vim module. xml

Vim module. xml

[Html]
<? Xml version = "1.0" encoding = "UTF-8"?>
<Module xmlns = "urn: jboss: module: 1.0" name = "com. mysql">
<Resources>
<Resource-root path = "mysql-connector-java-5.1.21-bin.jar"/>
</Resources>
<Dependencies>
<Module name = "javax. api"/>
</Dependencies>
</Module>

<? Xml version = "1.0" encoding = "UTF-8"?>
<Module xmlns = "urn: jboss: module: 1.0" name = "com. mysql">
<Resources>
<Resource-root path = "mysql-connector-java-5.1.21-bin.jar"/>
</Resources>
<Dependencies>
<Module name = "javax. api"/>
</Dependencies>
</Module>

2. register the data source driver
Modify the $ JBOSS_HOME/standalone/configuration/standalone. xml file, find the drivers node under the CES node, and add it under the drivers node:


[Html]
<Driver name = "mysql" module = "com. mysql">
<Driver-class> com. mysql. jdbc. Driver </driver-class>
</Driver>

<Driver name = "mysql" module = "com. mysql">
<Driver-class> com. mysql. jdbc. Driver </driver-class>
</Driver>

3. Register a data source
Modify the $ JBOSS_HOME/standalone/configuration/standalone. xml file, find the CES node, and add the datasource node:

[Html]
<Datasource jta = "false" jndi-name = "java: jboss/datasources/UEC_DataSourceDS" pool-name = "UEC_DataSourceDS" enabled = "true" use-ccm = "false">
<Connection-url> jdbc: mysql: // localhost: 3306/uec_cloud? UseUnicode = true & characterEncoding = UTF-8 & zeroDateTimeBehavior = convertToNull </connection-url>
<Driver-class> com. mysql. jdbc. Driver </driver-class>
<Driver> mysql </driver>
<Transaction-isolation> TRANSACTION_READ_COMMITTED </transaction-isolation>
<Pool>
<Min-pool-size> 10 </min-pool-size>
<Max-pool-size> 100 </max-pool-size>
<Prefill> true </prefill>
<Use-strict-min> false </use-strict-min>
</Pool>
<Security>
<User-name> root </user-name>
<Password> eric </password>
</Security>
<Validation>
<Validate-on-match> false </validate-on-match>
<Background-validation> false </background-validation>
</Validation>
<Statement>
<Share-prepared-statements> false </share-prepared-statements>
</Statement>
</Datasource>

<Datasource jta = "false" jndi-name = "java: jboss/datasources/UEC_DataSourceDS" pool-name = "UEC_DataSourceDS" enabled = "true" use-ccm = "false">
<Connection-url> jdbc: mysql: // localhost: 3306/uec_cloud? UseUnicode = true & characterEncoding = UTF-8 & zeroDateTimeBehavior = convertToNull </connection-url>
<Driver-class> com. mysql. jdbc. Driver </driver-class>
<Driver> mysql </driver>
<Transaction-isolation> TRANSACTION_READ_COMMITTED </transaction-isolation>
<Pool>
<Min-pool-size> 10 </min-pool-size>
<Max-pool-size> 100 </max-pool-size>
<Prefill> true </prefill>
<Use-strict-min> false </use-strict-min>
</Pool>
<Security>
<User-name> root </user-name>
<Password> eric </password>
</Security>
<Validation>
<Validate-on-match> false </validate-on-match>
<Background-validation> false </background-validation>
</Validation>
<Statement>
<Share-prepared-statements> false </share-prepared-statements>
</Statement>
</Datasource>

Program release core parameter changes:


1. JBOSS data source Configuration:
Modify the applicationContext-common.xml profile to mask the original dataSource and enable the JNDI data source.

Example:

 


[Html]
<Bean id = "dataSource" class = "org. springframework. jndi. JndiObjectFactoryBean" p: jndiName = "java: jboss/datasources/UEC_DataSourceDS"/>

<Bean id = "dataSource" class = "org. springframework. jndi. JndiObjectFactoryBean" p: jndiName = "java: jboss/datasources/UEC_DataSourceDS"/>

2. web. xml configuration:


Add the following parameters:
[Html]
<! -- JBOSS AS7 Rest Config -->
<Context-param>
<Param-name> resteasy. scan </param-name>
<Param-value> false </param-value>
</Context-param>
<Context-param>
<Param-name> resteasy. scan. resources </param-name>
<Param-value> false </param-value>
</Context-param>
<Context-param>
<Param-name> resteasy. scan. providers </param-name>
<Param-value> false </param-value>
</Context-param>

<! -- JBOSS AS7 Rest Config -->
<Context-param>
<Param-name> resteasy. scan </param-name>
<Param-value> false </param-value>
</Context-param>
<Context-param>
<Param-name> resteasy. scan. resources </param-name>
<Param-value> false </param-value>
</Context-param>
<Context-param>
<Param-name> resteasy. scan. providers </param-name>
<Param-value> false </param-value>
</Context-param>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.