Kubernetes Skywalking 部署及链路追踪Java运行程序-halo/jenkins(一)

二进制部署

安装ES

使用之前 Elasticsearch环境 
# 设置内存大小
[root@xianchaonode2 elasticsearch]# cat /usr/local/elasticsearch/config/jvm.options
-Xms2g
-Xmx2g

#启动ES
[elasticsearch@xianchaonode2 ~]$ cd /usr/local/elasticsearch/bin/
[elasticsearch@xianchaonode2 bin]$ ./elasticsearch -d

[root@xianchaonode2 elasticsearch]# netstat -nltp | grep 9200
tcp6       0      0 192.168.40.182:9200     :::*                    LISTEN      45795/java

#http://192.168.40.182:9200/
{
  "name" : "ES3",
  "cluster_name" : "Winnie-cluster1",
  "cluster_uuid" : "_na_",
  "version" : {
    "number" : "7.12.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "3186837139b9c6b6d23c3200870651f10d3343b7",
    "build_date" : "2021-04-20T20:56:39.040728659Z",
    "build_snapshot" : false,
    "lucene_version" : "8.8.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"

安装skywalking server

#安装jdk-11
rpm -qa|grep jdk
rpm -e --nodeps java-1.8.0-openjdk-devel
rpm -e --nodeps java-1.8.0-openjdk-headless
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.362.b08-1.el7_9.x86_64

yum install -y java-11-openjdk-devel.x86_64
java -version


#下载Skywalking安装包 解压 配置
[root@xianchaonode2 config]# vim config/application.yml
 89 storage:
 90   selector: ${SW_STORAGE:elasticsearch7}
127   elasticsearch7:
128     nameSpace: ${SW_NAMESPACE:""}
129     clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:192.168.40.182:9200}

#启动
./bin/startup.sh

Docker-compose 部署

[root@xianchaonode2 skywalking]# cat docker-compose.yaml
version: '3.3'
services:
  es7:
    image: elasticsearch:7.10.1
    container_name: es7
    ports:
      - 9200:9200
      - 9300:9300
    environment:
      - discovery.type=single-node #单机模式
      - bootstrap.memory_lock=true #锁定物理内存地址
      - "ES_JAVA_OPTS=-Xms1048m -Xmx1048m" #堆内存大小
      - TZ=Asia/Shanghai
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - /data/elasticsearch/data:/usr/share/elasticsearch/data

  skywalking-oap:
    image: apache/skywalking-oap-server:8.6.0-es7
    container_name: skywalking-oap
    restart: always
    depends_on:
      - es7
    links:
      - es7
    ports:
      - 11800:11800
      - 12800:12800
    environment:
      TZ: Asia/Shanghai
      SW_STORAGE: elasticsearch7
      SW_STORAGE_ES_CLUSTER_NODES: es7:9200

  skywalking-ui:
    image: apache/skywalking-ui:8.6.0
    container_name: skywalking-ui
    restart: always
    depends_on:
      - skywalking-oap
    links:
      - skywalking-oap
    ports:
      - 8080:8080
    environment:
      TZ: Asia/Shanghai
      SW_OAP_ADDRESS: skywalking-oap:12800
      
[root@xianchaonode2 skywalking]# mkdir -p /data/elasticsearch/data
[root@xianchaonode2 skywalking]# chmod -R 777 /data/elasticsearch/data
[root@xianchaonode2 skywalking]# tar zxvf docker-20.10.17-binary-install.tar.gz 
[root@xianchaonode2 skywalking]# mv docker-compose-Linux-x86_64_1.28.6 /usr/local/bin/docker-compose
[root@xianchaonode2 skywalking]# docker-compose up -d
[root@xianchaonode2 skywalking]# docker ps | grep sky
[root@xianchaonode2 skywalking]# docker logs -f ddbbd5bfc76f
2023-04-18 23:16:47,590 - org.apache.skywalking.oap.server.library.server.grpc.GRPCServer -14844 [main] INFO  [] - Bind handler MeterServiceHandlerCompat into gRPC server 0.0.0.0:11800
2023-04-18 23:16:47,729 - org.apache.skywalking.oap.server.library.server.jetty.JettyServer -14983 [main] INFO  [] - start server, host: 0.0.0.0, port: 12800
2023-04-18 23:16:47,734 - org.eclipse.jetty.server.Server -14988 [main] INFO  [] - jetty-9.4.40.v20210413; built: 2021-04-13T20:42:42.668Z; git: b881a572662e1943a14ae12e7e1207989f218b74; jvm 11.0.9+11
2023-04-18 23:16:47,791 - org.eclipse.jetty.server.handler.ContextHandler -15045 [main] INFO  [] - Started o.e.j.s.ServletContextHandler@564d9ec2{/,null,AVAILABLE}
2023-04-18 23:16:47,813 - org.eclipse.jetty.server.AbstractConnector -15067 [main] INFO  [] - Started ServerConnector@208f0007{HTTP/1.1, (http/1.1)}{0.0.0.0:12800}
2023-04-18 23:16:47,813 - org.eclipse.jetty.server.Server -15067 [main] INFO  [] - Started @15094ms
2023-04-18 23:16:47,814 - org.apache.skywalking.oap.server.core.storage.PersistenceTimer -15068 [main] INFO  [] - persistence timer start
2023-04-18 23:16:47,820 - org.apache.skywalking.oap.server.core.cache.CacheUpdateTimer -15074 [main] INFO  [] - Cache updateServiceInventory timer start


netstat -nltp | grep 8080

 

 

部署Halo 应用

#下载 Github上的 halo jar包
https://github.com/halo-dev/halo/releases/download/v1.5.4/halo-1.5.4.jar

 

部署 Skywalking agent

#下载地址
https://skywalking.apache.org/downloads/
https://archive.apache.org/dist/skywalking/java-agent/8.8.0/

[root@xianchaonode2 skywalking]# ll
total 478272
drwxrwxr-x 10 1001 1002       162 Apr 18 23:02 apache-skywalking-apm-bin-es7
-rw-r--r--  1 root root 142586408 Apr 18 23:00 apache-skywalking-apm-es7-7.0.0.tar.gz
-rw-r--r--  1 root root 176426724 Apr 18 22:40 apache-skywalking-apm-es7-8.6.0.tar.gz
-rw-r--r--  1 root root  28982315 Apr 18 23:32 apache-skywalking-java-agent-8.8.0.tgz
drwxrwxr-x 10 1012 1013       221 Oct 27  2021 skywalking-agent

[root@xianchaonode2 skywalking-agent]# tar -zxvf apache-skywalking-java-agent-8.8.0.tgz
[root@xianchaonode2 skywalking-agent]# cd skywalking-agent/
[root@xianchaonode2 skywalking-agent]# vim config/agent.config
agent.namespace=${SW_AGENT_NAMESPACE:xks}
agent.service_name=${SW_AGENT_NAME:xks-halo}
collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:192.168.40.182:11800}

[root@xianchaonode2 skywalking]# java -javaagent:./skywalking-agent/skywalking-agent.jar -jar halo-1.5.4.jar
DEBUG 2023-04-18 23:41:10:677 main AgentPackagePath : The beacon class location is jar:file:/root/skywalking/skywalking-agent/skywalking-agent.jar!/org/apache/skywalking/apm/agent/core/boot/AgentPackagePath.class.
INFO 2023-04-18 23:41:10:678 main SnifferConfigInitializer : Config file found in /root/skywalking/skywalking-agent/config/agent.config.

    __  __      __
   / / / /___ _/ /___
  / /_/ / __ `/ / __ \
 / __  / /_/ / / /_/ /
/_/ /_/\__,_/_/\____/

Version: 1.5.4
2023-04-18 23:41:14.542  INFO 100667 --- [           main] run.halo.app.Application                 : Starting Application v1.5.4 using Java 11.0.18 on xianchaonode2 with PID 100667 (/root/skywalking/halo-1.5.4.jar started by root in /root/skywalking)
2023-04-18 23:41:14.547  INFO 100667 --- [           main] run.halo.app.Application                 : No active profile set, falling back to 1 default profile: "default"
2023-04-18 23:41:16.926  INFO 100667 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2023-04-18 23:41:16.927  INFO 100667 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-04-18 23:41:18.040  INFO 100667 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 1095 ms. Found 24 JPA repository interfaces.
2023-04-18 23:41:19.981  INFO 100667 --- [           main] org.eclipse.jetty.util.log               : Logging initialized @9419ms to org.eclipse.jetty.util.log.Slf4jLog
2023-04-18 23:41:20.428  INFO 100667 --- [           main] o.s.b.w.e.j.JettyServletWebServerFactory : Server initialized with port: 8090
2023-04-18 23:41:20.446  INFO 100667 --- [           main] org.eclipse.jetty.server.Server          : jetty-9.4.45.v20220203; built: 2022-02-03T09:14:34.105Z; git: 4a0c91c0be53805e3fcffdcdcc9587d5301863db; jvm 11.0.18+10-LTS
2023-04-18 23:41:20.489  INFO 100667 --- [           main] o.e.j.s.h.ContextHandler.application     : Initializing Spring embedded WebApplicationContext
2023-04-18 23:41:20.489  INFO 100667 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 5829 ms
2023-04-18 23:41:21.827  INFO 100667 --- [           main] run.halo.app.config.HaloConfiguration    : Halo cache store load impl : [class run.halo.app.cache.InMemoryCacheStore]
2023-04-18 23:41:23.382  INFO 100667 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-04-18 23:41:23.484  INFO 100667 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.33
2023-04-18 23:41:23.569  INFO 100667 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2023-04-18 23:41:23.880  INFO 100667 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2023-04-18 23:41:24.330  INFO 100667 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2023-04-18 23:41:24.479  INFO 100667 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2023-04-18 23:41:26.026  INFO 100667 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-04-18 23:41:26.046  INFO 100667 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-04-18 23:41:27.285  INFO 100667 --- [           main] org.eclipse.jetty.server.session         : DefaultSessionIdManager workerName=node0
2023-04-18 23:41:27.285  INFO 100667 --- [           main] org.eclipse.jetty.server.session         : No SessionScavenger set, using defaults
2023-04-18 23:41:27.291  INFO 100667 --- [           main] org.eclipse.jetty.server.session         : node0 Scavenging every 600000ms
2023-04-18 23:41:27.307  INFO 100667 --- [           main] o.e.jetty.server.handler.ContextHandler  : Started o.s.b.w.e.j.JettyEmbeddedWebAppContext@787a4519{application,/,[file:///tmp/jetty-docbase.8090.12292109537266358137/, jar:file:/root/skywalking/halo-1.5.4.jar!/BOOT-INF/lib/springfox-swagger-ui-3.0.0.jar!/META-INF/resources],AVAILABLE}
2023-04-18 23:41:27.308  INFO 100667 --- [           main] org.eclipse.jetty.server.Server          : Started @16747ms
2023-04-18 23:41:29.949  INFO 100667 --- [           main] run.halo.app.handler.file.FileHandlers   : Registered 9 file handler(s)
2023-04-18 23:41:31.671  INFO 100667 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 4 endpoint(s) beneath base path '/api/admin/actuator'
2023-04-18 23:41:31.738  INFO 100667 --- [           main] o.e.j.s.h.ContextHandler.application     : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-04-18 23:41:31.739  INFO 100667 --- [           main] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2023-04-18 23:41:31.741  INFO 100667 --- [           main] o.s.web.servlet.DispatcherServlet        : Completed initialization in 2 ms
2023-04-18 23:41:31.765  INFO 100667 --- [           main] o.e.jetty.server.AbstractConnector       : Started ServerConnector@195580ba{HTTP/1.1, (http/1.1)}{0.0.0.0:8090}
2023-04-18 23:41:31.766  INFO 100667 --- [           main] o.s.b.web.embedded.jetty.JettyWebServer  : Jetty started on port(s) 8090 (http/1.1) with context path '/'
2023-04-18 23:41:31.796  INFO 100667 --- [           main] run.halo.app.Application                 : Started Application in 18.867 seconds (JVM running for 21.236)
2023-04-18 23:41:31.797  INFO 100667 --- [           main] run.halo.app.listener.StartedListener    : Starting migrate database...
2023-04-18 23:41:31.922  INFO 100667 --- [           main] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 7.15.0 by Redgate
2023-04-18 23:41:31.923  INFO 100667 --- [           main] o.f.c.i.database.base.BaseDatabaseType   : Database: jdbc:h2:file:/root/.halo//db/halo (H2 1.4)
2023-04-18 23:41:31.963  INFO 100667 --- [           main] o.f.c.i.s.JdbcTableSchemaHistory         : Repair of failed migration in Schema History table "PUBLIC"."flyway_schema_history" not necessary as table doesn't exist.
2023-04-18 23:41:31.993  INFO 100667 --- [           main] o.f.core.internal.command.DbRepair       : Successfully repaired schema history table "PUBLIC"."flyway_schema_history" (execution time 00:00.037s).
2023-04-18 23:41:32.000  INFO 100667 --- [           main] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 7.15.0 by Redgate
2023-04-18 23:41:32.015  INFO 100667 --- [           main] o.f.core.internal.command.DbValidate     : Successfully validated 6 migrations (execution time 00:00.007s)
2023-04-18 23:41:32.035  INFO 100667 --- [           main] o.f.c.i.s.JdbcTableSchemaHistory         : Creating Schema History table "PUBLIC"."flyway_schema_history" with baseline ...
2023-04-18 23:41:32.071  INFO 100667 --- [           main] o.f.core.internal.command.DbBaseline     : Successfully baselined schema with version: 1
2023-04-18 23:41:32.084  INFO 100667 --- [           main] o.f.core.internal.command.DbMigrate      : Current version of schema "PUBLIC": 1
2023-04-18 23:41:32.090  INFO 100667 --- [           main] o.f.core.internal.command.DbMigrate      : Migrating schema "PUBLIC" to version "2 - migrate 1.2.0-beta.1 to 1.2.0-beta.2"
2023-04-18 23:41:32.138  INFO 100667 --- [           main] o.f.core.internal.command.DbMigrate      : Migrating schema "PUBLIC" to version "3 - migrate 1.3.0-beta.1 to 1.3.0-beta.2"
2023-04-18 23:41:32.192  INFO 100667 --- [           main] o.f.core.internal.command.DbMigrate      : Migrating schema "PUBLIC" to version "4 - migrate 1.3.0-beta.2 to 1.3.0-beta.3"
2023-04-18 23:41:32.210  INFO 100667 --- [           main] o.f.core.internal.command.DbMigrate      : Migrating schema "PUBLIC" to version "5 - migrate remove notnull for email in comments table"
2023-04-18 23:41:32.243  INFO 100667 --- [           main] o.f.core.internal.command.DbMigrate      : Migrating schema "PUBLIC" to version "6 - migrate create contents table"
2023-04-18 23:41:32.304  INFO 100667 --- [           main] o.f.core.internal.command.DbMigrate      : Successfully applied 5 migrations to schema "PUBLIC", now at version v6 (execution time 00:00.227s)
2023-04-18 23:41:32.305  INFO 100667 --- [           main] run.halo.app.listener.StartedListener    : Migrate database succeed.
2023-04-18 23:41:32.306  INFO 100667 --- [           main] run.halo.app.listener.StartedListener    : Created backup directory: [/tmp/halo-backup]
2023-04-18 23:41:32.306  INFO 100667 --- [           main] run.halo.app.listener.StartedListener    : Created data export directory: [/tmp/halo-data-export]
2023-04-18 23:41:32.464  INFO 100667 --- [           main] run.halo.app.listener.StartedListener    : Copied theme folder from [/BOOT-INF/classes/templates/themes] to [/root/.halo/templates/themes/caicai_anatole]
2023-04-18 23:41:32.507  INFO 100667 --- [           main] run.halo.app.listener.StartedListener    : Halo started at         http://127.0.0.1:8090
2023-04-18 23:41:32.507  INFO 100667 --- [           main] run.halo.app.listener.StartedListener    : Halo admin started at   http://127.0.0.1:8090/admin
2023-04-18 23:41:32.508  INFO 100667 --- [           main] run.halo.app.listener.StartedListener    : Halo has started successfully!

 访问博客地址:http://192.168.40.182:8090/admin/index.html#/install

可以写博客

查看skywalking 链路情况

 

Tomcat运行Jenkins Skywalking监控

#tomcat war包下载
https://tomcat.apache.org/download-80.cgi

#jenkins war包下载
https://www.jenkins.io/zh/download/

#node1 安装JAVA 11
#安装jdk-11
rpm -qa|grep jdk
rpm -e --nodeps java-1.8.0-openjdk-devel
rpm -e --nodeps java-1.8.0-openjdk-headless
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.362.b08-1.el7_9.x86_64

yum install -y java-11-openjdk-devel.x86_64

[root@xianchaonode1 yum.repos.d]# java -version
openjdk version "11.0.18" 2023-01-17 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.18.0.10-1.el7_9) (build 11.0.18+10-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.18.0.10-1.el7_9) (build 11.0.18+10-LTS, mixed mode, sharing)

#部署skywalking-agent 指向 node2节点
[root@xianchaonode1 skywalking-agent]# tar -zxvf apache-skywalking-java-agent-8.8.0.tgz
[root@xianchaonode1 skywalking-agent]# cd skywalking-agent/
[root@xianchaonode1 skywalking-agent]# vim config/agent.config
agent.namespace=${SW_AGENT_NAMESPACE:xks}
agent.service_name=${SW_AGENT_NAME:xks-jenkins}
collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:192.168.40.182:11800}

#在tomcat中添加 skywalking-agent
[root@xianchaonode1 skywalking-agent]# cat /apps/apache-tomcat-8.5.87/bin/catalina.sh
CATALINA_OPTS="$CATALINA_OPTS -javaagent:/root/skywalking/skywalking-agent/skywalking-agent.jar";export CATALINA_OPTS

#启动tomcat 
[root@xianchaonode1 bin]# pwd
/apps/apache-tomcat-8.5.87/bin
[root@xianchaonode1 bin]# ./catalina.sh run #前台看 正常再后台跑
[root@xianchaonode1 bin]# ./catalina.sh start
Using CATALINA_BASE:   /apps/apache-tomcat-8.5.87
Using CATALINA_HOME:   /apps/apache-tomcat-8.5.87
Using CATALINA_TMPDIR: /apps/apache-tomcat-8.5.87/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /apps/apache-tomcat-8.5.87/bin/bootstrap.jar:/apps/apache-tomcat-8.5.87/bin/tomcat-juli.jar
Using CATALINA_OPTS:    -javaagent:/root/skywalking/skywalking-agent/skywalking-agent.jar -javaagent:/root/skywalking/skywalking-agent/skywalking-agent.jar
Tomcat started.

#访问tomcat
http://192.168.40.181:8080/

#访问Jenkins
http://192.168.40.181:8080/jenkins/

cat /root/.jenkins/secrets/initialAdminPassword
717a760b946c4debab423ac8b649dec0

 

posted @ 2023-04-19 00:43  しみずよしだ  阅读(348)  评论(0)    收藏  举报