运行dubbo服务
作者:互联网
#统一namespace可以service不用加全称
root@slave002:/opt/k8s-data/dockerfile/web/chuan/dubbo/provider/dubbo-demo-provider-2.1.5/conf# cat dubbo.properties |grep -v "#" dubbo.container=log4j,spring dubbo.application.name=demo-provider dubbo.application.owner= dubbo.registry.address=zookeeper://zookeeper1.chuan.svc.cluster.local:2181 | zookeeper://zookeeper2.chuan.svc.cluster.local:2181 | zookeeper://zookeeper3.chuan.svc.cluster.local:2181 dubbo.monitor.protocol=registry dubbo.protocol.name=dubbo dubbo.protocol.port=20880 dubbo.log4j.file=logs/dubbo-demo-provider.log dubbo.log4j.level=WARN
root@slave002:/opt/k8s-data/dockerfile/web/chuan/dubbo/provider# cat Dockerfile #Dubbo provider FROM 192.168.192.155:80/pub-images/jdk-base:v8.212 RUN yum install file nc -y RUN mkdir -p /apps/dubbo/provider ADD dubbo-demo-provider-2.1.5/ /apps/dubbo/provider ADD run_java.sh /apps/dubbo/provider/bin
RUN && useradd nginx RUN chown nginx.nginx /apps -R RUN chmod a+x /apps/dubbo/provider/bin/*.sh
root@slave002:/opt/k8s-data/dockerfile/web/chuan/dubbo/provider# cat run_java.sh #!/bin/bash #echo "nameserver 223.6.6.6" > /etc/resolv.conf #/usr/share/filebeat/bin/filebeat -c /etc/filebeat/filebeat.yml -path.home /usr/share/filebeat -path.config /etc/filebeat -path.data /var/lib/filebeat -path.logs /var/log/filebeat & su - nginx -c "/apps/dubbo/provider/bin/start.sh"
#注意nginx不要加group #/apps/dubbo/provider/bin/start.sh tail -f /etc/hosts
root@slave002:/opt/k8s-data/yaml/chuan/dubbo/provider# cat provider.yaml kind: Deployment #apiVersion: extensions/v1beta1 apiVersion: apps/v1 metadata: labels: app: chuan-provider name: chuab-provider-deployment namespace: chuan spec: replicas: 1 selector: matchLabels: app: chuan-provider template: metadata: labels: app: mmchuan-provider spec: containers: - name: chuan-provider-container image: 192.168.192.155:80/chuan/dubbo-demo-provider:v1 #command: ["/apps/tomcat/bin/run_tomcat.sh"] #imagePullPolicy: IfNotPresent imagePullPolicy: Always ports: - containerPort: 20880 protocol: TCP name: http --- kind: Service apiVersion: v1 metadata: labels: app: chuan-provider name: chuan-provider-spec namespace: chuan spec: type: NodePort ports: - name: http port: 80 protocol: TCP targetPort: 20880 #nodePort: 30001 selector: app: chuan-provider
[root@chuan-provider-deployment-656557bd5b-2pgcj /]# ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 50 *:20880 *:*
consumer
root@slave002:/opt/k8s-data/dockerfile/web/chuan/dubbo/consumer/dubbo-demo-consumer-2.1.5/conf# cat dubbo.properties |grep -v "#" dubbo.container=log4j,spring dubbo.application.name=demo-consumer dubbo.application.owner= dubbo.registry.address=zookeeper://zookeeper1.chuan.svc.cluster.local:2181 | zookeeper://zookeeper2.chuan.svc.cluster.local:2181 | zookeeper://zookeeper3.chuan.svc.cluster.local:2181 dubbo.monitor.protocol=registry dubbo.log4j.file=logs/dubbo-demo-consumer.log dubbo.log4j.level=WARN
root@slave002:/opt/k8s-data/dockerfile/web/chuan/dubbo/consumer# cat run_java.sh #!/bin/bash #echo "nameserver 223.6.6.6" > /etc/resolv.conf #/usr/share/filebeat/bin/filebeat -c /etc/filebeat/filebeat.yml -path.home /usr/share/filebeat -path.config /etc/filebeat -path.data /var/lib/filebeat -path.logs /var/log/filebeat & su - nginx -c "/apps/dubbo/consumer/bin/start.sh" tail -f /etc/hosts
root@slave002:/opt/k8s-data/dockerfile/web/chuan/dubbo/consumer# cat Dockerfile #Dubbo consumer FROM 192.168.192.155:80/pub-images/jdk-base:v8.212 RUN yum install file -y RUN useradd nginx RUN mkdir -p /apps/dubbo/consumer ADD dubbo-demo-consumer-2.1.5 /apps/dubbo/consumer ADD run_java.sh /apps/dubbo/consumer/bin RUN chown nginx.nginx /apps -R RUN chmod a+x /apps/dubbo/consumer/bin/*.sh CMD ["/apps/dubbo/consumer/bin/run_java.sh"]
验证
[root@chuan-provider-deployment-656557bd5b-2pgcj logs]# tail -f stdout.log [21:18:27] Hello world150, request from consumer: /10.200.122.213:36238 [21:18:29] Hello world151, request from consumer: /10.200.122.213:36238 [21:18:31] Hello world152, request from consumer: /10.200.122.213:36238 [21:18:33] Hello world153, request from consumer: /10.200.122.213:36238
#dubboadmin
root@slave002:/opt/k8s-data/dockerfile/web/chuan/dubbo/dubboadmin/dubboadmin/WEB-INF# cat dubbo.properties dubbo.registry.address=zookeeper://zookeeper1.chuan.svc.cluster.local:2181 dubbo.admin.root.password=root dubbo.admin.guest.password=guest
root@slave002:/opt/k8s-data/dockerfile/web/pub-images/tomcat-base-8.5.43# cat Dockerfile #Tomcat 8.5.43基础镜像 FROM 192.168.192.155:80/pub-images/jdk-base:v8.212 RUN mkdir /apps /data/tomcat/webapps /data/tomcat/logs -pv ADD apache-tomcat-8.5.43.tar.gz /apps RUN useradd tomcat -u 2022 && ln -sv /apps/apache-tomcat-8.5.43 /apps/tomcat && chown -R tomcat.tomcat /apps /data -R
192.168.192.155:80/chuan/dubboadmin:v3 root@slave002:/opt/k8s-data/dockerfile/web/chuan/dubbo/dubboadmin# cat Dockerfile #Dubbo dubboadmin FROM 192.168.192.155:80/pub-images/tomcat-base:v8.5.43 RUN useradd nginx ADD server.xml /apps/tomcat/conf/server.xml ADD logging.properties /apps/tomcat/conf/logging.properties ADD catalina.sh /apps/tomcat/bin/catalina.sh ADD run_tomcat.sh /apps/tomcat/bin/run_tomcat.sh COPY dubboadmin /data/tomcat/webapps/dubboadmin RUN cd /data/tomcat/webapps && chown -R nginx.nginx /data /apps EXPOSE 8080 8443 CMD ["/apps/tomcat/bin/run_tomcat.sh"]
root@slave002:/opt/k8s-data/yaml/chuan/dubbo/dubboadmin# cat dubboadmin.yaml kind: Deployment #apiVersion: extensions/v1beta1 apiVersion: apps/v1 metadata: labels: app: chuan-dubboadmin name: chuan-dubboadmin-deployment namespace: chuan spec: replicas: 1 selector: matchLabels: app: chuan-dubboadmin template: metadata: labels: app: chuan-dubboadmin spec: containers: - name: chuan-dubboadmin-container image: 192.168.192.155:80/chuan/dubboadmin:v3 #command: ["/apps/tomcat/bin/run_tomcat.sh"] #imagePullPolicy: IfNotPresent imagePullPolicy: Always ports: - containerPort: 8080 protocol: TCP name: http --- kind: Service apiVersion: v1 metadata: labels: app: chuan-dubboadmin name: chuan-dubboadmin-service namespace: chuan spec: type: NodePort ports: - name: http port: 80 protocol: TCP targetPort: 8080 nodePort: 30080 selector: app: chuan-dubboadmin
[root@chuan-consumer-deployment-554f5d5874-t7clp logs]# tail -f stdout.log [08:46:35] Hello world361, response form provider: 10.200.163.88:20880 [08:46:37] Hello world362, response form provider: 10.200.163.87:20880
标签:dubbo,chuan,服务,tomcat,apps,provider,consumer,运行 来源: https://www.cnblogs.com/gxc888/p/15441229.html