当前位置:   article > 正文

在centos7上安装开发环境(jdk8、mariadb和tomcat9)_centos 7 mariadb jdk

centos 7 mariadb jdk

在centos7上安装开发环境(jdk、mariadb和tomcat)

一、工具安装

在360软件管家上安装Xshell工具,用于SSH登录连接;WinSCP工具用于上传下载文件(基于sftp)。

启动XShell,第一次启动会提示创建连接:

点击新建按钮,输入主机(centos主机ip地址)和名称(随意即可):

选择刚才新建的连接

输入用户名:

输入密码:

成功登录:

二、wget工具安装

yum -y install wget

三、安装jdk8

切换到/usr/local/src目录

下载jdk

解压:解压时,有些下载包需要z参数,tar -xvf 即可

创建/usr/local/jdk目录将jdk1.8.0_20/移动过去

cd /usr/local/src
wget http://dl.mycat.io/jdk-8u20-linux-x64.tar.gz
tar -zxvf jdk-8u20-linux-x64.tar.gz
mkdir -p ../jdk
mv jdk1.8.0_20/ ../jdk/

查看jdk目录:

[root@localhost src]# ls ../jdk
jdk1.8.0_20

上面的jdk来源于mycat的下载目录,如果要从oracle网站下载,请去如下网址下载,然后通过WinSCP上传至/usr/local/src目录下即可。

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

修改/etc/profile,并在末尾增加如下内容:

# by cailei 2018-01-16
JAVA_HOME=/usr/local/jdk/jdk1.8.0_20
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib/dt.jar
export JAVA_HOME JRE_HOME PATH CLASSPATH

修改文件可以使用vi工具,或者通过WinSCP下载文件到windows上,改完后再传到centos7机器上。

vi /etc/profile

具体vi命令可以网上查一下。然后使配置生效,并测试java命令是否能够成功执行。

source /etc/profile
java -version

四、安装tomcat9

基本步骤和jdk类似:

cd /usr/local/src
wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-9/v9.0.4/bin/apache-tomcat-9.0.4.tar.gz
tar -zxvf apache-tomcat-9.0.2.tar.gz
mkdir -p ../tomcat
mv apache-tomcat-9.0.2 ../tomcat

修改/etc/profile文件,并在末尾增加如下内容:

# by cailei -- tomcat
CATALINA_HOME=/usr/local/tomcat/apache-tomcat-9.0.2
CATALINA_BASE=/usr/local/tomcat/apache-tomcat-9.0.2
PATH=$PATH:$CATALINA_BASE/bin
export PATH CATALINA_BASE CATALINA_HOME

修改文件可以使用vi工具。

进入tomcat的bin目录,执行脚本启停tomcat:

cd /usr/local/tomcat/apache-tomcat-9.0.2/bin
./startup.sh
./shutdown.sh

如果需要修改端口,编辑/usr/local/tomcat/apache-tomcat-9.0.2/conf/server.xml即可。

五、mariadb安装

yum -y install mariadb mariadb-server

完成后,查看MariaDB安装版本:

[root@localhost apache-tomcat-9.0.2]# rpm -qa | grep maria
mariadb-server-5.5.56-2.el7.x86_64
mariadb-libs-5.5.56-2.el7.x86_64
mariadb-5.5.56-2.el7.x86_64

安装完成MariaDB,首先启动MariaDB

systemctl start mariadb

进行安全设置:

mysql_secure_installation

安全设置有多项,第一项直接回车即可,其他项根据自己的需要进行设置即可。

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

设置开机启动

systemctl enable mariadb
systemctl stop mariadb

设置字符集utf-8,需要修改3个配置文件

修改配置文件:/etc/my.cnf,在[mysqld]下增加如下信息

[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci' 
init_connect='SET NAMES utf8' 
character-set-server=utf8 
collation-server=utf8_unicode_ci 
skip-character-set-client-handshake

/etc/my.cnf.d/client.cnf,在[client]下增加如下信息:

[client]
default-character-set=utf8

/etc/my.cnf.d/mysql-clients.cnf,在[mysql]下增加如下信息:

[mysql]
default-character-set=utf8

/etc/my.cnf.d/server.cnf,在[mysqld]下增加如下信息,设置表名大小写不敏感:

lower_case_table_names=1

配置修改完成后,需要重新启动数据库

systemctl restart mariadb
客户端登录mysql,设置远程访问权限,xxx为root用户密码
mysql -u root -pxxx mysql

创建用户(如果不需要,可以不执行):

create user cailei@localhost identified by 'cailei';

设置用户root的远程访问权限,xxx为root用户密码

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'xxx' WITH GRANT OPTION;

查看防火墙状态

firewall-cmd --state

关闭防火墙

systemctl stop firewalld.service

如果使用阿里云虚拟主机,还需要设置阿里云的安全组,开放3306端口。




然后重启数据库即可。

systemctl restart mariadb

六、mariadb升级

如果需要升级(可以不升级),创建文件:

/etc/yum.repos.d/MariaDB.repo

内容如下(从https://mariadb.com/kb/en/library/yum/获取):

# MariaDB 10.2 CentOS repository list - created 2018-02-25 03:26 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

删除之前的安装:

systemctl stop mariadb
yum remove mariadb-server

重新安装:

yum -y install mariadb mariadb-server

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/186755
推荐阅读
相关标签
  

闽ICP备14008679号