linux安装jdk和mysql5.7

更新时间 🔔🕙 2021年5月4日

环境:
CentOS6.7 64位
JDK8
Mysql5.7

安装JDK

1.查看原来安装的jdk

rpm -qa | grep -E '^open[jre|jdk]|j[re|dk]'

2.卸载原来安装的jdk

yum remove java-1.6.0-openjdk
yum remove java-1.7.0-openjdk

3.下载oracle的rpm包,放入文件夹中,进行安装

rpm -ivh jdk-8u65-linux-x64.rpm

4.查看Java 版本,看安装是否成功

java -version

5.设置全局环境变量
在/etc/profile.d文件夹下,新建一个jdk.sh的文件,设置rx权限。

# oracle jdk 的配置
#!/bin/sh
#set java environment
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$PATH
# set apr path
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/tool/3rd/tomcat-native/lib

# openjdk的配置
export J2SDKDIR=/usr/lib/jvm/java-8-openjdk-amd64
export J2REDIR=/usr/lib/jvm/java-8-openjdk-amd64/jre
export PATH=$PATH:/usr/lib/jvm/java-8-openjdk-amd64/bin:/usr/lib/jvm/java-8-openjdk-amd64/jre/bin
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
#set java environment
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
# set apr path
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/tool/3rd/tomcat-native/lib

在/etc/profile.d文件夹下,新建一个jdk.csh的文件,设置rx权限。

# oracle jdk的配置
#!/bin/sh
#set java environment
setenv CLASSPATH .:${JAVA_HOME}/lib:${JAVA_HOME}/jre/lib:${CLASSPATH}
# set apr path
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/data/tool/3rd/tomcat-native/lib

ubuntu安装oracle jdk

参考网址:https://launchpad.net/~webupd8team/+archive/ubuntu/java

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

安装oraclejdk10,使用下面的ppa

sudo add-apt-repository ppa:linuxuprising/java
sudo apt update
sudo apt install oracle-java10-installer

安装oraclejdk11,使用下面的ppa

sudo add-apt-repository ppa:linuxuprising/java
sudo apt update
sudo apt install oracle-java11-installer
# 看各自需求,一般一个系统只有一个java环境的不用安装。make Oracle Java 11 default, install the oracle-java11-set-default package:
sudo apt install oracle-java11-set-default
# 看各自需求,如果没有安装,就不用执行。If you want to have Oracle Java 11 installed but not set it as the default Java, make sure the oracle-java11-set-default package is not installed / remove it:
sudo apt remove oracle-java11-set-default

安装openjdk,使用下面的

sudo apt update
sudo apt-get install openjdk-8-jdk
#sudo apt-get install openjdk-10-jdk
#sudo apt-get install openjdk-11-jdk

ubuntu安装tomcat apr

参考网址:https://stackoverflow.com/questions/22075531/how-to-install-apr-in-ubuntu
springboot怎样添加apr支持:https://gist.github.com/andreldm/7f89a3279438467a0bd41e6c1249d014
安装apr,apr-util,tomcat-native

#apt-get install libapr1 libapr1-dev libaprutil1
#安装在【/usr/lib/x86_64-linux-gnu/libtcnative-1.so】

#tomcat8.5开启apr
apt-get install libapr1 libaprutil1

下载编译好的tomcat-native

编译tomcat-native

#编译tomcat-native
apt-get install libapr1 libapr1-dev libaprutil1 libssl-dev
cd ./tomcat-native-1.2.17-src/native
./configure --with-apr=/usr/bin/apr-1-config \
--with-java-home=${JAVA_HOME} \
--with-ssl=yes \
--prefix=/data/tool/3rd/tomcat-native
#切换到root目录
sudo -s

Linux环境

系统变量LD_LIBRARY_PATH来添加java.library.path

Windows

在系统->高级系统设置->环境变量里,在path变量里添加。

修改tomcat的server.xml为

<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="off" useAprConnector="true"/>

加速tomcat的启动
catalina.sh里面添加下面的jvm参数
JAVA_OPTS=”${JAVA_OPTS} -Djava.security.egd=file:/dev/urandom”

安装mysql5.7

1.在mysql的官方网站上,下载对应CentOS6.7的含有yum库的rpm包。
官方介绍网址:http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
rpm包下载网址:http://dev.mysql.com/downloads/repo/yum/
然后下载中选择:
Red Hat Enterprise Linux 6 / Oracle Linux 6 (Architecture Independent), RPM Package版本,
文件是:mysql57-community-release-el6-7.noarch.rpm

直接的下载地址:http://repo.mysql.com//mysql57-community-release-el6-7.noarch.rpm
注意:一般来说,随着linux版本的升级,后面可能会变成el6-8,el6-9

2.安装rpm包

rpm -Uvh mysql57-community-release-el6-7.noarch.rpm

3.查看有哪些版本的mysql

yum repolist all | grep mysql

4.安装mysql

yum install mysql-community-server

5.启动mysql

service mysqld start

6.查看状态

service mysqld status

7.设置密码
获取安装时候的密码

grep "password" /var/log/mysqld.log

重新设置密码

mysql_secure_installation

http://www.centoscn.com/mysql/2015/1126/6451.html
http://sharong.iteye.com/blog/2262760
http://www.cnblogs.com/5201351/p/4912614.html

转载请备注引用地址:编程记忆 » linux安装jdk和mysql5.7