Centos6.5 jdk+tomcat+mysql Environment Installation graphics and text tutorial _java

Source: Internet
Author: User
Tags mysql client mysql version tomcat server dmesg

System Environment: Centos6.5 64-bit

I. Installing the Java environment this is jdk1.7.60.

Create a Java directory in the/usr/local directory to download jdk-7u60-linux-x64.tar.gz to Oracle's official website or mirror site and put it into/usr/local/java.

Cd/usr/local/java, perform decompression: Tar zxvf jdk-7u60-linux-x64.tar.gz.

Configure the Java_home,jar_home environment variables after the decompression is complete. Open/etc/profile file, command: Vi/etc/profile, add at the end

Export java_home=/usr/local/java/jdk1.7.0_60
Export JRE_HOME=/USR/LOCAL/JAVA/JDK1.7.0_60/JRE
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/lib: $CLASSPATH
Export path= $JAVA _home/bin: $PATH

Press ESC, and then enter: Wq Save the exit document and enter Source/etc/profile to take effect immediately (this method is set to work for all users once)

See if the installation succeeded Java-version.

[Note: Modify the ~/.BASHRC file (this method is modified to be valid only for the current user and is valid for all shells of that user)
Open the ~/.BASHRC file with the VIM editor
Add the JDK environment variable definition to the tail of the file. This method can be attempted when the above method does not work

2. Install Tomcat, this is apache-tomcat-8.0.33.tar.gz.
Tomcat (binary version not source version) to/usr/local directory, tar zxvf apache-tomcat-8.0.33.tar.gz, get uncompressed apache-tomcat-8.0.33
Directory, modify directory name to Tomcat.
Configurable memory size, cd/usr/local/tomcat/bin/, vi catalina.sh, added under 85 lines:
Java_opts= "-server-xms800m-xmx800m-xx:permsize=64m-xx:maxnewsize=256m
-xx:maxpermsize=128m-djava.awt.headless=true "
Press ESC and then: Wq save exit.
Start Tomcat server:
#cd/usr/local/tomcat/bin
#./startup.sh

Two. Install MySQL
Uninstall the original MySQL

Because the MySQL database is very popular on Linux, so the current download of the mainstream Linux system version is basically integrated with the MySQL database in it, we can use the following command to see if our operating system has been installed MySQL database

Copy Code code as follows:
[Root@xiaoluo ~]# Rpm-qa | grep mysql//This command will see if the MySQL database has been installed on the operating system

If so, we can uninstall it by RPM-E command or rpm-e--nodeps command.

Copy Code code as follows:
[Root@xiaoluo ~]# rpm-e mysql//normal Delete mode
[Root@xiaoluo ~]# rpm-e--nodeps mysql//brute-force deletion mode, use this command to strongly delete if you are prompted for additional files if you delete it with the command above.

After the deletion we can pass Rpm-qa | grep mysql command to see if MySQL has been uninstalled successfully!!

Three. mysql installation via Yum

I was yum to do MySQL database installation, first we can enter the Yum list | grep mysql command to view the downloadable version of the MySQL database provided on Yum:

[Root@xiaoluo ~]# Yum List | grep MySQL
you can get the downloadable version information for the MySQL database on the Yum server:

We can then install the MySQL mysql-server mysql-devel by entering the Yum install-y mysql-server mysql mysql-devel command (note: Install MySQL When we are not installed MySQL client is equivalent to install the MySQL database, we also need to install the Mysql-server server to do it

[Root@xiaoluo ~]# yum install-y mysql-server MySQL Mysql-deve

After waiting for some time, Yum will help us choose the software needed to install the MySQL database as well as some other ancillary software.

We found that the Yum way to install the MySQL database eliminates a lot of unnecessary trouble, when the results of the following, on behalf of the MySQL database installation was successful

At this point we can view the version of the Mysql-server just installed by using the following command

[Root@xiaoluo ~]# Rpm-qi Mysql-server

We installed the Mysql-server is not the latest version, if you want to try the latest version, then go to the MySQL website to download the RPM package installed on the line, so far our MySQL database has been installed completed.

Four. Initialization of MySQL database and related configuration

After we install the MySQL database, we will find that there will be a mysqld service, this is our database service, we can enter the service mysqld Start command to start our MySQL service.

Note: If we are starting the MySQL service for the first time, the MySQL server will first initialize the configuration, such as:

[Root@xiaoluo ~]# Service mysqld Start initializes the MySQL database: warning:the host ' Xiaoluo ' could ' not being looked up and resolveip. This is probably means that your libc libraries are to% compatible with this binary MySQL version.
The MySQL daemon, mysqld, should work normally with the exception, this host name resolving would not work.
This means the should use IP addresses instead the hostnames when specifying MySQL privileges!
Installing MySQL system tables ...
OK Filling Help Tables ... OK to start mysqld at ' Boot time ' and ' have to copy support-files/mysql.server ' to ' right ' for your system, please RE
Member to SET A PASSWORD for the MySQL root USER! To does so, start the server, then issue the following commands:/usr/bin/mysqladmin-u root password ' new-password '/usr/b In/mysqladmin-u root-h xiaoluo password ' new-password ' Alternatively you can run:/usr/bin/mysql_secure_installation w Hich would also give you the option of removing the test databases and anonymous user created By default.

This is strongly recommended for production servers.

The manual for more instructions. You can start the MySQL daemon with:cd/usr; /usr/bin/mysqld_safe & can test the MySQL daemon with mysql-test-run.pl cd/usr/mysql-test;

               Perl mysql-test-run.pl Please the problems with The/usr/bin/mysqlbug script!

 [OK] starting mysqld: [OK]

At this time we will see the first time to start the MySQL server will prompt a lot of information, the purpose is to initialize the MySQL database operation, when we restart the MySQL service, will not prompt so much information, such as:

[Root@xiaoluo ~]# service mysqld Restart
stop mysqld:            [OK]
starting mysqld:           [OK]
 

When we use MySQL database, we have to start mysqld service first, we can through Chkconfig--list | grep mysqld command to see if the MySQL service is powered up automatically, such as:

[Root@xiaoluo ~]# chkconfig--list | grep mysqld
mysqld    0: Off 1: Off 2: Off 3: Off 4: off 5: off 6: Off

We found that the MYSQLD service did not start up automatically, and we can, of course, set it up with the Chkconfig mysqld on command, so that we don't have to manually start it every time.

[Root@xiaoluo ~]# chkconfig mysqld on
[Root@xiaoluo ~]# chkconfig--list | grep mysql
mysqld    0: Off 1: off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

MySQL database after installation will only have a root administrator account, but at this time the root account has not set a password for it, the first time the MySQL service, will do some initialization of the database, in the output of a large number of information, we saw that a line of information:

/usr/bin/mysqladmin-u root password ' new-password '/Set password for root account

So we can use this command to set our root account password (note: This root account is the MySQL root account, non-Linux root account)

[Root@xiaoluo ~]# mysqladmin-u root password ' root ' by this command to set the root password to root

At this point we can login to our MySQL database via the mysql-u root-p command.

Five. The main configuration file of MySQL database

1./etc/my.cnf This is the MySQL main configuration file

We can look at some information about this file

[Root@xiaoluo etc]# ls my.cnf 
my.cnf

[Root@xiaoluo etc]# cat my.cnf 
[mysqld]
Datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# 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/mysqld.pid

2./var/lib/mysql MySQL database file storage location

The database files for our MySQL database are usually stored in the/ver/lib/mysql directory.

[Root@xiaoluo ~]# cd/var/lib/mysql/
[Root@xiaoluo mysql]# ls-l
total dosage 20488-rw-rw
----. 1 mysql mysql 10485760 April 6 22:01 ibdata1
-rw-rw----. 1 mysql mysql 5242880 April 6 22:01 ib_logfile0
-rw-rw----. 1 mysql mysql 5242880 April  6 21:59 ib_logfile1
drwx------. 2 mysql mysql  4096 April 6 21:59 MySQL//These two are the default two database file srwxrwxrwx when MySQL database is installed
. 1 MySQL mysql  0 April 6 22:01 mysql.sock
drwx------. 2 mysql mysql  4096 April 6 21:59 Test//These two are MySQL database installation defaults of two database files

We can create a database of our own to verify where the database files are stored

Create a database of our own:
mysql> create db Xiaoluo;
Query OK, 1 row Affected (0.00 sec)

[Root@xiaoluo mysql]# ls-l
total dosage 20492
-rw-rw----. 1 mysql mysql 10485760 4 Month 6 22:01 ibdata1
-rw-rw----. 1 mysql mysql 5242880 April 6 22:01 ib_logfile0
-rw-rw----. 1 mysql mysql 5242880 April 6  21:59 ib_logfile1
drwx------. 2 mysql mysql  4096 April 6 21:59 mysql
srwxrwxrwx. 1 mysql mysql  0 April 6 22:01 Mysql.sock
drwx------. 2 mysql mysql  4096 April 6 21:59 test
drwx------. 2 mysql mysql  4096 April 6 22:15 x Iaoluo//This is the Xiaoluo database we just created ourselves
[Root@xiaoluo mysql]# cd xiaoluo/
[root@xiaoluo xiaoluo]# ls
db.opt

3./var/log MySQL database log output storage location

Some of our MySQL database log output is located in the/var/log directory

[Root@xiaoluo xiaoluo]# cd 
[Root@xiaoluo ~]# cd/var/log
[root@xiaoluo log]# ls
Amanda    cron   maillog-20130331 spice-vdagent.log
anaconda.ifcfg.log cron-20130331 mcelog    spooler   Cups   messages   spooler-20130331
anaconda.program.log dirsrv
messages-20130331 Anaconda.storage.log dmesg   mysqld.log   tallylog
anaconda.syslog  dmesg.old   tomcat6
anaconda.xlog   dracut.log  piranha   wpa_supplicant.log
anaconda.yum.log  GDM   pm-powersave.log wtmp
audit     httpd   PPP    xorg.0.log
boot.log    Ibacm.log  prelink   xorg.0.log.old
btmp     lastlog  sa     xorg.1.log
btmp-20130401   libvirt  Samba    xorg.2.log
cluster    Luci   secure    xorg.9.log
Consolekit   maillog  secure-20130331 yum.log

Where mysqld.log This file is that we store our MySQL database with the operation of some of the log information, by looking at the log file, we can get a lot of information

Because our MySQL database can be accessed through the network, not a stand-alone version of the database, which uses the protocol is the TCP/IP protocol, we all know that the MySQL database binding port number is 3306, so we can through the NETSTAT-ANP command to view, is the Linux system listening to the 3306 port number:

The result, as shown above, is that the 3306-port number that the Linux system listens to is our MySQL database!

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.