Rapid deployment of Java applications in CentOS 6

Source: Internet
Author: User
Tags install mongodb

Rapid deployment of Java applications in CentOS 6

At present, the vendors that provide IDC services are really varied, but there are only a few correction services in place. We recommend that you use Windows for time consideration. At least it will be much easier to install the development environment and it will not take too long. In general, the Java development environment is mainly composed of three parts: middleware, JDK, and database. Next I will share my deployment experiences.

1. Install jdk of Linux

The installation of Linux is not complicated. The annoying thing is that the speed of downloading jdk is a tortoise-like connection, as well as a mess of troubles such as logon. As for jdk, we strongly recommend downloading rpm or binfiles, these two files are very simple to install. if the system does not support rpm files, select binfile, and a simple sh command will be done.

To eliminate interference, we recommend that you uninstall the built-in openjdk first. If it does not exist, skip this step.


Check rpm-qa | grep java first

The following information is displayed:

Java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5

Uninstall:

Rpm-e -- nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Rpm-e -- nodeps java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5

There are other commands

Rpm-qa | grep gcj

Rpm-qa | grep jdk

If openjdk source cannot be found, you can uninstall it like this.

Yum-y remove java java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Yum-y remove java java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5

1. Install jdk

Installing jdk is really easy. First, go to the directory where the downloaded jdk is located and use the command to authorize the file.

Chmod + x your jdk file name

Enter the./jdk file name. bin, and install jdk in one minute.

2. Copy the directory to/usr/local (optional)

After installation, you can copy the installation directory to/usr/local for ease of management. The command is as follows:

Cp original installation directory/usr/local/jdk6

 


3. Configure environment variables (critical)

Run the vi command to edit the profile. The command is vim/etc/profile;

Append the following content at the end of the file, and modify the directory according to the actual situation.

Export JAVA_HOME =/usr/local/jdk6
Export JAVA_BIN =/usr/local/6/bin
Export PATH = $ PATH: $ JAVA_HOME/bin
Export CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
Export JAVA_HOME JAVA_BIN PATH CLASSPATH


4. Restart linux

Reboot

2. install tomcat

This step is to upload tomcat of the linux version to the server. We recommend that you delete the original built-in version because the native version is too difficult to use and put the war package under webapps, we recommend that you use apache-tomcat-6.0.29, which is too easy to use.

3. Install mongodb or mysql

1. Solve the Problems Related to the wonderful mysql

(1) the dialect is not configured when an exception occurs.

This situation is common in jpa development projects, and the solution is simple. You only need to configure the dialect.

<Bean id = "entityManagerFactory"
Class = "org. springframework. orm. jpa. LocalContainerEntityManagerFactoryBean">
<Property name = "dataSource" ref = "dataSource"/>
<Property name = "jpaVendorAdapter">
<Bean class = "org. springframework. orm. jpa. vendor. HibernateJpaVendorAdapter">
<Property name = "showSql" value = "false"/>
</Bean>
</Property>
<Property name = "jpaProperties">
<Props>
<Prop key = "hibernate. hbm2ddl. auto"> update </prop>
<Prop key = "hibernate. dialect"> org. hibernate. dialect. MySQLInnoDBDialect </prop>
</Props>
</Property>
</Bean>

(2) database connection failure

This problem is well ruled out, basically because the url is incorrect, the user name or password is incorrect, and the database driver jar package is missing.

(3) The database table name is abnormal.

This is really amazing. In general, the probability of such a situation is relatively small, so it is difficult to find a solution on the Internet. I also found it for a long time, the solution is to add a configuration under the mysqld node.

Lower_case_table_names = 1

This often occurs when projects on windows are ported to linux. Normally, tables automatically generated after hibernat or jpa are used with the same default name as the class name of the object class, if the table names of the database are all in lower case, as long as the project starts, the database will generate a bunch of new tables according to the jpa or hibernate specifications, resulting in program errors.

Common mysql configuration files:

[Mysqld]
Datadir =/var/lib/mysql
Socket =/var/lib/mysql. sock
User = mysql
Default-character-set = utf8
Lower_case_table_names = 1
[Client]
Password = gtyiaJB8R
Port = 3306
Socket =/var/lib/mysql. sock
Default-character-set = utf8
# Disabling symbolic-links is recommended to prevent assorted security risks
# Symbolic-links = 0
[Mysqld_safe]
Log-error =/var/log/mysqld. log
Pid-file =/var/run/mysqld. pid
Default-character-set = utf8

(4) mongodb start/stop mode

Mongodb is different from mysql in that it is mainly used for database startup. It is not suitable for mongodb to be started on the frontend. It can only be started using background processes.

./Mongod -- dbpath = directory of your mongdb data -- fork -- logpath =/data/log/mongodb. log

If you want to stop using mongodb, we recommend that you:

Use admin
Db. shutdownServer ();

Are these questions amazing? I have learned a lot by solving these problems.

Install JDK 1.8.0 _ 25 on Ubuntu 14.04 and configure Environment Variables

Install Oracle JDK 14.04 on Ubuntu 1.8 LTS

CentOS6.3 install JDK and environment Configuration

Install JDK 8 on Ubuntu 14.04

Install JDK graph analysis in Ubuntu

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.