Skip to content

Commit 36c501a

Browse files
committed
✨ 更新脚本
1 parent 74a703f commit 36c501a

9 files changed

Lines changed: 614 additions & 13 deletions

File tree

codes/deploy/main.sh

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/bin/bash
22
###################################################################################
3-
# 环境部署脚本
3+
# Linux Centos 环境部署脚本
4+
# Author: Zhang Peng
45
###################################################################################
56

67
function printBeginning() {
78
cat << EOF
89
***********************************************************************************
9-
* Welcome to using the deployment script for linux.
10+
* Welcome to using the deployment script for Centos.
1011
* Author: Zhang Peng
1112
***********************************************************************************
1213
EOF
@@ -44,13 +45,16 @@ cat << EOF
4445
4546
=================================== Deploy Menu ===================================
4647
【1 - System Environment】
47-
[1-2 | libs] install commonly libs.
48+
[sys] initial system environment
49+
[libs] install commonly libs
4850
4951
【2 - Common Tools】
5052
[2 | tools] install all tools.
51-
[2-1 | git] install git. [2-2 | jdk8] install jdk8.
52-
[2-3 | maven] install maven. [2-4 | nginx] install nginx.
53-
[2-5 | nodejs] install node.js. [2-6 | tomcat] install tomcat8.
53+
[git] install git [svn] install svn
54+
[jdk8] install jdk8 [jdk8] install jdk8
55+
[maven] install maven [nginx] install nginx
56+
[nodejs] install node.js [tomcat] install tomcat8
57+
[elk] install elk
5458
5559
Press <CTRL-D> to exit
5660
Please input key:
@@ -63,15 +67,18 @@ function chooseOper() {
6367
while read key
6468
do
6569
case ${key} in
66-
1-2 | libs) ${filepath}/lib/install-libs.sh;;
70+
sys) ${filepath}/sys/init.sh;;
71+
libs) ${filepath}/lib/install-libs.sh;;
6772

6873
2 | tools) ${filepath}/tool/install-all.sh;;
69-
2-1 | git) ${filepath}/tool/git/install-git.sh;;
70-
2-2 | jdk8) ${filepath}/tool/jdk/install-jdk8.sh;;
71-
2-3 | maven) ${filepath}/tool/maven/install-maven.sh;;
72-
2-4 | nginx) ${filepath}/tool/nginx/install-nginx.sh;;
73-
2-5 | nodejs) ${filepath}/tool/nodejs/install-nodejs.sh;;
74-
2-6 | tomcat) ${filepath}/tool/tomcat/install-tomcat8.sh;;
74+
git) ${filepath}/tool/git/install-git.sh;;
75+
svn) ${filepath}/tool/git/install-svn.sh;;
76+
jdk8) ${filepath}/tool/jdk/install-jdk8.sh;;
77+
maven) ${filepath}/tool/maven/install-maven.sh;;
78+
nginx) ${filepath}/tool/nginx/install-nginx.sh;;
79+
nodejs) ${filepath}/tool/nodejs/install-nodejs.sh;;
80+
tomcat) ${filepath}/tool/tomcat/install-tomcat8.sh;;
81+
elk) ${filepath}/tool/elk/install-elk.sh;;
7582
* ) echo "invalid key";;
7683
esac
7784

codes/deploy/sys/init.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
###################################################################################
4+
# Linux Centos 环境初始化脚本(设置环境配置、安装基本的命令工具)
5+
# Author: Zhang Peng
6+
###################################################################################
7+
8+
cat << EOF
9+
***********************************************************************************
10+
* The initialization of linux environment is begin.
11+
***********************************************************************************
12+
EOF
13+
14+
filepath=$(cd "$(dirname "$0")"; pwd)
15+
16+
# 设置环境配置,不了解具体修改内容的情况下,请勿执行
17+
# ./set-config.sh
18+
19+
# 安装命令行工具
20+
${filepath}/install-cmd-tool.sh
21+
22+
# 时钟同步工具
23+
yum -y install ntp
24+
# 同步上海交通大学网络中心NTP服务器
25+
echo "* 4 * * * /usr/sbin/ntpdate ntp.sjtu.edu.cn > /dev/null 2>&1" >> /var/spool/cron/root
26+
# 以一个服务器时间为标准定时更新时间(有时需要以公司中的服务器作为标准)
27+
#echo "*/30 * * * * /usr/local/bin/ntpdate 192.168.16.182" >> /var/spool/cron/root
28+
29+
cat << EOF
30+
***********************************************************************************
31+
* The initialization of linux environment is over.
32+
***********************************************************************************
33+
EOF
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env bash
2+
3+
###################################################################################
4+
# 安装基本的命令工具
5+
# Author: Zhang Peng
6+
#
7+
# 如果不知道某个命令工具是由哪个包提供的,使用 yum provides xxx
8+
# 或 yum whatprovides xxx 来查找
9+
###################################################################################
10+
11+
###################################################################################
12+
# 执行本脚本后支持的命令工具
13+
# 核心工具:df、du、chkconfig
14+
# 网络工具:ifconfig、netstat、route
15+
# IP工具:ip、ss、ping、tracepath、traceroute
16+
# DNS工具:dig、host、nslookup、whois
17+
# 端口工具:lsof、nc、telnet
18+
# 下载工具:curl、wget
19+
# 防火墙工具:iptables
20+
# 编辑工具:emacs、vim
21+
# 流量工具:iftop、nethogs
22+
# 抓包工具:tcpdump
23+
###################################################################################
24+
# 核心工具
25+
echo -e "\n>>>>>>>>> install coreutils(df、du)"
26+
yum install -y coreutils
27+
echo -e "\n>>>>>>>>> install chkconfig"
28+
yum install -y chkconfig
29+
30+
# 网络工具
31+
echo -e "\n>>>>>>>>> install net-tools(ifconfig、netstat、route)"
32+
yum install -y net-tools
33+
34+
# IP工具
35+
echo -e "\n>>>>>>>>> install iputils(ping、tracepath)"
36+
yum install -y iputils
37+
echo -e "\n>>>>>>>>> install traceroute"
38+
yum install -y traceroute
39+
echo -e "\n>>>>>>>>> install iproute(ip、ss)"
40+
yum install -y iproute
41+
42+
# 端口工具
43+
echo -e "\n>>>>>>>>> install lsof"
44+
yum install -y lsof
45+
echo -e "\n>>>>>>>>> install nc"
46+
yum install -y nc
47+
echo -e "\n>>>>>>>>> install netstat"
48+
yum install -y netstat
49+
50+
# DNS工具
51+
echo -e "\n>>>>>>>>> install bind-utils(dig、host、nslookup)"
52+
yum install -y bind-utils
53+
echo -e "\n>>>>>>>>> install whois"
54+
yum install -y whois
55+
56+
# 下载工具
57+
echo -e "\n>>>>>>>>> install curl"
58+
yum install -y curl
59+
echo -e "\n>>>>>>>>> install wget"
60+
yum install -y wget
61+
62+
# 防火墙工具
63+
echo -e "\n>>>>>>>>> install iptables"
64+
yum install -y iptables
65+
66+
# 编辑工具
67+
echo -e "\n>>>>>>>>> install emacs"
68+
yum install -y emacs
69+
echo -e "\n>>>>>>>>> install vim"
70+
yum install -y vim
71+
72+
# 流量工具
73+
echo -e "\n>>>>>>>>> install iftop"
74+
yum install -y iftop
75+
echo -e "\n>>>>>>>>> install nethogs"
76+
yum install -y nethogs
77+
78+
# 抓包工具
79+
echo -e "\n>>>>>>>>> install tcpdump"
80+
yum install -y tcpdump

codes/deploy/sys/set-config.sh

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env bash
2+
3+
###################################################################################
4+
# Linux Centos 设置环境配置脚本
5+
# Author: Zhang Peng
6+
#
7+
# 不了解脚本中配置意图的情况下,不要贸然执行此脚本
8+
###################################################################################
9+
10+
# 获取当前机器 IP
11+
ip=""
12+
getDeviceIp() {
13+
ip=`ifconfig eth0 | grep "inet addr" | awk '{ print $2}' | awk -F: '{print $2}'`
14+
if [ "$ip" == "" ]
15+
then
16+
ip=`ifconfig ens32 | grep "inet"|grep "broadcast" | awk '{ print $2}' | awk -F: '{print $1}'`
17+
fi
18+
19+
if [ "$ip" == "" ]
20+
then
21+
ip=`echo $1`
22+
fi
23+
24+
if [ "${ip}" == "" ]
25+
then
26+
echo "无法获取IP地址"
27+
exit 0
28+
fi
29+
}
30+
31+
host=`hostname`
32+
33+
#set the file limit
34+
cat >> /etc/security/limits.conf << EOF
35+
* - nofile 65535
36+
* - nproc 65535
37+
EOF
38+
39+
#set system language utf8
40+
cat > /etc/sysconfig/i18n << EOF
41+
LANG="zh_CN.UTF-8"
42+
EOF
43+
44+
#set DNS
45+
cat >> /etc/hosts << EOF
46+
${ip} ${host}
47+
EOF
48+
49+
#set the control-alt-delete to guard against the miSUSE
50+
sed -i 's#exec /sbin/shutdown -r now#\#exec /sbin/shutdown -r now#' /etc/init/control-alt-delete.conf
51+
52+
#disable selinux
53+
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
54+
55+
#Full multiuser mode
56+
sed -i 's/id:5:initdefault:/id:3:initdefault:/' /etc/inittab
57+
58+
#tune kernel parametres
59+
cat >> /etc/sysctl.conf << EOF
60+
net.ipv4.tcp_tw_reuse = 1
61+
net.ipv4.tcp_tw_recycle = 1
62+
net.ipv4.tcp_fin_timeout = 2
63+
net.ipv4.tcp_syncookies = 1
64+
net.ipv4.tcp_keepalive_time = 1200
65+
net.ipv4.tcp_max_syn_backlog = 16384
66+
net.core.netdev_max_backlog = 16384
67+
net.core.somaxconn = 32768
68+
net.core.wmem_default = 8388608
69+
net.core.rmem_default = 8388608
70+
net.core.rmem_max = 16777216
71+
net.core.wmem_max = 16777216
72+
net.ipv4.tcp_timestamps = 0
73+
net.ipv4.route.gc_timeout = 100
74+
net.ipv4.tcp_synack_retries = 1
75+
net.ipv4.tcp_syn_retries = 1
76+
net.ipv4.tcp_mem = 94500000 915000000 927000000
77+
net.ipv4.tcp_max_orphans = 3276800
78+
net.ipv4.ip_local_port_range = 2000 65535
79+
net.ipv4.tcp_max_tw_buckets = 5000
80+
vm.swappiness=10
81+
EOF
82+
83+
#disable the ipv6
84+
cat > /etc/modprobe.d/ipv6.conf << EOF
85+
alias net-pf-10 off
86+
options ipv6 disable=1
87+
EOF
88+
echo "NETWORKING_IPV6=off" >> /etc/sysconfig/network

0 commit comments

Comments
 (0)