Elasticsearch是一个开源的分布式、RESTful 风格的搜索和数据分析引擎
请在ElasticSearch官网下载8.1.2版本的ElasticSearch
官网下载地址:https://www.elastic.co/cn/downloads/past-releases/elasticsearch-8-1-2

日志中心是收集、缓冲、存储、展示的标准日志中心架构,收集各应用产生的本地日志数据,进行汇总,可以进行应用日志查看,检索,链路分析。

使用APIGateway版本时,请务必先安装 、配置 ElasticSearch。
本章节均已单实例部署进行介绍,如用户需要部署集群模式,请参考官方文档。
如下安装包配置文件内容只列出关键配置项,其余内容省略(均是缺省配置值),详情请参考官方文档。
如果想用 Kibana 监控APIGateway日志,以下是 APIGateway 的日志说明
primeton_esb_log_*:交易日志
primeton_esb_mq_state_*MQ状态
primeton_esb_node_log_*:调用链日志
primeton_esb_system_resource_*:系统资源(CPU\内存)

primeton_esb_system_thread_*:全局线程池
primeton_esb_thread_*:模型使用的线程池

# Linux环境

  1. 执行如下命令,将压缩包“elasticsearch-8.1.2-linux-x86_64.tar.gz”拷贝到Linux服务器的“/usr/local/elasticsearch”目录中。
# mkdir -p /usr/local/elasticsearch

# cd /usr/local/elasticsearch

# tar -zxvf elasticsearch-8.1.2-linux-x86_64.tar.gz
  1. Elasticsearch可以执行脚本文件,为了安全性,默认不允许通过 root 用户启动服务。我们需要新创建用户名和用户组启动服务。
# groupadd es

# useradd es -g es

# chown -R es:es /usr/local/elasticsearch/elasticsearch-8.1.2

# su es
  1. 在“elasticsearch-8.1.2/bin”目录下,执行如下命令,启动服务。
$ ./elasticsearch -d
  1. 修改用户名密码,请在"elasticsearch-8.1.2/bin”目录下执行./elasticsearch-reset-password -u elastic -i命令,其中elastic为用户名,设置密码为primeton000000
  2. 打开浏览器,输入https://[ip]:9200,ip为安装elasticsearch的服务器的实际IP地址,显示如下界面:
  3. 输入用户名和密码:elastic/primeton000000
    注意:
    1.若要修改访问端口,访问地址等信息,请在8.1.2/config”目录下,参照如下表格参数说明修改“elasticsearch.yml”文件。
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
#network.host: 192.168.0.1
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
#action.destructive_requires_name: false

#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
#
# The following settings, TLS certificates, and keys have been automatically      
# generated to configure Elasticsearch security features on 05-05-2022 01:41:44
#
# --------------------------------------------------------------------------------

# Enable security features
xpack.security.enabled: true

xpack.security.enrollment.enabled: true

# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
  enabled: true
  keystore.path: certs/http.p12

# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12
# Create a new cluster with the current node only
# Additional nodes can still join the cluster later
cluster.initial_master_nodes: ["localhost.localdomain"]

# Allow HTTP API connections from localhost and local networks
# Connections are encrypted and require user authentication
http.host: [_local_, _site_]

# Allow other nodes to join the cluster from localhost and local networks
# Connections are encrypted and mutually authenticated
#transport.host: [_local_, _site_]

#----------------------- END SECURITY AUTO CONFIGURATION -------------------------
参数 说明
cluster.name ElasticSearch 的集群名称,根据实际环境修改。例如:APIGateway
node.name 节点名称,集群中的各节点名字唯一,单节点部署时候不需要修改。例如:node-1
network.host 绑定监听ip地址。配置成安装ElasticSearch的本机IP地址,例如:0.0.0.0,设置为0.0.0.0后可以让任意IP访问es
bootstrap.memory_lock elasticsearch官网建议生产环境需要设置为 true 。
这个配置的意义:锁定物理内存地址,防止es内存被交换出去,也就是避免es使用swap交换分区,频繁的交换,会导致IOPS变高。
IPv6环境需要设置为: false
http.port ElasticSearch 的启动端口号。默认为9200。

# Windows环境

  1. 将压缩包“elasticsearch-8.1.2-windows-x86_64.zip”解压到需要安装Elasticsearch的服务器的指定目录的当前文件夹中。
  2. 在“elasticsearch-8.1.2/bin”目录下,执行如下命令,启动服务。
 $ ./elasticsearch.bat
  1. 参考Linux环境下步骤4 参数说明修改用户名密码。
  2. 访问同Linux环境下步骤5。