dubbo-monitor官方源码地址:https://github.com/Jeromefromcn/dubbo-monitor
在运维主机(mfyxw50.mfyxw.com)上执行
[root@mfyxw50 ~]# cd /opt/src/
[root@mfyxw50 src]# wget https://github.com/Jeromefromcn/dubbo-monitor/archive/master.zip
在运维主机(mfyxw50.mfyxw.com)上执行
[root@mfyxw50 ~]# mkdir -p /data/dockerfile/dubbo-monitor
[root@mfyxw50 ~]# unzip /opt/src/dubbo-monitor-master.zip #如没有unzip,请使用yum -y install unzip进行安装
[root@mfyxw50 src]# cp -R /opt/src/dubbo-monitor-master/* /data/dockerfile/dubbo-monitor/
在运维主机(mfyxw50.mfyxw.com)上执行
[root@mfyxw50 conf]# cat > /data/dockerfile/dubbo-monitor/dubbo-monitor-simple/conf/dubbo_origin.properties << EOF
dubbo.container=log4j,spring,registry,jetty
dubbo.application.name=dubbo-monitor
dubbo.application.owner=Maple
dubbo.registry.address=zookeeper://zk1.od.com:2181?backup=zk2.od.com:2181,zk3.od.com:2181
dubbo.protocol.port=20880
dubbo.jetty.port=8080
dubbo.jetty.directory=/dubbo-monitor-simple/monitor
dubbo.charts.directory=/dubbo-monitor-simple/charts
dubbo.statistics.directory=/dubbo-monitor-simple/statistics
dubbo.log4j.file=logs/dubbo-monitor-simple.log
dubbo.log4j.level=WARN
EOF
在运维主机(mfyxw50.mfyxw.com)上执行
[root@mfyxw50 conf]# cat > /data/dockerfile/dubbo-monitor/dubbo-monitor-simple/bin/start.sh << EOF
#!/bin/bash
sed -e "s/{ZOOKEEPER_ADDRESS}/\$ZOOKEEPER_ADDRESS/g" /dubbo-monitor-simple/conf/dubbo_origin.properties > /dubbo-monitor-simple/conf/dubbo.properties
cd \`dirname \$0\`
BIN_DIR=\`pwd\`
cd ..
DEPLOY_DIR=\`pwd\`
CONF_DIR=\$DEPLOY_DIR/conf
SERVER_NAME=\`sed ‘/dubbo.application.name/!d;s/.*=//‘ conf/dubbo.properties | tr -d ‘\r‘\`
SERVER_PROTOCOL=\`sed ‘/dubbo.protocol.name/!d;s/.*=//‘ conf/dubbo.properties | tr -d ‘\r‘\`
SERVER_PORT=\`sed ‘/dubbo.protocol.port/!d;s/.*=//‘ conf/dubbo.properties | tr -d ‘\r‘\`
LOGS_FILE=\`sed ‘/dubbo.log4j.file/!d;s/.*=//‘ conf/dubbo.properties | tr -d ‘\r‘\`
if [ -z "\$SERVER_NAME" ]; then
SERVER_NAME=\`hostname\`
fi
PIDS=\`ps -f | grep java | grep "\$CONF_DIR" |awk ‘{print \$2}‘\`
if [ -n "\$PIDS" ]; then
echo "ERROR: The \$SERVER_NAME already started!"
echo "PID: \$PIDS"
exit 1
fi
if [ -n "\$SERVER_PORT" ]; then
SERVER_PORT_COUNT=\`netstat -tln | grep \$SERVER_PORT | wc -l\`
if [ \$SERVER_PORT_COUNT -gt 0 ]; then
echo "ERROR: The \$SERVER_NAME port \$SERVER_PORT already used!"
exit 1
fi
fi
LOGS_DIR=""
if [ -n "\$LOGS_FILE" ]; then
LOGS_DIR=\`dirname \$LOGS_FILE\`
else
LOGS_DIR=\$DEPLOY_DIR/logs
fi
if [ ! -d \$LOGS_DIR ]; then
mkdir \$LOGS_DIR
fi
STDOUT_FILE=\$LOGS_DIR/stdout.log
LIB_DIR=\$DEPLOY_DIR/lib
LIB_JARS=\`ls $LIB_DIR|grep .jar|awk ‘{print "‘\$LIB_DIR‘/"\$0}‘|tr "\n" ":"\`
JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
JAVA_DEBUG_OPTS=""
if [ "\$1" = "debug" ]; then
JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
fi
JAVA_JMX_OPTS=""
if [ "\$1" = "jmx" ]; then
JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
fi
JAVA_MEM_OPTS=""
BITS=\`java -version 2>&1 | grep -i 64-bit\`
if [ -n "\$BITS" ]; then
JAVA_MEM_OPTS=" -server -Xmx128m -Xms128m -Xmn32m -XX:PermSize=16m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
else
JAVA_MEM_OPTS=" -server -Xms128m -Xmx128m -XX:PermSize=16m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
fi
echo -e "Starting the \$SERVER_NAME ...\c"
exec java \$JAVA_OPTS \$JAVA_MEM_OPTS \$JAVA_DEBUG_OPTS \$JAVA_JMX_OPTS -classpath \$CONF_DIR:\$LIB_JARS com.alibaba.dubbo.container.Main > \$STDOUT_FILE 2>&1
EOF
在运维主机(mfyxw50.mfyxw.com)上执行
[root@mfyxw50 ~]# cd /data/dockerfile/dubbo-monitor
[root@mfyxw50 dubbo-monitor]# docker build . -t harbor.od.com/infra/dubbo-monitor:latest
在运维主机(mfyxw50.mfyxw.com)上执行
[root@mfyxw50 ~]# docker login harbor.od.com
[root@mfyxw50 ~]# docker push harbor.od.com/infra/dubbo-monitor:latest
登录harbor.od.com的infra项目查看是否有dubbo-monitor镜像
在mfyxw10.mfyxw.com主机上执行
[root@mfyxw10 ~]# cat > /var/named/od.com.zone << EOF
\$ORIGIN od.com.
\$TTL 600 ; 10 minutes
@ IN SOA dns.od.com. dnsadmin.od.com. (
;序号请加1,表示比之前版本要新
2020031309 ; serial
10800 ; refresh (3 hours)
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS dns.od.com.
\$TTL 60 ; 1 minute
dns A 192.168.80.10
harbor A 192.168.80.50 ;添加harbor记录
k8s-yaml A 192.168.80.50
traefik A 192.168.80.100
dashboard A 192.168.80.100
zk1 A 192.168.80.10
zk2 A 192.168.80.20
zk3 A 192.168.80.30
jenkins A 192.168.80.100
dubbo-monitor A 192.168.80.100
EOF
重启DNS服务让其生效
[root@mfyxw10 ~]# systemctl restart named
验证是否可解析
[root@mfyxw10 ~]# dig -t A dubbo-monitor.od.com @192.168.80.10 +short
192.168.80.100
在运维主机(mfyxw50.mfyxw.com)上执行
创建一个dubbo-monitor目录
[root@mfyxw50 ~]# mkdir -p /data/k8s-yaml/dubbo-monitor
Deployment.yaml文件内容如下
[root@mfyxw50 ~]# cat > /data/k8s-yaml/dubbo-monitor/Deployment.yaml << EOF
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: dubbo-monitor
namespace: infra
labels:
name: dubbo-monitor
spec:
replicas: 1
selector:
matchLabels:
name: dubbo-monitor
template:
metadata:
labels:
app: dubbo-monitor
name: dubbo-monitor
spec:
containers:
- name: dubbo-monitor
image: harbor.od.com/infra/dubbo-monitor:latest
ports:
- containerPort: 8080
protocol: TCP
- containerPort: 20880
protocol: TCP
imagePullPolicy: IfNotPresent
imagePullSecrets:
- name: harbor
restartPolicy: Always
terminationGracePeriodSeconds: 30
securityContext:
runAsUser: 0
schedulerName: default-scheduler
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
revisionHistoryLimit: 7
progressDeadlineSeconds: 600
EOF
svc.yaml文件内容如下
[root@mfyxw50 ~]# cat > /data/k8s-yaml/dubbo-monitor/svc.yaml << EOF
kind: Service
apiVersion: v1
metadata:
name: dubbo-monitor
namespace: infra
spec:
ports:
- protocol: TCP
port: 8080
targetPort: 8080
selector:
app: dubbo-monitor
clusterIP: None
type: ClusterIP
sessionAffinity: None
EOF
Ingress文件内容如下
[root@mfyxw50 ~]# cat > /data/k8s-yaml/dubbo-monitor/Ingress.yaml << EOF
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: dubbo-monitor
namespace: infra
spec:
rules:
- host: dubbo-monitor.od.com
http:
paths:
- path: /
backend:
serviceName: dubbo-monitor
servicePort: 8080
EOF
在master节点(mfyxw30.mfyxw.com或mfyxw40.mfyxw.com)任意一台执行即可
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/Deployment.yaml
deployment.extensions/dubbo-monitor created
[root@mfyxw30 ~]#
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/svc.yaml
service/dubbo-monitor created
[root@mfyxw30 ~]#
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/Ingress.yaml
ingress.extensions/dubbo-monitor created
实战交付一套dubbo微服务到k8s集群(6)之交付dubbo-monitor到K8S集群
原文:https://www.cnblogs.com/Heroge/p/13123500.html