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 ...
随机推荐
- Mybatis源码解读-配置加载和Mapper的生成
问题 Mybatis四大对象的创建顺序? Mybatis插件的执行顺序? 工程创建 环境:Mybatis(3.5.9) mybatis-demo,参考官方文档 简单示例 这里只放出main方法的示例, ...
- java字符串类型数学运算表达式以及精度丢失问题
字符串类型数学运算精度丢失问题 方式一:ScriptEngine 会精度丢失,可执行连续双括号 方式二:hutool ScriptUtil 会精度丢失,可执行连续双括号 方式三:hutool Scri ...
- python将命令输出写入文件或临时缓存
python将命令输出写入文件 将文件写入到对应文件,方便后期处理或保存 def write_file(file_path): with open(file=file_path, mode=" ...
- Linux系列之进程管理
前言 进程是正在运行的程序,Linux系统通常有数百个进程同时运行.本文就来介绍下Linux是如何进行进程管理的. 我们可以看到: 查看进程(Viewing processes) 查找进程(Findi ...
- 高通cDSP简单编程例子(实现查询高通cDSP使用率、签名),RK3588 npu使用率查询
PS:要转载请注明出处,本人版权所有. PS: 这个只是基于<我自己>的理解, 如果和你的原则及想法相冲突,请谅解,勿喷. 前置说明 本文作为本人csdn blog的主站的备份.(Bl ...
- Linux、Ubuntu常用命令
# 文件解压缩 # zip压缩目录(附带目录权限) zip -q -r html.zip /home/html 压缩目录 tar -zcvf pack.tar.gz pack/ #打包压缩为一个.gz ...
- Normal3类定义
法线的相关操作都在图中,实现部分还是大家自己练习,照着图写代码就行了. 类声明: class Normal3 { public: Normal3(); ~Normal3(); Normal3(ldou ...
- HDU3085 Nightmare Ⅱ (双向BFS)
联赛前该练什么?DP,树型,状压当然是爆搜啦 双向BFS就是两个普通BFS通过一拼接函数联系,多多判断啦 #include <iostream> #include <cstdio&g ...
- LuoguP3128 [USACO15DEC]最大流Max Flow (树上差分)
跟LOJ10131暗的连锁 相似,只是对于\(lca\)节点把它和父亲减一 #include <cstdio> #include <iostream> #include < ...
- Luogu1088 火星人 (康托展开)
皮一波 #include <iostream> #include <cstdio> #include <cstring> #include <algorith ...