欢迎光临
我们一直在努力

Linux 部署 BanyanDB 0.10.3 生产单机模式对接SkyWalking OAP

BanyanDB数据库生产单机安装

环境准备

软件:Apache SkyWalking BanyanDB 0.10.3 稳定版

部署模式:单机 standalone 生产模式(内嵌 etcd 元数据存储,集成 data + liaison 角色)

运行身份:低权限专用用户 banyandb,禁止 root 直接运行

BanyanDB 生产目录规范
目录路径用途权限归属
/opt/skywalking-banyandb-0.10.3 BanyanDB 程序本体(只读) root:root
/opt/banyandb 生效版本软链接,用于版本切换 root:root
/etc/banyandb/ 配置文件目录 banyandb:banyandb
/data/banyandb/ 业务数据存储目录(流、指标、链路、元数据) banyandb:banyandb
/var/log/banyandb/ 运行日志目录 banyandb:banyandb
/usr/local/bin/ 全局命令软链接,方便终端调用 root:root
系统优化

BanyanDB 作为时序数据库,需调高文件描述符与进程数限制,避免高并发下资源不足。

# 写入全局资源限制配置
cat << 'EOF' | sudo tee -a /etc/security/limits.conf
* soft nofile 800000
* hard nofile 800000
* soft nproc 8096
* hard nproc 8096
* soft memlock unlimited
* hard memlock unlimited
EOF

安全运行

创建专用运行用户,生产环境禁止以 root 运行服务,创建无登录权限的专用运行用户

sudo groupadd banyandb
sudo useradd -g banyandb -s /sbin/nologin -M banyandb

创建业务目录结构,按分层规范创建所有目录并授权:

# 数据目录(含各数据类型子目录)
sudo mkdir -p /data/banyandb/{stream,measure,trace,property,metadata}

# 配置与日志目录
sudo mkdir -p /etc/banyandb
sudo mkdir -p /var/log/banyandb

# 统一授权给运行用户
sudo chown -R banyandb:banyandb /data/banyandb
sudo chown -R banyandb:banyandb /etc/banyandb
sudo chown -R banyandb:banyandb /var/log/banyandb

sudo mkdir -p /opt/banyandb
sudo mkdir -p /opt/bydbctl

标准部署

软件下载:

https://dlcdn.apache.org/skywalking/banyandb/0.10.3/skywalking-banyandb-0.10.3-banyand.tgz

https://dlcdn.apache.org/skywalking/banyandb/0.10.3/skywalking-banyandb-0.10.3-bydbctl.tgz

将程序包解压到 /opt 目录,保留版本号目录,便于后续多版本共存与回滚:

# 解压服务端与 CLI 工具到 /opt
sudo tar -zxvf skywalking-banyandb-0.10.3-banyand.tgz -C /opt/banyandb
sudo tar -zxvf skywalking-banyandb-0.10.3-bydbctl.tgz -C /opt/bydbctl

# 验证解压结果
ls /opt | grep skywalking

创建无版本号软链接,升级时仅需切换软链接,无需修改服务配置;同时将命令加入系统 PATH:

# ========== x86_64 架构执行以下命令 ==========
# 服务端二进制全局软链接
sudo ln -s /opt/banyandb/bin/banyand-server-static-linux-amd64 /usr/local/bin/banyand
# CLI 工具全局软链接
sudo ln -s /opt/bydbctl/bin/bydbctl-cli-static-linux-amd64 /usr/local/bin/bydbctl

# ========== ARM64 架构执行以下命令 ==========
# sudo ln -s /opt/banyandb/bin/banyand-server-static-linux-arm64 /usr/local/bin/banyand
# sudo ln -s /opt/bydbctl/bin/bydbctl-cli-static-linux-arm64 /usr/local/bin/bydbctl

# 添加执行权限
sudo chmod +x /usr/local/bin/banyand
sudo chmod +x /usr/local/bin/bydbctl

结果验证:执行版本命令,确认安装成功

banyand –version
bydbctl –version

生产单机运维配置
  • 编写环境变量配置文件:
  • 创建 /etc/banyandb/banyand.env 配置文件:

    cat << 'EOF' | sudo tee /etc/banyandb/banyand.env
    # ===================== 网络配置 =====================
    # gRPC 服务监听地址(SkyWalking OAP 对接端口)
    BYDB_GRPC_HOST=0.0.0.0
    BYDB_GRPC_PORT=17912
    # HTTP/UI 与指标接口
    BYDB_HTTP_HOST=0.0.0.0
    BYDB_HTTP_PORT=17913
    # 单条消息最大接收大小
    BYDB_MAX_RECV_MSG_SIZE=64MiB

    # ===================== 数据存储路径 =====================
    BYDB_STREAM_ROOT_PATH=/data/banyandb
    BYDB_MEASURE_ROOT_PATH=/data/banyandb
    BYDB_TRACE_ROOT_PATH=/data/banyandb
    BYDB_PROPERTY_ROOT_PATH=/data/banyandb
    BYDB_METADATA_ROOT_PATH=/data/banyandb/metadata

    # ===================== 内存与性能保护 =====================
    # 内存使用百分比阈值,超阈值自动拒绝查询,防止 OOM
    BYDB_ALLOWED_PERCENT=70
    # 慢查询阈值,超过则记录慢查询日志
    BYDB_BYDBQL_SLOW_QUERY_THRESHOLD=5s
    # 查询预编译缓存大小
    BYDB_BYDBQL_PREPARED_CACHE_SIZE=8000

    # ===================== 内嵌 etcd 元数据配置 =====================
    # 自动压缩模式:周期压缩
    BYDB_ETCD_AUTO_COMPACTION_MODE=periodic
    # 压缩保留时长
    BYDB_ETCD_AUTO_COMPACTION_RETENTION=1h
    # 每日自动碎片整理
    BYDB_ETCD_DEFRAG_CRON=@daily
    # etcd 后端存储配额
    BYDB_ETCD_QUOTA_BACKEND_BYTES=8GiB

    # ===================== 数据刷盘超时 =====================
    BYDB_STREAM_FLUSH_TIMEOUT=1s
    BYDB_MEASURE_FLUSH_TIMEOUT=5s
    BYDB_TRACE_FLUSH_TIMEOUT=1s
    EOF

    配置文件授权,确保运行用户可读配置文件:

    sudo chown banyandb:banyandb /etc/banyandb/banyand.env
    sudo chmod 640 /etc/banyandb/banyand.env

  • Systemd 系统服务部署
  • 通过 Systemd 托管服务,实现开机自启、异常重启、资源限制与安全加固。

    创建 /etc/systemd/system/banyandb.service:

    cat << 'EOF' | sudo tee /etc/systemd/system/banyandb.service
    [Unit]
    Description=Apache SkyWalking BanyanDB Server
    After=network.target
    Wants=network.target

    [Service]
    Type=simple
    # 运行身份(低权限用户)
    User=banyandb
    Group=banyandb
    WorkingDirectory=/data/banyandb

    # 加载环境变量配置
    EnvironmentFile=/etc/banyandb/banyand.env
    # 启动命令(standalone 单机模式)
    ExecStart=/usr/local/bin/banyand standalone

    # 重启策略:异常自动重启,间隔 5 秒,1 分钟内最多重启 3 次
    Restart=always
    RestartSec=5s
    StartLimitInterval=60s
    StartLimitBurst=3

    # 资源限制(优先级高于 limits.conf,服务级生效)
    LimitNOFILE=800000
    LimitNPROC=8096
    LimitMEMLOCK=infinity

    # ===================== 安全加固 =====================
    # 私有临时目录
    PrivateTmp=true
    # 禁止获取新权限
    NoNewPrivileges=true
    # 只读挂载系统目录
    ProtectSystem=full
    # 禁止访问用户家目录
    ProtectHome=true
    # 仅允许写入指定目录
    ReadWritePaths=/data/banyandb /var/log/banyandb

    # 日志输出到系统 journal
    StandardOutput=journal
    StandardError=journal
    SyslogIdentifier=banyandb

    [Install]
    WantedBy=multi-user.target
    EOF

  • 重载系统服务配置
  • sudo systemctl daemon-reload

  • 启动服务并设置开机自启
  • # 设置开机自启
    sudo systemctl enable banyandb

    # 启动服务
    sudo systemctl start banyandb

  • 健康状态接口验证
  • curl http://127.0.0.1:17913/api/healthz

    返回结果:SERVING

    CLI 管理工具验证

    bydbctl health –addr http://127.0.0.1:17913

    返回结果:

    Using config file: /home/kylin/.bydbctl.yaml
    SERVING

  • 防火墙配置
  • # 放行 gRPC 端口(SkyWalking OAP 接入必须)
    sudo firewall-cmd –permanent –add-port=17912/tcp

    # 放行 HTTP/UI 与指标端口(按需开放,建议限制 IP 段)
    sudo firewall-cmd –permanent –add-port=17913/tcp

    # 重载防火墙规则
    sudo firewall-cmd –reload

    # 验证规则
    sudo firewall-cmd –list-ports

  • 日志轮转配置
  • 配置 logrotate 自动轮转日志,避免磁盘占满:

    cat << 'EOF' | sudo tee /etc/logrotate.d/banyandb
    /var/log/banyandb/*.log {
    daily
    rotate 30
    compress
    delaycompress
    missingok
    notifempty
    copytruncate
    }
    EOF

  • 监控指标接入(可选)
  • BanyanDB 内置 Prometheus 指标端点,可接入监控系统:

    • 指标地址:http://<服务器IP>:17913/metrics
    • 核心监控项:写入 QPS、查询延迟、磁盘使用率、内存占用、etcd 健康状态

    生产单机安装Skywalking并对接BanyanDB

    Skywalking数据库生产单机安装

    先进行文件的修改,再创建用户管理权限运行

    skywalking服务下载:https://dlcdn.apache.org/skywalking/10.4.0/apache-skywalking-apm-10.4.0-bin.tar.gz

    sudo tar -xzvf apache-skywalking-apm-10.4.0-bin.tar.gz -C /opt

    sudo mv /opt/apache-skywalking-apm-bin/ /opt/skywalking

  • 修改/opt/skywalking/config/bydb.yml文件
  • # Licensed to the Apache Software Foundation (ASF) under one or more
    # contributor license agreements. See the NOTICE file distributed with
    # this work for additional information regarding copyright ownership.
    # The ASF licenses this file to You under the Apache License, Version 2.0
    # (the "License"); you may not use this file except in compliance with
    # the License. You may obtain a copy of the License at
    #
    # http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.

    global:
    # Targets is the list of BanyanDB servers, separated by commas.
    # Each target is a BanyanDB server in the format of `host:port`.
    # If BanyanDB is deployed as a standalone server, the target should be the IP address or domain name and port of the BanyanDB server.
    # If BanyanDB is deployed in a cluster, the targets should be the IP address or domain name and port of the `liaison` nodes, separated by commas.
    targets: ${SW_STORAGE_BANYANDB_TARGETS:127.0.0.1:17912}
    # The maximum number of records in a bulk write request.
    # A larger value can improve write performance but also increases OAP and BanyanDB Server memory usage.
    maxBulkSize: ${SW_STORAGE_BANYANDB_MAX_BULK_SIZE:20000}
    # The minimum seconds between two bulk flushes.
    # If the data in a bulk is less than maxBulkSize, the data will be flushed after this period.
    # If the data in a bulk exceeds maxBulkSize, the data will be flushed immediately.
    # A larger value can reduce write pressure on BanyanDB Server but increase data latency.
    flushInterval: ${SW_STORAGE_BANYANDB_FLUSH_INTERVAL:1}
    # The timeout in seconds for a bulk flush.
    flushTimeout: ${SW_STORAGE_BANYANDB_FLUSH_TIMEOUT:10}
    # The number of threads that write data to BanyanDB concurrently.
    # A higher value can improve write performance but also increases CPU usage on both OAP and BanyanDB Server.
    concurrentWriteThreads: ${SW_STORAGE_BANYANDB_CONCURRENT_WRITE_THREADS:6}
    # The maximum size of the dataset when the OAP loads cache, such as network aliases.
    resultWindowMaxSize: ${SW_STORAGE_BANYANDB_QUERY_MAX_WINDOW_SIZE:10000}
    # The maximum size of metadata per query.
    metadataQueryMaxSize: ${SW_STORAGE_BANYANDB_QUERY_MAX_SIZE:10000}
    # The maximum number of trace segments per query.
    segmentQueryMaxSize: ${SW_STORAGE_BANYANDB_QUERY_SEGMENT_SIZE:200}
    # The maximum number of profile task queries in a request.
    profileTaskQueryMaxSize: ${SW_STORAGE_BANYANDB_QUERY_PROFILE_TASK_SIZE:200}
    # The batch size for querying profile data.
    profileDataQueryBatchSize: ${SW_STORAGE_BANYANDB_QUERY_PROFILE_DATA_BATCH_SIZE:100}
    asyncProfilerTaskQueryMaxSize: ${SW_STORAGE_BANYANDB_ASYNC_PROFILER_TASK_QUERY_MAX_SIZE:200}
    pprofTaskQueryMaxSize: ${SW_STORAGE_BANYANDB_PPROF_TASK_QUERY_MAX_SIZE:200}
    user: ${SW_STORAGE_BANYANDB_USER:""}
    password: ${SW_STORAGE_BANYANDB_PASSWORD:""}
    # If the BanyanDB server is configured with TLS, configure the TLS cert file path and enable TLS connection.
    sslTrustCAPath: ${SW_STORAGE_BANYANDB_SSL_TRUST_CA_PATH:""}
    # Cleanup TopN rules in BanyanDB server that are not configured in the bydb-topn.yml config.
    cleanupUnusedTopNRules: ${SW_STORAGE_BANYANDB_CLEANUP_UNUSED_TOPN_RULES:true}
    # The namespace in BanyanDB to store the data of OAP, if not set, the default is "sw".
    # OAP will create BanyanDB Groups using the format of "{namespace}_{group name}", such as "sw_records".
    namespace: ${SW_NAMESPACE:"sw"}
    # The compatible server API versions of BanyanDB.
    # The compatible BanyanDB Server version number can be found via the [API versions mapping](https://skywalking.apache.org/docs/skywalking-banyandb/latest/installation/versions/).
    compatibleServerApiVersions: ${SW_STORAGE_BANYANDB_COMPATIBLE_SERVER_API_VERSIONS:"0.10"}

    groups:
    # The group settings of record.
    # – "shardNum": Number of shards in the group. Shards are the basic units of data storage in BanyanDB. Data is distributed across shards based on the hash value of the series ID.
    # Refer to the [BanyanDB Shard](https://skywalking.apache.org/docs/skywalking-banyandb/latest/concept/clustering/#52-data-sharding) documentation for more details.
    # – "segmentInterval": Interval in days for creating a new segment. Segments are time-based, allowing efficient data retention and querying. `SI` stands for Segment Interval.
    # – "ttl": Time-to-live for the data in the group, in days. Data exceeding the TTL will be deleted.
    # – "replicas": Number of replicas for the group/stage. Replicas are used for data redundancy and high availability, a value of 0 means no replicas, while a value of 1 means one primary shard and one replica, higher values indicate more replicas.
    #
    # For more details on setting `segmentInterval` and `ttl`, refer to the [BanyanDB TTL](https://skywalking.apache.org/docs/main/latest/en/banyandb/ttl) documentation.

    # The "records" section defines settings for normal datasets not specified in records.
    # Each dataset will be grouped under a single group named "records".
    records:
    # The settings for the default "hot" stage.
    shardNum: ${SW_STORAGE_BANYANDB_RECORDS_SHARD_NUM:1}
    segmentInterval: ${SW_STORAGE_BANYANDB_RECORDS_SI_DAYS:1}
    # 数据保留天数
    ttl: ${SW_STORAGE_BANYANDB_RECORDS_TTL_DAYS:3}
    replicas: ${SW_STORAGE_BANYANDB_RECORDS_REPLICAS:0}
    # If the "warm" stage is enabled, the data will be moved to the "warm" stage after the TTL of the "hot" stage.
    # If the "cold" stage is enabled and "warm" stage is disabled, the data will be moved to the "cold" stage after the TTL of the "hot" stage.
    # If both "warm" and "cold" stages are enabled, the data will be moved to the "warm" stage after the TTL of the "hot" stage, and then to the "cold" stage after the TTL of the "warm" stage.
    # OAP will query the data from the "hot and warm" stage by default if the "warm" stage is enabled.
    enableWarmStage: ${SW_STORAGE_BANYANDB_RECORDS_ENABLE_WARM_STAGE:false}
    enableColdStage: ${SW_STORAGE_BANYANDB_RECORDS_ENABLE_COLD_STAGE:false}
    # The settings for the "warm" stage.
    warm:
    shardNum: ${SW_STORAGE_BANYANDB_RECORDS_WARM_SHARD_NUM:1}
    segmentInterval: ${SW_STORAGE_BANYANDB_RECORDS_WARM_SI_DAYS:2}
    ttl: ${SW_STORAGE_BANYANDB_RECORDS_WARM_TTL_DAYS:7}
    replicas: ${SW_STORAGE_BANYANDB_RECORDS_WARM_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_RECORDS_WARM_NODE_SELECTOR:"type=warm"}
    # The settings for the "cold" stage.
    cold:
    shardNum: ${SW_STORAGE_BANYANDB_RECORDS_COLD_SHARD_NUM:1}
    segmentInterval: ${SW_STORAGE_BANYANDB_RECORDS_COLD_SI_DAYS:3}
    ttl: ${SW_STORAGE_BANYANDB_RECORDS_COLD_TTL_DAYS:30}
    replicas: ${SW_STORAGE_BANYANDB_RECORDS_COLD_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_RECORDS_COLD_NODE_SELECTOR:"type=cold"}
    trace:
    shardNum: ${SW_STORAGE_BANYANDB_TRACE_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_TRACE_SI_DAYS:1}
    ttl: ${SW_STORAGE_BANYANDB_TRACE_TTL_DAYS:3}
    replicas: ${SW_STORAGE_BANYANDB_TRACE_REPLICAS:0}
    enableWarmStage: ${SW_STORAGE_BANYANDB_TRACE_ENABLE_WARM_STAGE:false}
    enableColdStage: ${SW_STORAGE_BANYANDB_TRACE_ENABLE_COLD_STAGE:false}
    warm:
    shardNum: ${SW_STORAGE_BANYANDB_TRACE_WARM_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_TRACE_WARM_SI_DAYS:1}
    ttl: ${SW_STORAGE_BANYANDB_TRACE_WARM_TTL_DAYS:7}
    replicas: ${SW_STORAGE_BANYANDB_TRACE_WARM_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_TRACE_WARM_NODE_SELECTOR:"type=warm"}
    cold:
    shardNum: ${SW_STORAGE_BANYANDB_TRACE_COLD_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_TRACE_COLD_SI_DAYS:1}
    ttl: ${SW_STORAGE_BANYANDB_TRACE_COLD_TTL_DAYS:30}
    replicas: ${SW_STORAGE_BANYANDB_TRACE_COLD_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_TRACE_COLD_NODE_SELECTOR:"type=cold"}
    zipkinTrace:
    shardNum: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_SI_DAYS:1}
    ttl: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_TTL_DAYS:3}
    replicas: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_REPLICAS:0}
    enableWarmStage: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_ENABLE_WARM_STAGE:false}
    enableColdStage: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_ENABLE_COLD_STAGE:false}
    warm:
    shardNum: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_WARM_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_WARM_SI_DAYS:1}
    ttl: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_WARM_TTL_DAYS:7}
    replicas: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_WARM_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_WARM_NODE_SELECTOR:"type=warm"}
    cold:
    shardNum: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_COLD_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_COLD_SI_DAYS:1}
    ttl: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_COLD_TTL_DAYS:30}
    replicas: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_COLD_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_ZIPKIN_TRACE_COLD_NODE_SELECTOR:"type=cold"}
    recordsLog:
    shardNum: ${SW_STORAGE_BANYANDB_LOG_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_LOG_SI_DAYS:1}
    ttl: ${SW_STORAGE_BANYANDB_LOG_TTL_DAYS:3}
    replicas: ${SW_STORAGE_BANYANDB_LOG_REPLICAS:0}
    enableWarmStage: ${SW_STORAGE_BANYANDB_LOG_ENABLE_WARM_STAGE:false}
    enableColdStage: ${SW_STORAGE_BANYANDB_LOG_ENABLE_COLD_STAGE:false}
    warm:
    shardNum: ${SW_STORAGE_BANYANDB_LOG_WARM_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_LOG_WARM_SI_DAYS:1}
    ttl: ${SW_STORAGE_BANYANDB_LOG_WARM_TTL_DAYS:7}
    replicas: ${SW_STORAGE_BANYANDB_LOG_WARM_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_LOG_WARM_NODE_SELECTOR:"type=warm"}
    cold:
    shardNum: ${SW_STORAGE_BANYANDB_LOG_COLD_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_LOG_COLD_SI_DAYS:1}
    ttl: ${SW_STORAGE_BANYANDB_LOG_COLD_TTL_DAYS:30}
    replicas: ${SW_STORAGE_BANYANDB_LOG_COLD_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_LOG_COLD_NODE_SELECTOR:"type=cold"}
    recordsBrowserErrorLog:
    shardNum: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_SI_DAYS:1}
    ttl: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_TTL_DAYS:3}
    replicas: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_REPLICAS:0}
    enableWarmStage: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_ENABLE_WARM_STAGE:false}
    enableColdStage: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_ENABLE_COLD_STAGE:false}
    warm:
    shardNum: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_WARM_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_WARM_SI_DAYS:1}
    ttl: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_WARM_TTL_DAYS:7}
    replicas: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_WARM_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_WARM_NODE_SELECTOR:"type=warm"}
    cold:
    shardNum: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_COLD_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_COLD_SI_DAYS:1}
    ttl: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_COLD_TTL_DAYS:30}
    replicas: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_COLD_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_BROWSER_ERROR_LOG_COLD_NODE_SELECTOR:"type=cold"}
    # The group settings of metrics.
    #
    # OAP stores metrics based its granularity.
    # Valid values are "day", "hour", and "minute". That means metrics will be stored in the three separate groups.
    # Non-"minute" are governed by the "core.downsampling" setting.
    # For example, if "core.downsampling" is set to "hour", the "hour" will be used, while "day" are ignored.
    metricsMinute:
    shardNum: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_SI_DAYS:1}
    ttl: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_TTL_DAYS:7}
    replicas: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_REPLICAS:0}
    enableWarmStage: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_ENABLE_WARM_STAGE:false}
    enableColdStage: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_ENABLE_COLD_STAGE:false}
    warm:
    shardNum: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_WARM_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_WARM_SI_DAYS:3}
    ttl: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_WARM_TTL_DAYS:15}
    replicas: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_WARM_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_WARM_NODE_SELECTOR:"type=warm"}
    cold:
    shardNum: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_COLD_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_COLD_SI_DAYS:5}
    ttl: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_COLD_TTL_DAYS:60}
    replicas: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_COLD_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_METRICS_MINUTE_COLD_NODE_SELECTOR:"type=cold"}
    metricsHour:
    shardNum: ${SW_STORAGE_BANYANDB_METRICS_HOUR_SHARD_NUM:1}
    segmentInterval: ${SW_STORAGE_BANYANDB_METRICS_HOUR_SI_DAYS:5}
    ttl: ${SW_STORAGE_BANYANDB_METRICS_HOUR_TTL_DAYS:15}
    replicas: ${SW_STORAGE_BANYANDB_METRICS_HOUR_REPLICAS:0}
    enableWarmStage: ${SW_STORAGE_BANYANDB_METRICS_HOUR_ENABLE_WARM_STAGE:false}
    enableColdStage: ${SW_STORAGE_BANYANDB_METRICS_HOUR_ENABLE_COLD_STAGE:false}
    warm:
    shardNum: ${SW_STORAGE_BANYANDB_METRICS_HOUR_WARM_SHARD_NUM:1}
    segmentInterval: ${SW_STORAGE_BANYANDB_METRICS_HOUR_WARM_SI_DAYS:7}
    ttl: ${SW_STORAGE_BANYANDB_METRICS_HOUR_WARM_TTL_DAYS:30}
    replicas: ${SW_STORAGE_BANYANDB_METRICS_HOUR_WARM_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_METRICS_HOUR_WARM_NODE_SELECTOR:"type=warm"}
    cold:
    shardNum: ${SW_STORAGE_BANYANDB_METRICS_HOUR_COLD_SHARD_NUM:1}
    segmentInterval: ${SW_STORAGE_BANYANDB_METRICS_HOUR_COLD_SI_DAYS:15}
    ttl: ${SW_STORAGE_BANYANDB_METRICS_HOUR_COLD_TTL_DAYS:120}
    replicas: ${SW_STORAGE_BANYANDB_METRICS_HOUR_COLD_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_METRICS_HOUR_COLD_NODE_SELECTOR:"type=cold"}
    metricsDay:
    shardNum: ${SW_STORAGE_BANYANDB_METRICS_DAY_SHARD_NUM:1}
    segmentInterval: ${SW_STORAGE_BANYANDB_METRICS_DAY_SI_DAYS:15}
    ttl: ${SW_STORAGE_BANYANDB_METRICS_DAY_TTL_DAYS:15}
    replicas: ${SW_STORAGE_BANYANDB_METRICS_DAY_REPLICAS:0}
    enableWarmStage: ${SW_STORAGE_BANYANDB_METRICS_DAY_ENABLE_WARM_STAGE:false}
    enableColdStage: ${SW_STORAGE_BANYANDB_METRICS_DAY_ENABLE_COLD_STAGE:false}
    warm:
    shardNum: ${SW_STORAGE_BANYANDB_METRICS_DAY_WARM_SHARD_NUM:1}
    segmentInterval: ${SW_STORAGE_BANYANDB_METRICS_DAY_WARM_SI_DAYS:15}
    ttl: ${SW_STORAGE_BANYANDB_METRICS_DAY_WARM_TTL_DAYS:30}
    replicas: ${SW_STORAGE_BANYANDB_METRICS_DAY_WARM_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_METRICS_DAY_WARM_NODE_SELECTOR:"type=warm"}
    cold:
    shardNum: ${SW_STORAGE_BANYANDB_METRICS_DAY_COLD_SHARD_NUM:1}
    segmentInterval: ${SW_STORAGE_BANYANDB_METRICS_DAY_COLD_SI_DAYS:15}
    ttl: ${SW_STORAGE_BANYANDB_METRICS_DAY_COLD_TTL_DAYS:120}
    replicas: ${SW_STORAGE_BANYANDB_METRICS_DAY_COLD_REPLICAS:0}
    nodeSelector: ${SW_STORAGE_BANYANDB_METRICS_DAY_COLD_NODE_SELECTOR:"type=cold"}
    # If the metrics is marked as "index_mode", the metrics will be stored in the "metadata" group.
    # The "metadata" group is designed to store metrics that are used for indexing without value columns.
    # Such as `service_traffic`, `network_address_alias`, etc.
    # "index_mode" requires BanyanDB *0.8.0* or later.
    metadata:
    shardNum: ${SW_STORAGE_BANYANDB_METADATA_SHARD_NUM:2}
    segmentInterval: ${SW_STORAGE_BANYANDB_METADATA_SI_DAYS:15}
    ttl: ${SW_STORAGE_BANYANDB_METADATA_TTL_DAYS:15}
    replicas: ${SW_STORAGE_BANYANDB_METADATA_REPLICAS:0}

    # The group settings of property, such as UI and profiling.
    property:
    shardNum: ${SW_STORAGE_BANYANDB_PROPERTY_SHARD_NUM:1}
    replicas: ${SW_STORAGE_BANYANDB_PROPERTY_REPLICAS:0}

  • 避免服务端口冲突,修改端口:/opt/skywalking/webapp/application.yml
  • # 避免8080端口冲突改成9000端口
    serverPort: ${SW_SERVER_PORT:-9000}

    # Comma seperated list of OAP addresses.
    oapServices: ${SW_OAP_ADDRESS:-http://localhost:12800}

    zipkinServices: ${SW_ZIPKIN_ADDRESS:-http://localhost:9412}

  • 日志滚动配置(避免打满磁盘)
  • 编辑 /opt/skywalking/config/log4j2.xml,修改滚动策略为按天 + 大小限制,保留 10 天:

    <?xml version="1.0" encoding="UTF-8"?>
    <!–
    ~ Licensed to the Apache Software Foundation (ASF) under one or more
    ~ contributor license agreements. See the NOTICE file distributed with
    ~ this work for additional information regarding copyright ownership.
    ~ The ASF licenses this file to You under the Apache License, Version 2.0
    ~ (the "License"); you may not use this file except in compliance with
    ~ the License. You may obtain a copy of the License at
    ~
    ~ http://www.apache.org/licenses/LICENSE-2.0
    ~
    ~ Unless required by applicable law or agreed to in writing, software
    ~ distributed under the License is distributed on an "AS IS" BASIS,
    ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    ~ See the License for the specific language governing permissions and
    ~ limitations under the License.
    ~
    –>

    <Configuration status="info">
    <Properties>
    <Property name="log-path">${sys:oap.logDir}</Property>
    </Properties>
    <Appenders>
    <RollingFile name="RollingFile" fileName="${log-path}/skywalking-oap-server.log"
    filePattern="${log-path}/skywalking-oap-server-%d{yyyy-MM-dd}-%i.log">

    <PatternLayout>
    <pattern>%d – %c – %L [%t] %-5p %x – %m%n</pattern>
    </PatternLayout>
    <Policies>
    <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
    <SizeBasedTriggeringPolicy size="100 MB"/>
    </Policies>
    <DefaultRolloverStrategy max="10">
    <Delete basePath="${log-path}" maxDepth="1">
    <IfFileName glob="*.log.gz"/>
    <IfLastModified age="10d"/>
    </Delete>
    </DefaultRolloverStrategy>
    </RollingFile>
    <Console name="Console" target="SYSTEM_OUT">
    <PatternLayout>
    <pattern>%m%n</pattern>
    </PatternLayout>
    <MarkerFilter marker="Console" onMatch="ACCEPT" onMismatch="DENY"/>
    </Console>
    </Appenders>
    <Loggers>
    <logger name="org.apache.zookeeper" level="INFO"/>
    <logger name="io.grpc.netty" level="INFO"/>
    <Logger name="org.apache.skywalking.oap.server.library.server.grpc.GRPCServer" level="INFO" additivity="false">
    <AppenderRef ref="Console"/>
    </Logger>
    <Root level="info">
    <AppenderRef ref="RollingFile"/>
    <AppenderRef ref="Console"/>
    </Root>
    </Loggers>
    </Configuration>

    在 /opt/skywalking/bin 目录下创建 setenv.sh,自定义 JVM 参数:

    #!/bin/bash
    # 堆内存:建议设为系统可用内存的40%,8G内存建议设为3G,必须Xms=Xmx避免堆伸缩
    JAVA_OPTS="-Xms3g -Xmx3g"
    # 元空间大小
    JAVA_OPTS="${JAVA_OPTS} -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m"
    # G1垃圾回收器,生产环境标配,控制最大暂停时间
    JAVA_OPTS="${JAVA_OPTS} -XX:+UseG1GC -XX:MaxGCPauseMillis=200"
    # GC日志输出,便于排查OOM与性能问题
    JAVA_OPTS="${JAVA_OPTS} -Xlog:gc*:file=/opt/skywalking/logs/gc.log:time,uptime:filecount=10,filesize=100M"
    # OOM 时生成堆转储,用于定位问题
    JAVA_OPTS="${JAVA_OPTS} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/skywalking/logs/heapdump.hprof"

    系统参数调优
  • 文件句柄限制
  • # 写入全局资源限制配置
    cat << 'EOF' | sudo tee -a /etc/security/limits.conf
    skywalking soft nofile 65536
    skywalking hard nofile 65536
    skywalking soft nproc 65536
    skywalking hard nproc 65536
    EOF

  • 网络内核参数优化
  • 编辑 /etc/sysctl.conf,追加高并发适配参数:

    cat << 'EOF' | sudo tee -a /etc/sysctl.conf
    # TCP连接复用,减少TIME_WAIT
    net.ipv4.tcp_tw_reuse=1
    net.ipv4.tcp_fin_timeout=30
    # 最大监听队列长度
    net.core.somaxconn=1024
    # 扩大临时端口范围
    net.ipv4.ip_local_port_range=1024 65535
    EOF

    执行 sudo sysctl -p 生效。

    安全配置

    创建专用运行用户,禁止 root 直接运行服务

    sudo useradd -s /sbin/nologin -M skywalking

    # 授权给专用用户
    sudo chown -R skywalking:skywalking /opt/skywalking
    # 授权
    sudo chmod +x /opt/skywalking/bin/setenv.sh
    sudo chown skywalking:skywalking /opt/skywalking/bin/setenv.sh

    生产单机运维配置
  • 配置 systemd 开机自启
  • 创建 sudo vim /etc/systemd/system/skywalking-oap.service

    [Unit]
    Description=SkyWalking OAP Server
    After=network.target remote-fs.target

    [Service]
    Type=simple
    User=skywalking
    Group=skywalking
    Environment="JAVA_HOME=/usr/local/java/jdk-21.0.12"
    ExecStart=/opt/skywalking/bin/oapService.sh
    ExecStop=/opt/skywalking/bin/oapService.sh stop
    Restart=on-failure
    RestartSec=5
    # 延长启动超时时间
    TimeoutStartSec=300
    LimitNOFILE=65536
    LimitNPROC=65536

    [Install]
    WantedBy=multi-user.target

    注意:JAVA_HOME 替换为你服务器实际 JDK 路径。

    创建 sudo vim /etc/systemd/system/skywalking-ui.service

    [Unit]
    Description=SkyWalking UI
    After=skywalking-oap.service

    [Service]
    Type=simple
    User=skywalking
    Group=skywalking
    Environment="JAVA_HOME=/usr/local/java/jdk-21.0.12"
    Environment=SW_SERVER_PORT=9000
    ExecStart=/opt/skywalking/bin/webappService.sh
    ExecStop=/opt/skywalking/bin/webappService.sh stop
    Restart=on-failure
    RestartSec=5
    TimeoutStartSec=120

    [Install]
    WantedBy=multi-user.target

  • 启动服务并设置开机自启
  • sudo systemctl daemon-reload
    # 启动OAP(首次启动会初始化BanyanDB表结构,耗时1-3分钟属正常)
    sudo systemctl start skywalking-oap
    # 设置开机自启
    sudo systemctl enable skywalking-oap skywalking-ui
    # 启动UI(OAP启动成功后再启UI)
    sudo systemctl start skywalking-ui

  • 部署验证与健康检查
  • 服务状态检查

    # 检查服务运行状态
    systemctl status skywalking-oap
    systemctl status skywalking-ui

  • firewalld 基础全量放行(内网环境配置)
  • # 放行 Agent 上报端口 11800
    sudo firewall-cmd –permanent –add-port=11800/tcp
    # 放行 OAP HTTP 端口 12800
    sudo firewall-cmd –permanent –add-port=12800/tcp
    # 放行 UI 控制台端口 8080
    # firewall-cmd –permanent –add-port=8080/tcp

    # 放行 UI 控制台端口 9000
    sudo firewall-cmd –permanent –add-port=9000/tcp

    # 重载使配置生效
    sudo firewall-cmd –reload

    赞(0)
    未经允许不得转载:171主机测评 » Linux 部署 BanyanDB 0.10.3 生产单机模式对接SkyWalking OAP
    分享到: 更多 (0)

    评论 抢沙发

    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址