安装JDKTomcat和Mysql(CentOS 7.4)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装JDKTomcat和Mysql(CentOS 7.4)相关的知识,希望对你有一定的参考价值。

  • 上传软件包
rz上传jdk-8u181-linux-x64.tar.gz和apache-tomcat-8.5.32.tar.gz
或者FileZilla Client进行sftp链接上传

技术分享图片

  • 解压JDK到/usr/local/目录
tar xzvf jdk-8u181-linux-x64.tar.gz -C /usr/local/
  • 查看JAVA是否安装成功
cd /usr/local/jdk1.8.0_181/bin
[[email protected] bin]# ./java -version 
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mix-ed mode)
  • 配置环境变量
    [[email protected] bin]# vim /etc/profile
    export JAVA_HOME=/usr/local/jdk1.8.0_181
    export CLASSPATH=.:JAVA_HOME/lib
    export PATH=$PATH:$JAVA_HOME/bin
    [[email protected] ~]# source /etc/profile
    [[email protected] ~]# java -version      
    openjdk version "1.8.0_131"
    OpenJDK Runtime Environment (build 1.8.0_131-b12)
    OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)
  • 安装Tomcat
    [[email protected] software]# tar xzvf apache-tomcat-8.5.32.tar.gz
    [[email protected] software]# cd apache-tomcat-8.5.32/
    [[email protected] apache-tomcat-8.5.32]# ll
    总用量 92
    drwxr-x---. 2 root root  4096 8月  20 14:56 bin
    drwx------. 2 root root   238 6月  21 03:53 conf
    drwxr-x---. 2 root root  4096 8月  20 14:56 lib
    -rw-r-----. 1 root root 57092 6月  21 03:53 LICENSE
    drwxr-x---. 2 root root     6 6月  21 03:50 logs
    -rw-r-----. 1 root root  1723 6月  21 03:53 NOTICE
    -rw-r-----. 1 root root  7138 6月  21 03:53 RELEASE-NOTES
    -rw-r-----. 1 root root 16246 6月  21 03:53 RUNNING.txt
    drwxr-x---. 2 root root    30 8月  20 14:56 temp
    drwxr-x---. 7 root root    81 6月  21 03:51 webapps
    drwxr-x---. 2 root root     6 6月  21 03:50 work
    [[email protected] apache-tomcat-8.5.32]# cd bin/
    [[email protected] bin]# pwd
    /root/software/apache-tomcat-8.5.32/bin
    [[email protected] bin]# ./startup.sh 
    Using CATALINA_BASE:   /root/software/apache-tomcat-8.5.32
    Using CATALINA_HOME:   /root/software/apache-tomcat-8.5.32
    Using CATALINA_TMPDIR: /root/software/apache-tomcat-8.5.32/temp
    Using JRE_HOME:        /usr/local/jdk1.8.0_181
    Using CLASSPATH:       /root/software/apache-tomcat-8.5.32/bin/bootstrap.jar:/root/software/apache-tomcat-8.5.32/bin/tomcat-juli.jar
    Tomcat started.
  • 放行默认端口8080,关闭selinux
    [[email protected] bin]# firewall-cmd --permanent --add-port=8080/tcp
    success
    [[email protected] bin]# firewall-cmd --reload 
    success
    [[email protected] bin]# getenforce
    Enforcing
    [[email protected] bin]# setenforce 0
    [[email protected] bin]# getenforce  
    Permissive

    技术分享图片

  • 安装mysql
    [[email protected] bin]# yum repolist | grep mysql
    [[email protected] bin]# rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
    获取https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
    警告:/var/tmp/rpm-tmp.m7U7PD: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
    准备中...                          ################################# [100%]
    正在升级/安装...
    1:mysql80-community-release-el7-1  ################################# [100%]
[[email protected] bin]# yum repolist | grep mysql
mysql-connectors-community/x86_64        MySQL Connectors Community           63
mysql-tools-community/x86_64             MySQL Tools Community                69
mysql80-community/x86_64                 MySQL 8.0 Community Server           33
  • 获得两个mysql的yum repo源
[[email protected] yum.repos.d]# pwd
/etc/yum.repos.d
[[email protected] yum.repos.d]# ll
总用量 40
-rw-r--r--. 1 root root 1503 8月   3 05:03 CentOS-Base.repo
-rw-r--r--. 1 root root 1664 8月   3 05:01 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 1309 8月  30 2017 CentOS-CR.repo
-rw-r--r--. 1 root root  649 8月  30 2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 8月  30 2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 8月  30 2017 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 8月  30 2017 CentOS-Sources.repo
-rw-r--r--. 1 root root 3830 8月  30 2017 CentOS-Vault.repo
-rw-r--r--. 1 root root 1864 2月  22 16:49 mysql-community.repo
-rw-r--r--. 1 root root 1885 2月  22 16:49 mysql-community-source.repo
[[email protected] software]# yum install mysql-community-server
[[email protected] software]# yum install mysql-server
[[email protected] ~]# rpm -qa | grep mysql
mysql-community-server-8.0.12-1.el7.x86_64
mysql80-community-release-el7-1.noarch
mysql-community-libs-8.0.12-1.el7.x86_64
mysql-community-common-8.0.12-1.el7.x86_64
mysql-community-libs-compat-8.0.12-1.el7.x86_64
mysql-community-client-8.0.12-1.el7.x86_64

[[email protected] lib]# systemctl start mysqld
[[email protected] lib]# systemctl enable mysqld
[[email protected] lib]# cat /var/log/mysqld.log |grep password  #查看初始密码
2018-08-20T11:54:48.607318Z 5 [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: +goyZ3q8w?!z
[[email protected] lib]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 8
Server version: 8.0.12

Copyright (c) 2000, 2018, 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;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.  #提示需要先修改密码

mysql> alter user [email protected]‘localhost‘ identified by ‘[email protected]‘;  #修改密码为[email protected]
Query OK, 0 rows affected (0.10 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.02 sec)

mysql> 

以上是关于安装JDKTomcat和Mysql(CentOS 7.4)的主要内容,如果未能解决你的问题,请参考以下文章

centos下安装JDKTOMCAT

centos 下安装jdktomcat 以及tomcat无法从外部访问的解决办法

阿里云(CentOS)上安装jdktomcat

JDKTomcat安装(CentOS 7)

centos7安装配置jdktomcat

CentOS7下安装JDKTomcat及Maven