#!/bin/bash

####使用方法###############
# chmod a+x JdTomK-Auto.sh
# source JdTomK-Auto.sh
########################### echo "1.开始安装Java环境:"
sleep 3 tar -zxv -f jdk-8u231-linux-x64.tar.gz -C /usr/local cat >> /etc/profile.d/java.sh << "EOF"
#!/bin/bash export JAVA_HOME=/usr/local/jdk1.8.0_231
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
EOF source /etc/profile.d/java.sh echo "验证java环境"
echo "JAVA_HOME ====" ${JAVA_HOME}
java -version echo "2.开始安装Maven环境:"
sleep 3 tar -zxv -f apache-maven-3.6.3-bin.tar.gz -C /usr/local cat >> /etc/profile.d/maven.sh << "EOF"
#!/bin/bash export MAVEN_HOME=/usr/local/apache-maven-3.6.3
export PATH=${MAVEN_HOME}/bin:${PATH}
EOF source /etc/profile.d/maven.sh echo "使用阿里云源"
mkdir -p /data/maven/repository # \cp表示不使用别名cp == cp -i
\cp -rf settings.xml /usr/local/apache-maven-3.6.3/conf echo "验证maven环境"
echo "MAVEN_HOME ====" ${MAVEN_HOME}
mvn -version echo "3.开始安装Tomcat:"
sleep 3 cat >> /etc/sysctl.conf << "EOF"
fs.file-max = 262144
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.rmem_default = 1048576
net.core.wmem_default = 524288
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.core.netdev_max_backlog = 2500
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_fin_timeout = 30
net.nf_conntrack_max = 655360
net.netfilter.nf_conntrack_tcp_timeout_established = 1200
EOF sysctl -p echo "* soft nofile 65535" >> /etc/security/limits.conf
echo "* hard nofile 65535" >> /etc/security/limits.conf INFO=`getconf LONG_BIT`
if [ ${INFO} = "64" ] ; then
echo "session required /lib64/security/pam_limits.so" >> /etc/pam.d/login
else
echo "session required /lib/security/pam_limits.so" >> /etc/pam.d/login
fi tar -zxv -f apache-tomcat-8.5.64.tar.gz -C /usr/local #register server
cp -p /usr/local/apache-tomcat-8.5.64/bin/catalina.sh /etc/init.d/tomcat sed -i '3a #chkconfig: 112 63 37' /etc/init.d/tomcat
sed -i '4a #description: tomcat server init script' /etc/init.d/tomcat
sed -i '5a #Source Function Library' /etc/init.d/tomcat
sed -i '6a . /etc/init.d/functions' /etc/init.d/tomcat
sed -i '7a JAVA_HOME=/usr/local/jdk1.8.0_231/' /etc/init.d/tomcat
sed -i '8a CATALINA_HOME=/usr/local/apache-tomcat-8.5.64' /etc/init.d/tomcat #chmod
chmod 755 /etc/init.d/tomcat
#add to service
chkconfig --add tomcat
#auto run
chkconfig tomcat on
service tomcat start echo "4.开始安装mysql:" rpm -qa |grep mysql
rpm -qa |grep mariadb
yum remove mysql mysql-server mysql-libs mariadb mariadb-libs -y groupadd mysql
useradd -g mysql mysql -s /sbin/nologin tar -zxv -f mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz -C /data
cd /data/
mv mysql-5.7.32-linux-glibc2.12-x86_64 mysql
ln -sv /data/mysql /usr/local/mysql mkdir -pv /data/mysql/data
mkdir -pv /data/mysql/dblog/iblog
mkdir -pv /data/mysql/dblog/binlog
mkdir -pv /data/mysql/dblog/relaylog
mkdir -pv /data/mysql/dblog/errlog
mkdir -pv /data/mysql/dblog/slowlog
mkdir -pv /data/mysql/run
mkdir -pv /data/mysql/tmp
mkdir -pv /data/mysql/lock/subsys
chown -R mysql:mysql /data/mysql
chmod -R 755 /data/mysql cat >> /etc/my.cnf << "EOF"
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL. #[mysqld] # Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin # These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = ..... # Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M [mysql] # CLIENT #
port = 3306
socket = /data/mysql/run/mysql.sock
disable-auto-rehash
default-character-set=utf8mb4
prompt=(\\u@\\h) [\\d]>\\_ [mysqld] # GENERAL #
server_id = 128
port = 3306
user = mysql
explicit_defaults_for_timestamp=true default-storage-engine = InnoDB
character_set_server = utf8mb4
auto_increment_increment = 2
auto_increment_offset = 1
lower_case_table_names = 1
socket = /data/mysql/run/mysql.sock
pid_file = /data/mysql/run/mysqld.pid # MyISAM #
key-buffer-size = 32M
myisam-recover-options = FORCE,BACKUP # SAFETY #
max_allowed_packet = 134217728
max_connections = 2048
max_user_connections = 1024
open_files_limit = 65535
skip-name-resolve
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
sysdate-is-now = 1 # DATA STORAGE #
basedir = /data/mysql
datadir = /data/mysql/data/
tmpdir = /data/mysql/tmp # BINARY LOGGING #
log-bin = /data/mysql/dblog/binlog/master-bin
log-bin-index = /data/mysql/dblog/binlog/master-bin.index
expire-logs-days = 15
sync-binlog = 1
binlog_format = ROW #RELAY LOGGING
relay-log=/data/mysql/dblog/relaylog/master-relay-bin
relay-log-index=/data/mysql/dblog/relaylog/master-relay-bin.index
# sync_relay_log=1 最安全,崩溃后最多丢失一个事件,但是会引起同步延迟 # CACHES AND LIMITS #
tmp-table-size = 32M
max-heap-table-size = 32M
query-cache-type = 0
query-cache-size = 0
thread-cache-size = 50
open-files-limit = 65535
table-definition-cache = 1024
table-open-cache = 2048 # INNODB #
innodb_log_group_home_dir = /data/mysql/dblog/iblog
innodb_data_home_dir = /data/mysql/dblog/iblog
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 = 6G # LOGGING #
log_timestamps=system
general_log = off
log-error = /data/mysql/dblog/errlog/mysql-error.log
log-queries-not-using-indexes = 1
slow-query-log = 1
slow-query-log-file = /data/mysql/dblog/slowlog/mysql-slow.log
log_slave_updates=ON
EOF cd /data/mysql/bin
./mysqld --defaults-extra-file=/etc/my.cnf --basedir=/data/mysql --datadir=/data/mysql/data --user=mysql --initialize-insecure
./mysql_ssl_rsa_setup --basedir=/data/mysql --datadir=/data/mysql/data cat >> /etc/profile.d/mysql.sh << "EOF"
#!/bin/bash PATH=/data/mysql/bin:$PATH
EOF source /etc/profile.d/mysql.sh cp /data/mysql/support-files/mysql.server /etc/init.d/mysqld sed -i 's/^mysqld_pid_file_path=.*$/mysqld_pid_file_path=\/data\/mysql\/run\/mysqld.pid/' /etc/init.d/mysqld
sed -i "s/^lockdir=.*$/lockdir='\/data\/mysql\/lock\/subsys'/" /etc/init.d/mysqld chkconfig --add mysqld
# /etc/init.d/mysqld start
# /etc/init.d/mysqld stop
service mysqld start
# service mysqld restart echo "等待MySQL启动"
sleep 5
service mysqld status echo "默认没有密码" if [ $? -eq 0 ]
then
mysql -e "use mysql;DELETE FROM mysql.user WHERE User='' or host='localhost';"
else
echo "failed"
fi if [ $? -eq 0 ]
then
mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY 'password' WITH GRANT OPTION;FLUSH PRIVILEGES;"
else
echo "failed"
fi echo "若需要创建数据库,用户等在这儿增加" service mysqld restart echo "mysql root用户密码:password" echo "##########################################################################"
echo -e "\033[32m安装完成\n启动Tomcat: service tomcat start\n关闭Tomcat: service tomcat stop\nTomcat目录:/usr/local/apache-tomcat-8.5.64/webapps/ROOT\033[0m"
echo -e "\033[32m安装完成\n启动mysql: service mysqld start\n关闭Tomcat: service mysqld stop\n\033[0m"
echo -e "\033"
echo "##########################################################################"

CentOS系统一键部署jdk,maven,tomcat,mysql的更多相关文章

  1. 【转载】Centos系统快速部署LNMP环境

    PHP语言在Linux系统上运行的时候,需要在Linux系统上部署相应的Nginx.MySQL.PHP等环境,只有将这些环境参数都设置好,PHP相关应用程序才可正常运行,部署环境的方法有很多种,可手动 ...

  2. Docker Compose 一键部署Nginx代理Tomcat集群

    Docker Compose 一键部署Nginx代理Tomcat集群 目录结构 [root@localhost ~]# tree compose_nginx_tomcat/ compose_nginx ...

  3. 如何在Cent OS上安装和部署jdk与tomcat?

    Cent OS是一款Linux系统.在商业应用中,Linux操作系统在服务器市场有着广泛的运用,这源于Linux系统的几大优点: 1.跨平台的硬件支持 由于Linux 的内核大部分是用C 语言编写的, ...

  4. Centos 环境一键部署脚本(shell脚本)

    谨以此文纪念吊炸天的Centos环境一键部署方案的新鲜出炉 辛苦大半年,产品准备上线了,BOSS亲自体验安装部署,看着超过200+页的安装文档直接崩溃了(需要部署23个基础服务),经历了超过3个小时的 ...

  5. CentOS 7 下 JDK1.8+Maven+Nginx+MySql+Git+Redis环境安装

    CentOS 7 下 JDK1.8+Maven+Nginx+MySql+Git+Redis环境安装 安装目录准备 新建data目录,用来放下载的软件 mkdir -p /data 切换到该data目录 ...

  6. linux CentOS 系统下如何将php和mysql命令加入到环境变量中

    在Linux CentOS系统上安装完php和MySQL后,为了使用方便,需要将php和mysql命令加到系统命令中,如果在没有添加到环境变量之前,执行“php -v”命令查看当前php版本信息时时, ...

  7. Linux中CentOS 7版本安装JDK、Tomcat、MySQL、lezsz、maven软件详解

    软件安装 在Linux系统中,安装软件的方式主要有四种,这四种安装方式的特点如下: 安装方式 特点 二进制发布包安装 软件已经针对具体平台编译打包发布,只要解压,修改配置即可 rpm安装 软件已经按照 ...

  8. linux(Centos7系统)中安装JDK、Tomcat、Mysql

    安装前准备两个工具:(360可以安装) 1.JDK的安装 使用yum命令安装 .查看是否已安装JDK # yum list installed |grep java .卸载CentOS系统Java环境 ...

  9. JDK+Apache+Tomcat+MySQL配置 一起来学习吧

    配置JDK1.8+Apache2.4+Tomcat8.0+mySQL5.1,网上的资料非常繁杂,花费几天时间配置成功,汇总记录. 操作系统:CentOS6.5 预先下载最新版软件: apache-to ...

随机推荐

  1. Java 范例 - 定时任务

    前言 JDK 有两种定时任务的实现,一种是单线程循环判断,另一种则是线程池. 定时器 java.util 包下有 Timer 类可用来实现定时任务,下面是一个简单的例子: Date date = ne ...

  2. Maven3 入门到入门

    Maven3 Core Overview Maven是一个项目管理工具,它包含了一个项目对象模型(Project Object Model,POM) ,一组标准集合,一个项目生命周期(Project ...

  3. 年中盘点 | 2022年,PaaS 再升级

    作者丨刘世民(Sammy Liu)全文共7741个字,预计阅读需要15分钟 过去十五年,是云计算从无到有突飞猛进的十五年.PaaS作为云计算的重要组成部分,在伴随着云计算高速发展的同时,在云计算产业链 ...

  4. c++头文件的一个误导

    通常情况下,我们都认为c++的头文件是这样的: #include <bits/stdc++.h> using namespace std; int main() 但c++也可以用c的头文件 ...

  5. 【PMP学习笔记】第1章 PMP体系引论

    一.什么是项目? 项目是为创造独特的产品.服务或成果而进行的临时性工作. 项目管理是把事办成的方法论,万物皆可项目. 项目的特性 临时性:有明确的"起"和"止" ...

  6. 2022-7-21 第七组 pan小堂 继承与super与this

    1.继承 1.1继承的概述 在现实生活中,继承一般指的是子女继承父辈的财产.在程序中,继承描述的是事物之间的所属关系,通过继承可以使多种事物之间形成一种关系体系. 1.2继承的格式 class 子类 ...

  7. input 输入框背景色设置为透明

  8. python 可变、不可变类型、深拷贝、浅拷贝理解

    简介 python中数据分为可变类型,不可变类型.不同的数据类型影响着不同情况下的深浅拷贝. 下面则将简要介绍一下 可变类型 当某个数据的值发生改变时,它对应的内存地址不发生改变,常见的有列表.字典. ...

  9. mysql show操作

    SHOW CHARACTER SET 显示所有可用的字符集 SHOW CHARACTER SET; SHOW CHARACTER SET LIKE 'latin%'; SHOW COLLATION 输 ...

  10. Tomcat启动失败 提示Server Tomcat v7.0 Server at localhost failed to start.六种解决方法

    Tomcat启动失败,提示Server Tomcat v7.0 Server at localhost failed to start 在一次查看自己以前写过的项目中,运行tomcat失败,出现如图提 ...