Java EE Environment Construction Guide under CentOS server (Remote Desktop +jdk+tomcat+mysql)

Source: Internet
Author: User
Tags mysql commands centos server iptables

--------------------------------------------------------------------------------
1 System settings:

1.1 Remote Desktop settings: Through window settings
System--preferences--Remote Desktop
TICK: Allow other users to control your desktop
Cancellation: You must confirm each access for this machine
Set access password

1.2 Setting up a firewall
System--management--firewall--options
Disable the firewall to
Command mode: Shutdown of the firewall starts
/etc/init.d/iptables status
/etc/init.d/iptables stop
To permanently shut down the firewall:
Chkconfig--level iptables off
Service Iptables Stop
Regardless of the firewall, add 8080 ports to the firewall configuration separately, do the following:
[Email protected] ~]# VI +/etc/sysconfig/iptables
#增加以下代码
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 8080-j ACCEPT
Restarting the firewall
[Email protected] ~]# service iptables restart

--------------------------------------------------------------------------------

2 Installing the JDK:

jdk-7u45-linux-i586.rpm
Switch root user
[[Email protected] ~] #su root
Go to the downloaded RPM directory and execute the following command
[[Email protected] ~] #rpm-IVH jdk-7u45-linux-i586.rpm
Editing system Environment variables
[Email protected] ~]# $vi/etc/profile
Enter o and add the following at the end: Wq (Save exit), q! (do not save exit)
Java_home=/usr/java/jdk1.7.0_45
Jre_home=/usr/java/jdk1.7.0_45/jre
Path= $PATH: $JAVA _home/bin: $JRE _home/bin
Classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/lib
[[Email protected] ~] #export java_home jre_home PATH CLASSPATH
Make environment variables effective immediately
[Email protected] ~]# $source/etc/profile
Test if the installation is successful, enter Java,java-version,javac in turn, and see the output information, such as
[[Email protected] ~] #java
[Email protected] tools]# java-version

--------------------------------------------------------------------------------

3 Installing Apache-tomcat

Apache-tomcat-7.0.54.tar.gz
Go to the downloaded Apache-tomcat directory and execute the command below
[[email protected] ~]# tar-zxv-f apache-tomcat-7.0.54.tar.gz//Decompression Pack
[[email protected] ~]# RM-RF apache-tomcat-7.0.54.tar.gz//Delete compressed package
Apache-tomcat directory to/usr/local/, execute the following command
[Email protected] ~]# MV apache-tomcat-7.0.54/usr/local/apache-tomcat-7.0.54
(If unable to move, the new directory can also: Mkdir-p/usr/local/apache-tomcat-7.0.54)

Add Environment variables
Catalina_base:/usr/local/apache-tomcat-7.0.54
Catalina_home:/usr/local/apache-tomcat-7.0.54
Catalina_tmpdir:/usr/local/apache-tomcat-7.0.54/temp
Jre_home:/usr/java/jdk1_7_45/jre
classpath:/usr/local/apache-tomcat-7.0.54/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.54/bin/ Tomcat-juli.jar

Start Tomcat
[Email protected] ~]#/usr/local/apache-tomcat-7.0.54/bin/startup.sh
Viewing the boot log
[Email protected] ~]#/usr/local/apache-tomcat-7.0.54/logs/catalina.out

Check Tomcat installation Run
See if Tomcat is working properly with the following address:
http://127.0.0.1:8080/
See the Tomcat system interface to show that the installation was successful!
Stop Tomcat
[Email protected] ~]#/usr/local/apache-tomcat-7.0.54/bin/shutdown.sh

Set on self-boot:
[[Email protected] ~] #vi/etc/rc.d/rc.local
Export java_home=/usr/java/jdk1.7.0_45
Export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Export path= $PATH: $JAVA _home/bin
Export catalina_home=/usr/local/apache-tomcat-7.0.54
#tomcat自启动
/usr/local/apache-tomcat-7.0.54/bin/startup.sh


--------------------------------------------------------------------------------
4 Installing MySQL

Mysql-5.6.20-1.el6.x86_64.rpm-bundle.tar
See if Mysql:rpm-qa|grep MySQL is installed
View system current MySQL process
[email protected] ~]ps aux |grep mysq*
If you have previously installed MySQL other version or reinstall, remove all MySQL directory residue, execute the following command
RPM-E--nodeps mysql-server-5.6.17-1.el6.i686
Rm-rf/var/lib/mysql
Rm-rf/usr/lib/mysql
Rm-rf/home/undoner/mysqldata (Mysqldata can also customize other folders for users)
Rm-rf/etc/my.cnf
Rm-rf/usr/my.cnf
Rm-rf/root/.mysql_secret

The following are three ways to install:
A default RPM installation (using default configuration)
B Custom RPM installation (custom database path, MY.CNF configuration, log path, etc.)
C Compile Package Custom installation using source code (not included)
D use CentOS built-in Yum tool for automatic installation (lower version)

--------------------------------------------------------
A default RPM installation (using default configuration)
Go to the downloaded MySQL directory and execute the following command
[Email protected] ~]# Cd/home/undoner/software
Unpack the Tarball
[Email protected] ~]# TAR-XVF Mysql-5.6.20-1.el6.x86_64.rpm-bundle.tar
Run RPM file, server must be installed, other optional.
[Email protected] ~]cd/home/undoner/software/
[Email protected] ~]rpm-iv mysql-server-5.6.20-1.el6.x86_64.rpm
[Email protected] ~]rpm-iv mysql-client-5.6.20-1.el6.x86_64.rpm
[Email protected] ~]rpm-iv mysql-devel-5.6.20-1.el6.x86_64.rpm
(direct installation will prompt for no default MySQL group and MySQL user)
Alternative: Add MySQL groups and users, but not.
[[email protected] ~]# Groupadd MySQL
[[email protected] ~]# useradd-g MySQL MySQL
[[email protected] ~]# passwd mysql//change user password

MySQL default installation directory description
/var/lib/mysql Database files
/usr/share/mysql commands and configuration files
/usr/bin (Mysqladmin, mysqldump and other commands)

Modify permissions for/var/lib/mysql
The directory has full permissions for any user
[Email protected] ~]chmod-r 777/var/lib/mysql
Alternative: If a MySQL user is established, change the directory owner from root to MySQL
[Email protected] ~]chown-r Mysql/var/lib/mysql

Start MySQL:
[[email protected] ~]service mysql status
Result: The display "SUCCESS" is already running
Show "FAILED" is not running
Start: [[email protected] ~]service MySQL start
Close: [[email protected] ~]service MySQL stop

MySQL service some other commands
A. See if MySQL is in the auto-start list: #/sbin/chkconfig--list
B. Add MySQL to System self-boot service group: #/sbin/chkconfig--add MySQL
C. remove MySQL from the Startup service group: #/sbin/chkconfig--del MySQL
D, stop MySQL service: # service MySQL Stop
E, script start MySQL service: #/etc/rc.d/init.d/mysqld start
F, script stop MySQL service: #/etc/rc.d/init.d/mysqld stop
The default is boot-start! Status 2-5 for Startup
[Email protected] ~]/sbin/chkconfig--list

View the current default root account password (installation generated random values)
[Email protected] ~]vim/root/.mysql_secret
Copy the current root account password and log in to MySQL
[Email protected] ~]mysql-uroot-p
Modify the current password after logging in to MySQL
mysql> SET PASSWORD = PASSWORD (' root ');
mysql> show databases;
Mysql> quit
Log in again with the new password root to see if remote connection is allowed (default deny), add remote root user access
mysql> use MySQL;
Mysql> select Host,user,password from user;
Mysql> Grant all privileges on * * to [e-mail protected] "%" identified by ' root ' with GRANT option;
Change the MySQL default character set (the default character set is the same as the operating system character set, so no setting is required)
To view the MySQL character set:
Mysql> Show variables like ' character_set_% ';
Add a MySQL profile, set the default encoding character set
[[email protected] ~]service MySQL stop
[Email protected] ~]cp/usr/share/mysql/my-default.cnf/etc/my.cnf
[Email protected] ~]vim/etc/my.cnf
[MySQL]
Default-character-set = UTF8
[Client]
port=3306
Socket=/var/lib/mysql/mysql.sock
Default-character-set=utf8
[Mysqld]
Bind-address = 0.0.0.0
User=root
port=3306
Default_storage_engine = InnoDB
Character-set-server = UTF8
Lower_case_table_names=1
Socket=/var/lib/mysql/mysql.sock
...
[[email protected] ~]service MySQL start
[Email protected] ~]mysql-uroot-p
Re-login to view MySQL default encoding
Mysql> Show variables like ' character_set_% ';
View MySQL log information
Cat/var/lib/mysql/localhost.localdomain.err


*********************************************************
Modify the/etc/init.d/mysql, the default is empty that is in this directory, do not change.
Vi/etc/init.d/mysql
Datadir=/var/lib/mysql
Basedir=/var/lib/mysql
mysql_install_db--user=root--basedir=/var/lib/mysql--datadir=/var/lib/mysql–defaults-file=/etc/my.cnf
*********************************************************

--------------------------------------------------------

B Custom RPM installation (custom database path, MY.CNF configuration, log path, etc.)

Go to the downloaded MySQL directory and execute the following command
[Email protected] ~]# Cd/home/undoner/software
[[email protected] ~]# TAR-XVF Mysql-5.6.17-1.el6.i686.rpm-bundle.tar//Decompression Pack

Run the rpm file
[Email protected] ~]cd/home/undoner/software/
[Email protected] ~]rpm-iv mysql-server-5.6.17-1.el6.i686.rpm
[Email protected] ~]rpm-iv mysql-client-5.6.17-1.el6.i686.rpm
[Email protected] ~]rpm-iv mysql-devel-5.6.17-1.el6.i686.rpm

Modify the data storage path and place the MySQL default installed database file in your home directory:
[Email protected] ~]cp-r/var/lib/mysql/home/undoner/mysqldata

Modifying the default configuration file
[Email protected] ~]vi/etc/my.cnf
/USR/SHARE/MYSQL/MY-HUGE.CNF is a template configuration file that comes with your own, modified to include the following:
[Email protected] ~]vi/etc/my.cnf
MY.CNF File Contents:
[MySQL]
# CLIENT #
Port = 3306
Socket =/home/undoner/mysqldata
Default-character-set = UTF8
[Mysqld]
# General #
Bind-address = 0.0.0.0
port=3306
#datadir =/var/lib/mysql
# DATA STORAGE #
Datadir=/home/undoner/mysqldata
Basedir=/home/undoner
#socket =/var/lib/mysql/mysql.sock
Socket=/tmp/mysql.sock
Default_storage_engine = InnoDB
Character-set-server = UTF8
User=root
# Disabling Symbolic-links is recommended to prevent assorted security risks
Symbolic-links=0
# MyISAM #
Key_buffer_size = 32M
Myisam_recover = Force,backup
# SAFETY #
Max_allowed_packet = 16M
Max_connect_errors = 1000000
Skip_name_resolve
# BINARY LOGGING #
#log_bin =/data/mysql/mysql-bin
Expire_logs_days = 14
Sync_binlog = 1
# CACHES and LIMITS #
Tmp_table_size = 32M
Max_heap_table_size = 32M
Query_cache_type = 0
Query_cache_size = 0
Max_connections = 500
Thread_cache_size = 50
Open_files_limit = 65535
Table_definition_cache = 1024
Table_open_cache = 2048
# INNODB #
Innodb_flush_method = O_direct
Innodb_log_files_in_group = 2
Innodb_log_file_size = 256M
Innodb_flush_log_at_trx_commit = 1
innodb_file_per_table = 1
Innodb_buffer_pool_size = 10G
Innodb_thread_concurrency = 12
thread_handling = Pool-of-threads
#auto_increment_increment = 2
#auto_increment_offset = 0
# LOGGING #
Log_error =/tmp/mysql-error.log
Log_queries_not_using_indexes = 1
Slow_query_log = 1
#slow_query_log_file =/tmp/mysql-slow.log
[Mysqld_safe]
Log-error=/tmp/mysql.log
Pid-file=/tmp/mysql.pid

Put the modified configuration file my.cnf Direct copy into the/etc/directory.
[Email protected] ~]cp/my.cnf/etc/my.cnf

Modify permissions for/home/undoner/mysqldata
The directory has full permissions for any user
[Email protected] ~]chmod-r 777/home/undoner/mysqldata
Modify the directory owner to be a MySQL user
[Email protected] ~]chown-r Mysql/home/undoner/mysqldata

Perform the MySQL database installation operation and specify the DataDir directory that we defined:
[Email protected] ~]mysql_install_db--datadir=/home/undoner/mysqldata

Start the database:
[Email protected] ~]mysqld
Fatal error:please read "Security" section of the manual to find out how to run mysqld as root!
If the above error occurs, please join MYSQLD in/etc/my.conf
User=root

Log in to Database
Mysql-h127.0.0.1-p3371-uroot-p
No password by default

Change Password:
sudo mysqladmin-h127.0.0.1-uroot password root
Or
will prompt for a password, the initial root password is saved in the '/root/.mysql_secret ' file
Log in to MySQL, then enter mysql>set PASSWORD = PASSWORD (' root ');

Ln-s/home/undoner/mysqldata/var/lib/
Modify/etc/init.d/mysql
Vi/etc/init.d/mysql
Datadir=/home/undoner/mysqldata
Basedir=/home/undoner

Using the command: #/etc/rc.d/init.d/mysql status
Result: The display "SUCCESS" is already running
Show "FAILED" is not running

Configure remote access and database encoding the same as the top a installation, view the error log information:
Cat/home/undoner/mysqldata/localhost.localdomain.err

----------------------------------------------------------------------------------------------------------

**************************************************************
Install Chinese Input Method
[email protected] java]# Yum Install "@Chinese support"

How many bits of your system are viewed under CentOS
[Email protected] ~]# uname-a
Linux localhost.localdomain 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT i686 i686 i386 gnu/linux
[Email protected] ~]# getconf word_bit
32
[Email protected] ~]# echo $HOSTTYPE
i686
This is my machine, if it is 64 bits, the first and third command will show: x86_64

How many bits of your JDK are viewed under CentOS
# java-version
Java Version "1.6.0_26"
Java (TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot (TM) Server VM (build 20.1-b02, Mixed mode)
If it is 64 bits, the last row shows 64-bit
#java-version
Java Version "1.6.0_26"
Java (TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot (TM) 64-bit Server VM (build 20.1-b02, Mixed mode)

---------------------------------------------------------------------------------------------------------
To install the Vncserver configuration:
To change the execution permissions:
sudo chmod u+rwx/etc/sysconfig/vncservers
Modifying a configuration file
Su Root
Vi/etc/sysconfig/vncservers
The number 1 corresponds to the time of the connection, such as 192.168.1.101:1
Vncservers= "1:undoner"
vncserverargs[1]= "-geometry 1024x768-nolisten TCP"

Java EE Environment Construction Guide under CentOS server (Remote Desktop +jdk+tomcat+mysql)

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.