Skip to content

Commit 90908bb

Browse files
committed
update docs
1 parent 34458c1 commit 90908bb

7 files changed

Lines changed: 246 additions & 58 deletions

File tree

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
#!/usr/bin/env bash
2+
3+
##############################################################################
4+
# console color
5+
BLACK="\033[1;30m"
6+
RED="\033[1;31m"
7+
GREEN="\033[1;32m"
8+
YELLOW="\033[1;33m"
9+
BLUE="\033[1;34m"
10+
PURPLE="\033[1;35m"
11+
CYAN="\033[1;36m"
12+
RESET="$(tput sgr0)"
13+
##############################################################################
14+
15+
JAVA_OPTS=""
16+
APP_OPTS=""
17+
packageJavaOpts() {
18+
19+
# GC OPTS
20+
JAVA_OPTS="${JAVA_OPTS} -server -Xms8g -Xmx16g -Xss512k"
21+
JAVA_OPTS="${JAVA_OPTS} -XX:+UseParallelOldGC -XX:+UseAdaptiveSizePolicy -XX:MaxGCPauseMillis=150"
22+
JAVA_OPTS="${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom"
23+
24+
# DEBUG OPTS
25+
if [[ ${debug} == "on" ]]; then
26+
27+
# Remote Debug
28+
JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xnoagent -Djava.compiler=NONE"
29+
JAVA_OPTS="${JAVA_OPTS} -Xrunjdwp:transport=dt_socket,address=28889,server=y,suspend=n"
30+
31+
# GC LOG
32+
JAVA_OPTS="${JAVA_OPTS} -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps"
33+
JAVA_OPTS="${JAVA_OPTS} -verbose:gc -Xloggc:${LOG_PATH}/${APP_NAME}.gc.log"
34+
JAVA_OPTS="${JAVA_OPTS} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M"
35+
36+
# Heap Dump
37+
JAVA_OPTS="${JAVA_OPTS} -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError"
38+
JAVA_OPTS="${JAVA_OPTS} -XX:HeapDumpPath=${LOG_PATH}/${APP_NAME}.heapdump.hprof"
39+
40+
# JMX OPTS
41+
IP=`ip addr|grep "inet "|grep -v 127.0.0.1|awk '{print $2}'|cut -d/ -f1`
42+
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote=true"
43+
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
44+
JAVA_OPTS="${JAVA_OPTS} -Djava.rmi.server.hostname=${IP} -Dcom.sun.management.jmxremote.port=18889"
45+
fi
46+
47+
# APP OPTS
48+
JAVA_OPTS="${JAVA_OPTS} -Dsun.net.inetaddr.ttl=60 -Djava.net.preferIPv4Stack=true"
49+
JAVA_OPTS="${JAVA_OPTS} -Dspring.profiles.active=${profile} -Dfile.encoding=UTF-8"
50+
51+
# CLASSPATH
52+
APP_OPTS=" -classpath lib/* -Dlogging.config=file:./config/logback.dev.xml --spring.config.location=classpath:/,classpath:/config/,file:./,file:./config/"
53+
}
54+
55+
# 检查服务是否已经启动
56+
pid=""
57+
checkStarted() {
58+
pid=`ps -ef | grep java | grep ${APP_NAME} | awk '{print $2}'`
59+
if [[ -n "${pid}" ]]; then
60+
return 0
61+
else
62+
return 1
63+
fi
64+
}
65+
66+
main() {
67+
case "${oper}" in
68+
start )
69+
startServer
70+
;;
71+
stop )
72+
stopServer
73+
;;
74+
restart )
75+
stopServer
76+
sleep 5
77+
startServer
78+
;;
79+
* )
80+
echo "Invalid oper: ${oper}."
81+
exit 1
82+
esac
83+
84+
exit 0
85+
}
86+
87+
stopServer() {
88+
echo -n "stopping server: "
89+
if checkStarted ;then
90+
kill -9 ${pid}
91+
printf "${GREEN}\n${APP_NAME} is stopped.${RESET}\n"
92+
else
93+
printf "${RED}\n${APP_NAME} fail to stop.${RESET}\n"
94+
fi
95+
}
96+
97+
startServer() {
98+
printf "${BLUE}starting ${APP_NAME}...${RESET}\n"
99+
if checkStarted ;then
100+
printf "${YELLOW}[WARN] ${APP_NAME} already started!${RESET}\n"
101+
printf "PID: ${pid}\n"
102+
exit 1
103+
fi
104+
105+
packageJavaOpts
106+
printf "${CYAN}JVM OPTS:\n ${JAVA_OPTS}${RESET}\n"
107+
if [[ ! -f "${LOG_PATH}/start.out" ]]; then
108+
touch "${LOG_PATH}/start.out"
109+
fi
110+
nohup java ${JAVA_OPTS} -jar ${ROOT_DIR}/../spring-boot-app.jar ${APP_OPTS} >> ${LOG_PATH}/start.out 2>&1 &
111+
printf "${GREEN}\n${APP_NAME} is started.${RESET}\n"
112+
}
113+
114+
######################################## MAIN ########################################
115+
# 设置环境变量
116+
export LANG="zh_CN.UTF-8"
117+
ROOT_DIR=$(pwd)
118+
119+
APP_NAME=spring-boot-app
120+
LOG_PATH=${ROOT_DIR}/../logs
121+
mkdir -p ${LOG_PATH}
122+
123+
declare -a serial
124+
serial=(start stop restart)
125+
echo -n "请选择操作(可选值:start|stop|restart):"
126+
read oper
127+
if ! echo "${serial[@]}" | grep -q ${oper}; then
128+
echo "请选择正确操作(可选值:start|stop|restart)"
129+
exit 1
130+
fi
131+
132+
if [[ ${oper} == "start" ]] || [[ "${oper}" == "restart" ]]; then
133+
declare -a serial2
134+
serial2=(prod dev test)
135+
echo -n "选择 profile(可选值:prod|dev|test):"
136+
read profile
137+
if ! echo "${serial2[@]}" | grep -q ${profile}; then
138+
echo "请选择正确 profile(可选值:prod|dev|test)"
139+
exit 1
140+
fi
141+
142+
declare -a serial3
143+
serial3=(on off)
144+
echo -n "是否启动 debug 模式(可选值:on|off):"
145+
read debug
146+
if ! echo "${serial3[@]}" | grep -q ${debug}; then
147+
echo "是否启动 debug 模式(可选值:on|off)"
148+
exit 1
149+
fi
150+
fi
151+
152+
main

codes/linux/dunwu-ops.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ checkOsVersion() {
6363
menus=( "配置系统" "安装软件" "退出" )
6464
main() {
6565
PS3="请输入命令编号:"
66-
select item in ${menus[@]}
66+
select item in "${menus[@]}"
6767
do
6868
case ${item} in
6969
"配置系统")

codes/linux/dunwu-sys.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ EOF
1212
menus=( "替换yum镜像" "安装基本的命令工具" "安装常用libs" "系统配置" "全部执行" "退出" )
1313
main() {
1414
PS3="请输入命令编号:"
15-
select item in ${menus[@]}
15+
select item in "${menus[@]}"
1616
do
1717
case ${item} in
1818
"替换yum镜像")

codes/linux/soft/arthas-install.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
# ----------------------------------------------------------------------------------
4+
# 控制台颜色
5+
BLACK="\033[1;30m"
6+
RED="\033[1;31m"
7+
GREEN="\033[1;32m"
8+
YELLOW="\033[1;33m"
9+
BLUE="\033[1;34m"
10+
PURPLE="\033[1;35m"
11+
CYAN="\033[1;36m"
12+
RESET="$(tput sgr0)"
13+
# ----------------------------------------------------------------------------------
14+
15+
printf "${PURPLE}"
16+
cat << EOF
17+
# ----------------------------------------------------------------------------------
18+
# Arthas 安装脚本
19+
# @author: Zhang Peng
20+
# ----------------------------------------------------------------------------------
21+
EOF
22+
printf "${RESET}"
23+
24+
printf "${BLUE}>>>>>>>> begin.\n${RESET}"
25+
26+
root=/opt/arthas
27+
if [[ -n $1 ]]; then
28+
root=$1
29+
fi
30+
31+
mkdir -p ${root}
32+
curl -o ${root}/arthas-boot.jar https://alibaba.github.io/arthas/arthas-boot.jar
33+
34+
printf "${GREEN}[OK]\n${RESET}"
35+
printf "${BLUE}<<<<<<<< end.\n${RESET}"

codes/linux/soft/config/settings-aliyun.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
4-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
3+
<settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
5+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
56

67
<!-- 使用 aliyun maven 仓库加速下载 -->
78
<mirrors>
@@ -18,4 +19,4 @@
1819
<mirrorOf>central</mirrorOf>
1920
</mirror>
2021
</mirrors>
21-
</settings>
22+
</settings>

codes/linux/soft/elk/config/filebeat.yml

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,54 +14,54 @@
1414

1515
filebeat.prospectors:
1616

17-
# Each - is a prospector. Most options can be set at the prospector level, so
18-
# you can use different prospectors for various configurations.
19-
# Below are the prospector specific configurations.
17+
# Each - is a prospector. Most options can be set at the prospector level, so
18+
# you can use different prospectors for various configurations.
19+
# Below are the prospector specific configurations.
2020

21-
- type: log
21+
- type: log
2222

23-
# Change to true to enable this prospector configuration.
24-
enabled: true
23+
# Change to true to enable this prospector configuration.
24+
enabled: true
2525

26-
# Paths that should be crawled and fetched. Glob based paths.
27-
paths:
28-
#- /var/log/*.log
29-
#- c:\programdata\elasticsearch\logs\*
30-
- /home/zp/log/*.log
26+
# Paths that should be crawled and fetched. Glob based paths.
27+
paths:
28+
#- /var/log/*.log
29+
#- c:\programdata\elasticsearch\logs\*
30+
- /home/zp/log/*.log
3131

32-
# Exclude lines. A list of regular expressions to match. It drops the lines that are
33-
# matching any regular expression from the list.
34-
#exclude_lines: ['^DBG']
32+
# Exclude lines. A list of regular expressions to match. It drops the lines that are
33+
# matching any regular expression from the list.
34+
#exclude_lines: ['^DBG']
3535

36-
# Include lines. A list of regular expressions to match. It exports the lines that are
37-
# matching any regular expression from the list.
38-
#include_lines: ['^ERR', '^WARN']
36+
# Include lines. A list of regular expressions to match. It exports the lines that are
37+
# matching any regular expression from the list.
38+
#include_lines: ['^ERR', '^WARN']
3939

40-
# Exclude files. A list of regular expressions to match. Filebeat drops the files that
41-
# are matching any regular expression from the list. By default, no files are dropped.
42-
#exclude_files: ['.gz$']
40+
# Exclude files. A list of regular expressions to match. Filebeat drops the files that
41+
# are matching any regular expression from the list. By default, no files are dropped.
42+
#exclude_files: ['.gz$']
4343

44-
# Optional additional fields. These fields can be freely picked
45-
# to add additional information to the crawled log files for filtering
46-
#fields:
47-
# level: debug
48-
# review: 1
44+
# Optional additional fields. These fields can be freely picked
45+
# to add additional information to the crawled log files for filtering
46+
#fields:
47+
# level: debug
48+
# review: 1
4949

50-
### Multiline options
50+
### Multiline options
5151

52-
# Mutiline can be used for log messages spanning multiple lines. This is common
53-
# for Java Stack Traces or C-Line Continuation
52+
# Mutiline can be used for log messages spanning multiple lines. This is common
53+
# for Java Stack Traces or C-Line Continuation
5454

55-
# The regexp Pattern that has to be matched. The example pattern matches all lines starting with [
56-
#multiline.pattern: ^\[
55+
# The regexp Pattern that has to be matched. The example pattern matches all lines starting with [
56+
#multiline.pattern: ^\[
5757

58-
# Defines if the pattern set under pattern should be negated or not. Default is false.
59-
#multiline.negate: false
58+
# Defines if the pattern set under pattern should be negated or not. Default is false.
59+
#multiline.negate: false
6060

61-
# Match can be set to "after" or "before". It is used to define if lines should be append to a pattern
62-
# that was (not) matched before or after or as long as a pattern is not matched based on negate.
63-
# Note: After is the equivalent to previous and before is the equivalent to to next in Logstash
64-
#multiline.match: after
61+
# Match can be set to "after" or "before". It is used to define if lines should be append to a pattern
62+
# that was (not) matched before or after or as long as a pattern is not matched based on negate.
63+
# Note: After is the equivalent to previous and before is the equivalent to to next in Logstash
64+
#multiline.match: after
6565

6666

6767
#============================= Filebeat modules ===============================
@@ -123,25 +123,25 @@ setup.kibana:
123123
# IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
124124
host: "192.168.28.11:5601"
125125

126-
#============================= Elastic Cloud ==================================
126+
#============================= Elastic Cloud ==================================
127127

128-
# These settings simplify using filebeat with the Elastic Cloud (https://cloud.elastic.co/).
128+
# These settings simplify using filebeat with the Elastic Cloud (https://cloud.elastic.co/).
129129

130-
# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
131-
# `setup.kibana.host` options.
132-
# You can find the `cloud.id` in the Elastic Cloud web UI.
133-
#cloud.id:
130+
# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
131+
# `setup.kibana.host` options.
132+
# You can find the `cloud.id` in the Elastic Cloud web UI.
133+
#cloud.id:
134134

135-
# The cloud.auth setting overwrites the `output.elasticsearch.username` and
136-
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
137-
#cloud.auth:
135+
# The cloud.auth setting overwrites the `output.elasticsearch.username` and
136+
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
137+
#cloud.auth:
138138

139-
#================================ Outputs =====================================
139+
#================================ Outputs =====================================
140140

141-
# Configure what output to use when sending the data collected by the beat.
141+
# Configure what output to use when sending the data collected by the beat.
142142

143-
#-------------------------- Elasticsearch output ------------------------------
144-
#output.elasticsearch:
143+
#-------------------------- Elasticsearch output ------------------------------
144+
#output.elasticsearch:
145145
# Array of hosts to connect to.
146146
#hosts: ["192.168.28.11:9200"]
147147

codes/linux/soft/elk/config/logback.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- logback中一共有5种有效级别,分别是TRACE、DEBUG、INFO、WARN、ERROR,优先级依次从低到高 -->
44
<configuration scan="true" scanPeriod="60 seconds" debug="false">
55

6-
<property name="FILE_NAME" value="javatool"/>
6+
<property name="FILE_NAME" value="javatool" />
77

88
<!-- 将记录日志打印到控制台 -->
99
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
@@ -45,12 +45,12 @@
4545
<!-- logger begin -->
4646
<!-- 本项目的日志记录,分级打印 -->
4747
<logger name="io.github.zp" level="TRACE">
48-
<appender-ref ref="ELK-TCP"/>
49-
<appender-ref ref="ALL"/>
48+
<appender-ref ref="ELK-TCP" />
49+
<appender-ref ref="ALL" />
5050
</logger>
5151

5252
<root level="TRACE">
53-
<appender-ref ref="STDOUT"/>
53+
<appender-ref ref="STDOUT" />
5454
</root>
5555
<!-- logger end -->
5656

0 commit comments

Comments
 (0)