CentOS系统一键部署jdk,maven,tomcat,mysql
#!/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的更多相关文章
- 【转载】Centos系统快速部署LNMP环境
PHP语言在Linux系统上运行的时候,需要在Linux系统上部署相应的Nginx.MySQL.PHP等环境,只有将这些环境参数都设置好,PHP相关应用程序才可正常运行,部署环境的方法有很多种,可手动 ...
- Docker Compose 一键部署Nginx代理Tomcat集群
Docker Compose 一键部署Nginx代理Tomcat集群 目录结构 [root@localhost ~]# tree compose_nginx_tomcat/ compose_nginx ...
- 如何在Cent OS上安装和部署jdk与tomcat?
Cent OS是一款Linux系统.在商业应用中,Linux操作系统在服务器市场有着广泛的运用,这源于Linux系统的几大优点: 1.跨平台的硬件支持 由于Linux 的内核大部分是用C 语言编写的, ...
- Centos 环境一键部署脚本(shell脚本)
谨以此文纪念吊炸天的Centos环境一键部署方案的新鲜出炉 辛苦大半年,产品准备上线了,BOSS亲自体验安装部署,看着超过200+页的安装文档直接崩溃了(需要部署23个基础服务),经历了超过3个小时的 ...
- CentOS 7 下 JDK1.8+Maven+Nginx+MySql+Git+Redis环境安装
CentOS 7 下 JDK1.8+Maven+Nginx+MySql+Git+Redis环境安装 安装目录准备 新建data目录,用来放下载的软件 mkdir -p /data 切换到该data目录 ...
- linux CentOS 系统下如何将php和mysql命令加入到环境变量中
在Linux CentOS系统上安装完php和MySQL后,为了使用方便,需要将php和mysql命令加到系统命令中,如果在没有添加到环境变量之前,执行“php -v”命令查看当前php版本信息时时, ...
- Linux中CentOS 7版本安装JDK、Tomcat、MySQL、lezsz、maven软件详解
软件安装 在Linux系统中,安装软件的方式主要有四种,这四种安装方式的特点如下: 安装方式 特点 二进制发布包安装 软件已经针对具体平台编译打包发布,只要解压,修改配置即可 rpm安装 软件已经按照 ...
- linux(Centos7系统)中安装JDK、Tomcat、Mysql
安装前准备两个工具:(360可以安装) 1.JDK的安装 使用yum命令安装 .查看是否已安装JDK # yum list installed |grep java .卸载CentOS系统Java环境 ...
- JDK+Apache+Tomcat+MySQL配置 一起来学习吧
配置JDK1.8+Apache2.4+Tomcat8.0+mySQL5.1,网上的资料非常繁杂,花费几天时间配置成功,汇总记录. 操作系统:CentOS6.5 预先下载最新版软件: apache-to ...
随机推荐
- labview入门到出家11(补充)——基于单片机和labview开发的虚拟示波器
之前有小伙伴提到需要虚拟示波器的资料,有些库还有文件丢失了,直接给的工程跑不起来,这里我把关键的地方讲解一下,大家可以自行开发.其实开发不难,只是有些点会耗点时间.虚拟示波器,顾名思义就是非实物的 ...
- Note -「狄利克雷前缀和」
学到一个诡异东西,当个 Trick 处理用吧. 现在有一个形如 \(\sum \limits _{i = 1} ^{n} \sum \limits _{d | i} f(d)\) 的柿子,不难发现可以 ...
- 算法竞赛进阶指南0x14 Hash
组成部分: 哈希函数: 链表 AcWing137. 雪花雪花雪花 因为所需要数据量过于大,所以只能以O(n)的复杂度. 所以不可能在实现的过程中一一顺时针逆时针进行比较,所以采用一种合适的数据结构. ...
- Netty源码解读(二)-服务端源码讲解
简单Echo案例 注释版代码地址:netty 代码是netty的源码,我添加了自己理解的中文注释. 了解了Netty的线程模型和组件之后,我们先看看如何写一个简单的Echo案例,后续的源码讲解都基于此 ...
- Golang 盲注脚本
Golang 盲注脚本 payload部分 其中脚本最重要的环节就是payload部分了,需要如何去闭合,如何构造SQL语句来达到判断的效果.(还有如何绕过waf等等...) bool盲注 下面是最基 ...
- 《深入了解java虚拟机》高效并发读书笔记——Java内存模型,线程,线程安全 与锁优化
<深入了解java虚拟机>高效并发读书笔记--Java内存模型,线程,线程安全 与锁优化 本文主要参考<深入了解java虚拟机>高效并发章节 关于锁升级,偏向锁,轻量级锁参考& ...
- 无意苦争春,一任群芳妒!M1 Mac book(Apple Silicon)能否支撑全栈工程师的日常?(Python3/虚拟机/Docker/Redis)
原文转载自「刘悦的技术博客」https://v3u.cn/a_id_187 就像大航海时代里突然诞生的航空母舰一样,苹果把玩着手心里远超时代的M1芯片,微笑着对Intel说:"不好意思,虽然 ...
- Taurus.MVC WebAPI 入门开发教程1:框架下载环境配置与运行(含系列目录)。
前言: Taurus.MVC 微服务版本已经发布了:Taurus.MVC V3.0.3 微服务开源框架发布:让.NET 架构在大并发的演进过程更简单. 以前都是框架发布时写点相关功能点的文章,没有形成 ...
- Java 注解及其底层原理
目录 什么是注解? 注解的分类 Java自带的标准注解 元注解 @Retention @Documented @Target @Inherited @Repeatable 自定义注解 自定义注解的读取 ...
- 详解ConCurrentHashMap源码(jdk1.8)
ConCurrentHashMap是一个支持高并发集合,常用的集合之一,在jdk1.8中ConCurrentHashMap的结构和操作和HashMap都很类似: 数据结构基于数组+链表/红黑树. ge ...