APM

Skywalking安装配置

2020-01-20  本文已影响0人  一斗水

Skywalking安装

从官网下载skywalking安装包,包括两部分,一个是skywalking,一个是elasticsearch

skywalking下载地址:http://skywalking.apache.org/downloads/

我们下载linux版本的最新版:

https://www.apache.org/dyn/closer.cgi/skywalking/6.6.0/apache-skywalking-apm-6.6.0.tar.gz

https://www.apache.org/dyn/closer.cgi/skywalking/6.6.0/apache-skywalking-apm-es7-6.6.0.tar.gz

apache-skywalking-apm-6.6.0.tar.gz

apache-skywalking-apm-es7-6.6.0.tar.gz

解压

修改:apache-skywalking-apm-bin-es7/webapp/webapp.yml

安装ElK

安装Elasticsearch

elasticsearch相关软件下载中心:https://elasticsearch.cn/download/

下载elasticsearch

kibana

放置到/usr/local/elk目录

创建es用户

useradd es -b /home/es -d /home/es -U

使es用户有sudo权限

root用户执行命令:visudo

新增如下一行数据,然后wq保存退出

es      ALL=(ALL)       ALL

赋予目录权限:

chown -R es:es /usr/local/elk/

su - es

创建目录:

mkdir -p /usr/local/elk/elasticsearch-6.8.6/data
mkdir -p /usr/local/elk/elasticsearch-6.2.4/logs

编辑文件:/usr/local/elk/elasticsearch-6.8.6/config/elasticsearch.yml

# 修改cluster名称
cluster.name: my-skywalking-es
# 数据存储目录
path.data: /usr/local/elk/elasticsearch-6.8.6/data
# 日志存储目录
path.logs: /usr/local/elk/elasticsearch-6.2.4/logs
# elasticsearch官网建议生产环境需要设置bootstrap.memory_lock: true 
# 这个配置的意义:锁定物理内存地址,防止es内存被交换出去,也就是避免es使用swap交换分区,频繁的交换,会导致IOPS变高。
bootstrap.memory_lock: true
# 改成0.0.0.0即任意IP都可以访问
network.host: 0.0.0.0
# 修改端口号
http.port: 19200

进入:/usr/local/elk/elasticsearch-6.8.6目录

执行:bin/elasticsearch

启动报错

[es@localhost elasticsearch-6.8.6]$ bin/elasticsearch
[2020-01-06T10:35:10,014][WARN ][o.e.b.JNANatives         ] [node-1] Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
[2020-01-06T10:35:10,017][WARN ][o.e.b.JNANatives         ] [node-1] This can result in part of the JVM being swapped out.
[2020-01-06T10:35:10,017][WARN ][o.e.b.JNANatives         ] [node-1] Increase RLIMIT_MEMLOCK, soft limit: 65536, hard limit: 65536
[2020-01-06T10:35:10,018][WARN ][o.e.b.JNANatives         ] [node-1] These can be adjusted by modifying /etc/security/limits.conf, for example:
    # allow user 'es' mlockall
    es soft memlock unlimited
    es hard memlock unlimited
[2020-01-06T10:35:10,018][WARN ][o.e.b.JNANatives         ] [node-1] If you are logged in interactively, you will have to re-login for the new limits to take effect.
[2020-01-06T10:35:10,277][INFO ][o.e.e.NodeEnvironment    ] [node-1] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [40.8gb], net total_space [49.9gb], types [rootfs]
[2020-01-06T10:35:10,278][INFO ][o.e.e.NodeEnvironment    ] [node-1] heap size [990.7mb], compressed ordinary object pointers [true]
[2020-01-06T10:35:10,279][INFO ][o.e.n.Node               ] [node-1] node name [node-1], node ID [YqPp5oBzTMGxKf4vkcMxJg]
[2020-01-06T10:35:10,279][INFO ][o.e.n.Node               ] [node-1] version[6.8.6], pid[3075], build[default/tar/3d9f765/2019-12-13T17:11:52.013738Z], OS[Linux/3.10.0-327.el7.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_232/25.232-b09]
[2020-01-06T10:35:10,280][INFO ][o.e.n.Node               ] [node-1] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch-8686897058201483042, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.path.home=/usr/local/elk/elasticsearch-6.8.6, -Des.path.conf=/usr/local/elk/elasticsearch-6.8.6/config, -Des.distribution.flavor=default, -Des.distribution.type=tar]
[2020-01-06T10:35:12,342][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [aggs-matrix-stats]
[2020-01-06T10:35:12,342][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [analysis-common]
[2020-01-06T10:35:12,343][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [ingest-common]
[2020-01-06T10:35:12,343][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [ingest-geoip]
[2020-01-06T10:35:12,343][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [ingest-user-agent]
[2020-01-06T10:35:12,343][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-expression]
[2020-01-06T10:35:12,343][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-mustache]
[2020-01-06T10:35:12,343][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-painless]
[2020-01-06T10:35:12,343][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [mapper-extras]
[2020-01-06T10:35:12,343][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [parent-join]
[2020-01-06T10:35:12,343][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [percolator]
[2020-01-06T10:35:12,343][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [rank-eval]
[2020-01-06T10:35:12,344][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [reindex]
[2020-01-06T10:35:12,344][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [repository-url]
[2020-01-06T10:35:12,344][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty4]
[2020-01-06T10:35:12,344][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [tribe]
[2020-01-06T10:35:12,344][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-ccr]
[2020-01-06T10:35:12,344][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-core]
[2020-01-06T10:35:12,344][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-deprecation]
[2020-01-06T10:35:12,344][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-graph]
[2020-01-06T10:35:12,344][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-ilm]
[2020-01-06T10:35:12,344][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-logstash]
[2020-01-06T10:35:12,344][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-ml]
[2020-01-06T10:35:12,345][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-monitoring]
[2020-01-06T10:35:12,345][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-rollup]
[2020-01-06T10:35:12,345][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-security]
[2020-01-06T10:35:12,345][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-sql]
[2020-01-06T10:35:12,345][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-upgrade]
[2020-01-06T10:35:12,345][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-watcher]
[2020-01-06T10:35:12,345][INFO ][o.e.p.PluginsService     ] [node-1] no plugins loaded
[2020-01-06T10:35:17,385][INFO ][o.e.x.s.a.s.FileRolesStore] [node-1] parsed [0] roles from file [/usr/local/elk/elasticsearch-6.8.6/config/roles.yml]
[2020-01-06T10:35:18,163][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [node-1] [controller/3149] [Main.cc@109] controller (64 bit): Version 6.8.6 (Build 73ed602c10c48e) Copyright (c) 2019 Elasticsearch BV
[2020-01-06T10:35:18,733][DEBUG][o.e.a.ActionModule       ] [node-1] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2020-01-06T10:35:18,969][INFO ][o.e.d.DiscoveryModule    ] [node-1] using discovery type [zen] and host providers [settings]
[2020-01-06T10:35:19,973][INFO ][o.e.n.Node               ] [node-1] initialized
[2020-01-06T10:35:19,973][INFO ][o.e.n.Node               ] [node-1] starting ...
[2020-01-06T10:35:20,162][INFO ][o.e.t.TransportService   ] [node-1] publish_address {192.168.16.210:9300}, bound_addresses {[::]:9300}
[2020-01-06T10:35:20,180][INFO ][o.e.b.BootstrapChecks    ] [node-1] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: memory locking requested for elasticsearch process but memory is not locked
[2020-01-06T10:35:20,189][INFO ][o.e.n.Node               ] [node-1] stopping ...
[2020-01-06T10:35:20,220][INFO ][o.e.n.Node               ] [node-1] stopped
[2020-01-06T10:35:20,220][INFO ][o.e.n.Node               ] [node-1] closing ...
[2020-01-06T10:35:20,240][INFO ][o.e.n.Node               ] [node-1] closed
[2020-01-06T10:35:20,244][INFO ][o.e.x.m.p.NativeController] [node-1] Native controller process has stopped - no new native processes can be started

看到报错

==ERROR: [2] bootstrap checks failed==
==[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]==
==[2]: memory locking requested for elasticsearch process but memory is not locked==

如下修改:

切换到root用户修改配置文件:/etc/security/limits.conf

添加如下内容:

* soft nofile 65536
* hard nofile 65536
* soft nproc 32000
* hard nproc 32000
* hard memlock unlimited
* soft memlock unlimited

修改/etc/systemd/system.conf

DefaultLimitNOFILE=65536
DefaultLimitNPROC=32000
DefaultLimitMEMLOCK=infinity

执行以下操作,立即生效

systemctl daemon-reload

对于小系统应用es的优化和建议:

建议用SSD,提高性能;
新建索引的时候,分片设置成1,备份设置成0,能有效的降低IOPS;
可以参考以下配置:

put http://localhost:9200/test/
{
“settings”: {
“number_of_shards”: 1,
“number_of_replicas”: 0,
“index.analysis.analyzer.default.type”: “ik_max_word”
},
“mappings”: {
“my”: {
“properties”: {
“id”: {
“type”: “long”
},
“name”: {
“type”: “text”
},
“content”: {
“type”: “text”
}
}
}
}
}

修改完之后,切换到es,进入到/usr/local/elk/elasticsearch-6.8.6再次启动

bin/elasticsearch

启动成功后,发现不是后台启动,ctrl + c停止,然后执行命令

bin/elasticsearch --help

打印如下内容:

starts elasticsearch

Option                Description
------                -----------
-E <KeyValuePair>     Configure a setting
-V, --version         Prints elasticsearch version information and exits
-d, --daemonize       Starts Elasticsearch in the background
-h, --help            show help
-p, --pidfile <Path>  Creates a pid file in the specified path on start
-q, --quiet           Turns off standard output/error streams logging in console
-s, --silent          show minimal output
-v, --verbose         show verbose output

我们可以看到-d参数是后台启动的意思,所以执行如下命令后台启动es:

bin/elasticsearch -d

启动成功后,执行如下名:

curl 192.168.16.210:19200

控制台打印如下内容

{
  "name" : "node-1",
  "cluster_name" : "my-skywalking-es",
  "cluster_uuid" : "_kk1oWAsSte10VlJJpYG4Q",
  "version" : {
    "number" : "6.8.6",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "3d9f765",
    "build_date" : "2019-12-13T17:11:52.013738Z",
    "build_snapshot" : false,
    "lucene_version" : "7.7.2",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

elasticsearch已经启动OK。

安装Kibana

还是es用户,进入到/usr/local/elk/目录,解压kibana

tar -zxvf kibana-6.8.6-linux-x86_64.tar.gz

修改目录名称:

mv kibana-6.8.6-linux-x86_64 kibana-6.8.6

进入kibana目录:

cd /usr/local/elk/kibana-6.8.6

创建日志目录:

mkdir -p /usr/local/elk/kibana-6.8.6/run
touch /usr/local/elk/kibana-6.8.6/run/kibana.pid
mkdir -p /usr/local/elk/kibana-6.8.6/logs

修改配置文件config/kibana.yml

# 修改端口号为15601
server.port: 15601
# 服务IP地址
server.host: "192.168.16.210"
# elasticsearch 配置
elasticsearch.hosts: ["http://192.168.16.210:19200"]
# 配置pid文件存储运行Kibana时的进程号,便于用kill -9 `cat /usr/local/elk/kibana-6.8.6/run/kibana.pid`来杀进程。
pid.file: /usr/local/elk/kibana-6.8.6/run/kibana.pid
# 配置日志输出文件
logging.dest: /usr/local/elk/kibana-6.8.6/logs/kibana.log

启动kibana,进入/usr/local/elk/kibana-6.8.6目录,执行如下命令:

nohup bin/kibana > /dev/null 2>&1 &

在浏览器输入地址:http://192.168.16.210:15601

可以看到如下界面:这样kibana安装完成

kibana-snapshot.png

如何停掉kibana,执行如下命令:

kill -9 `cat /usr/local/elk/kibana-6.8.6/run/kibana.pid`

安装Skywalking

root用户,下载好skywalking安装包后,创建目录:/usr/local/skywalking

将安装apache-skywalking-apm-6.6.0.tar.gz包拷贝到/usr/local/skywalking目录,
执行解压命令:

tar -zxvf apache-skywalking-apm-6.6.0.tar.gz

查看目录文件:ls -al

[root@localhost skywalking]# ls -al
总用量 139128
drwxr-xr-x   3 root root        79 1月   6 11:19 .
drwxr-xr-x. 15 root root      4096 1月   6 10:19 ..
-rw-r--r--   1 root root 142460459 1月   6 09:37 apache-skywalking-apm-6.6.0.tar.gz
drwxrwxr-x   8 1001 1002       128 12月 24 14:10 apache-skywalking-apm-bin

进入目录:apache-skywalking-apm-bin修改配置文件vi config/application.yml

修改storage节点下内容,将默认的h2全部注释掉

#  h2:
#    driver: ${SW_STORAGE_H2_DRIVER:org.h2.jdbcx.JdbcDataSource}
#    url: ${SW_STORAGE_H2_URL:jdbc:h2:mem:skywalking-oap-db}
#    user: ${SW_STORAGE_H2_USER:sa}
#    metadataQueryMaxSize: ${SW_STORAGE_H2_QUERY_MAX_SIZE:5000}

放开elasticsearch的注释:

storage:
  elasticsearch:
    clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:19200}
    protocol: ${SW_STORAGE_ES_HTTP_PROTOCOL:"http"}
    indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:2}
    indexReplicasNumber: ${SW_STORAGE_ES_INDEX_REPLICAS_NUMBER:0}
    # Batch process setting, refer to https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.5/java-docs-bulk-processor.html
    bulkActions: ${SW_STORAGE_ES_BULK_ACTIONS:2000} # Execute the bulk every 1000 requests
    flushInterval: ${SW_STORAGE_ES_FLUSH_INTERVAL:10} # flush the bulk every 10 seconds whatever the number of requests
    concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2} # the number of concurrent

然后修改端口号,修改文件webapp/webapp.yml

server:
  port: 18080

collector:
  path: /graphql
  ribbon:
    ReadTimeout: 10000
    # Point to all backend's restHost:restPort, split by ,
    listOfServers: 127.0.0.1:12800

执行命令启动:

bin/startup.sh

[root@localhost apache-skywalking-apm-bin]# bin/startup.sh
SkyWalking OAP started successfully!
SkyWalking Web Application started successfully!

然后再浏览器界面输入地址:http://192.168.16.210:18080

可以看到skywalking界面:


skywalking-snapshot.png
上一篇下一篇

猜你喜欢

热点阅读