This article introduces the process of setting up a server environment such as CentOS7 64 Java, Tomcat, MySQL, and Maven hot deployment.
Server: Tencent Cloud Server
The required tools (Xshell, Xftp, FileZilla and other sftp upload tools, jdk-8u101-linux-x64.tar.gz and apache-tomcat-9.0.0.M10.tar.gz) have been uploaded to Baidu Cloud [http://pan.baidu.com/s/1qYRms8G] (http://pan.baidu.com/s/1qYRms8G)
1、 tomcat official websitehttps://tomcat.apache.org/download
Use uname -r
to determine how many bits the system is
source /etc/profile
command to make it effective immediatelyjava -version
to verify that Java is successfully configured.Self-start:
Edit the file /usr/local/java/tomcat/bin/catalina.sh (modify according to your own jdk path) At the beginning of the body of the file, that is, before the official code, add the following code about 99 lines
export JAVA_HOME=/usr/local/java/jdk
export JRE_HOME=/usr/local/java/jdk/jre
first step:
vim /lib/systemd/system/tomcat.service
[ Unit]
Description=tomcat
After=network.target
[ Service]
Type=oneshot
ExecStart=/usr/local/java/tomcat/bin/startup.sh //Own tomcat directory
ExecStop=/usr/local/java/tomcat/bin/shutdown.sh
ExecReload=/bin/kill -s HUP $MAINPID
RemainAfterExit=yes
[ Install]
WantedBy=multi-user.target
(2). Setting permissions
chmod 754 tomcat.service
(3). Start and close the service, set the startup to start
# Start service
systemctl start tomcat.service
# Close service
systemctl stop tomcat.service
# boot
systemctl enable tomcat.service
The system version after yum update upgrade is
[ root@yl-web yl]# cat /etc/redhat-release
CentOS Linux release 7.1.1503(Core)
At the beginning, it was installed directly through this command:
1[ root@yl-web yl]# yum install mysql
2[ root@yl-web yl]# yum install mysql-server
3[ root@yl-web yl]# yum install mysql-devel
The installation of mysql and mysql-devel were successful, but the installation of mysql-server failed, as follows:
[ root@yl-web yl]# yum install mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.sina.cn
* extras: mirrors.sina.cn
* updates: mirrors.sina.cn
No package mysql-server available.
Error: Nothing to do
Checking the information found that the CentOS 7 version removed the MySQL database software from the default program list and replaced it with mariadb.
There are two solutions:
The MariaDB database management system is a branch of MySQL, which is mainly maintained by the open source community and is licensed under GPL. One of the reasons for the development of this branch is that after Oracle acquired MySQL, there is a potential risk of closing MySQL to the source, so the community uses branching to avoid this risk. The purpose of MariaDB is to be fully compatible with MySQL, including API and command line, so that it can easily become a substitute for MySQL.
Install mariadb, size 59 M.
[ root@yl-web yl]# yum install mariadb-server mariadb
The related commands of the mariadb database are:
systemctl start mariadb #Start MariaDB
systemctl stop mariadb #Stop MariaDB
systemctl restart mariadb #Restart MariaDB
systemctl enable mariadb #Set boot up
So start the database first
[ root@yl-web yl]# systemctl start mariadb
Then you can use mysql normally
[ root@yl-web yl]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with; or \g.
Your MariaDB connection id is 3
Server version:5.5.41-MariaDB MariaDB Server
Copyright(c)2000,2014, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || test |+--------------------+4 rows inset(0.00 sec)
MariaDB [(none)]>
MariaDB (none)> is displayed after installing MariaDB, which may seem a bit unaccustomed. Here is the second method.
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server
After the installation is successful, restart the mysql service.
# service mysqld restart
When mysql is installed for the first time, the root account has no password.
[ root@yl-web yl]# mysql -u root
Welcome to the MySQL monitor. Commands end with; or \g.
Your MySQL connection id is 3
Server version:5.6.26 MySQL Community Server(GPL)Copyright(c)2000,2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || test |+--------------------+4 rows inset(0.01 sec)
mysql>
set password
mysql>set password for'root'@'localhost'=password('password');
Query OK,0 rows affected(0.00 sec)
mysql>
No need to restart the database to take effect.
The following content during the mysql installation:
Installed:
mysql-community-client.x86_64 0:5.6.26-2.el7 mysql-community-devel.x86_64 0:5.6.26-2.el7
mysql-community-libs.x86_64 0:5.6.26-2.el7 mysql-community-server.x86_64 0:5.6.26-2.el7
Dependency Installed:
mysql-community-common.x86_64 0:5.6.26-2.el7
Replaced:
mariadb.x86_64 1:5.5.41-2.el7_0 mariadb-devel.x86_64 1:5.5.41-2.el7_0 mariadb-libs.x86_64 1:5.5.41-2.el7_0
mariadb-server.x86_64 1:5.5.41-2.el7_0
So after installation, mariadb is automatically replaced and will no longer take effect.
[ root@yl-web yl]# rpm -qa |grep mariadb
[ root@yl-web yl]#
The mysql configuration file is /etc/my.cnf
Finally add the encoding configuration
[ mysql]default-character-set=utf8
The character encoding here must be the same as in /usr/share/mysql/charsets/Index.xml.
Assign all permissions of all tables in all databases to the root user at all IP addresses.
mysql> grant all privileges on *.* to root@'%'identified by 'password';
If it is a new user instead of root, you must first create a new user
mysql>create user 'username'@'%' identified by 'password';
At this point, you can connect remotely.
Maven hot deployment can be deployed to the local server with one line of command. If there is no problem, just one line of command can be deployed to the official server. It facilitates development and deployment. Because my Tomcat9 encountered many problems.
You can refer to [maven automatic deployment to remote tomcat tutorial] (http://www.cnblogs.com/xyb930826/p/5725340.html) for deployment and testing.
The following is an error I encountered, because there is no make configuration IDEA caused an error.
[ ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy(default-cli) on project liwenhao: Cannot invoke Tomcat manager: Connect
ion reset by peer: socket write error ->[Help 1][ERROR][ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.[ERROR] Re-run Maven using the -X switch to enable full debug logging.[ERROR][ERROR] For more information about the errors and possible solutions, please read the following articles:[ERROR][Help 1]
You can configure make as follows
Can succeed
**The war package is deployed on the server garbled **
You can solve the garbled code of the Chinese war package server by configuring the following properties.
< properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding></properties>
After configuring the figure.
When I used the mvn tomcat7:deploy
command to hot deploy, mysql could not be connected. Later, when I redeployed, this problem did not occur.
guess
It should be a problem with my configuration file
Reference documents
Recommended Posts