CentOS部署Skywalking

avatar
作者
筋斗云
阅读量:0

Skywalking9.7.0版本,搭配Java21版本。

一、安装Docker
#yum -y install gcc
#yum -y install gcc-c++
#yum install -y yum-utils
设置国内的镜像仓库
#yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
更新yum软件包索引
#yum makecache fast
安装Docker引擎
#yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
启动Docker引擎
#systemctl start docker
设置开机启动
#systemctl enable docker.service
关闭开机启动
#systemctl disable docker.service

二、下载Elasticsearch容器
#docker pull elasticsearch:8.1.0
8.1.0: Pulling from library/elasticsearch
08c01a0ec47e: Pull complete
5ff2ab324559: Pull complete
02ed3593db24: Pull complete
818e9e5e96bb: Downloading [===================> ]
9ffdad5b7c03: Download complete
c75c21c9d887: Download complete
7de9ee659811: Download complete
e251a8179c68: Download complete
fc4fd8fa609a: Download complete
eac1c98ec28b: Download complete

三、启动Elasticsearch容器
#docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e “discovery.type=single-node” elasticsearch:8.1.0

指定外挂目录
#docker run -itd --name=elasticsearch --restart=always -p 9200:9200 -p 9300:9300 -e “discovery.type=single-node” -v /opt/data/elasticsearch8/data:/usr/share/elasticsearch/data -v /opt/data/elasticsearch8/logs:/usr/share/elasticsearch/logs elasticsearch:8.1.0
07a2a3d34483d842976592e6210c68604af057966702d5d8aee6d04be2616558

访问:https://192.168.100.201:9200/,用户名:elastic,口令:

四、修改Elasticsearch密码
#docker exec -it elasticsearch /bin/bash
elasticsearch@4bf62698795e:~$ ./bin/elasticsearch-setup-passwords interactive


Note: The ‘elasticsearch-setup-passwords’ tool has been deprecated. This command will be removed in a future release.


Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y

Enter password for [elastic]:
Reenter password for [elastic]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana_system]:
Reenter password for [kibana_system]:
Enter password for [logstash_system]:
Reenter password for [logstash_system]:
Enter password for [beats_system]:
Reenter password for [beats_system]:
Enter password for [remote_monitoring_user]:
Reenter password for [remote_monitoring_user]:
Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]

五、部署kibana容器(非必须)
1)下载容器
#docker pull elastic/kibana:8.1.0
8.1.0: Pulling from elastic/kibana
4fb807caa40a: Pull complete
2e80e64cf6e3: Pull complete
4c5043548240: Pull complete
c7c77672bdbf: Pull complete
a65d590a7ad2: Pull complete
f8d7c469c05a: Pull complete
403c1affe949: Pull complete
87804eacf159: Pull complete
ba875619762d: Pull complete
b1435e1654c6: Pull complete
5b69485d1c81: Pull complete
814c00a2ef69: Pull complete
690ca8c6b0d6: Pull complete
Digest: sha256:4a9a3364d29488da257a64ae114e79e2a3c8cf621f8d5c51c62bd1facb5773b0
Status: Downloaded newer image for elastic/kibana:8.1.0
docker.io/elastic/kibana:8.1.0
2)启动容器
#docker run -d --name kibana002 --link elasticsearch -e ELASTICSEARCH_URL=https://192.168.100.201:9200/ -p 5601:5601 elastic/kibana:8.1.0
532df9b9966754e88e25d9a02d407f6014550f7df7c938fbdd44554447890bc5
3)停止容器
#docker stop 0be2e886baaa
#docker kill 0be2e886baaa
4)访问
http://192.168.100.201:5601/
5)验证
#docker exec -it elasticsearch /bin/bash
elasticsearch@4bf62698795e:~$ cd bin
elasticsearch@4bf62698795e:~/bin$ elasticsearch-create-enrollment-token --scope kibana
WARNING: Owner of file [/usr/share/elasticsearch/config/users] used to be [root], but now is [elasticsearch]
WARNING: Owner of file [/usr/share/elasticsearch/config/users_roles] used to be [root], but now is [elasticsearch]
eyJ2ZXIiOiI4LjEuMCIsImFkciI6WyIxNzIuMTcuMC4yOjkyMDAiXSwiZmdyIjoiNzFmMjhkMDhkMTgyZWU3MjllMDcwODFkNWRhMDJiMjc4MGJjY2E5YTM0MmE2MzE4NDMxYWMxZjQ0NDI1ZGFjNSIsImtleSI6Ilh0bjUyNHNCMFhoYm1adWRQMDA5OkR2aGFfRlpYU2tDcEtZTkVDT2pRM1EifQ==
6)验证
#docker exec -it kibana002 /bin/bash
kibana@532df9b99667:~$ cd bin
kibana@532df9b99667:~/bin$ kibana-verification-code
Your verification code is: 894 715
7)登录,同Elasticsearch的密码(elastic)

六、部署Skywalking镜像
#docker pull apache/skywalking-oap-server:8.9.1
#docker pull apache/skywalking-ui:8.9.1
如果pull操作一直有waiting:
[root@boco201 docker]# pwd
/etc/docker
[root@boco201 docker]# more daemon.json
{
“registry-mirrors”:[
“https://9cpn8tt6.mirror.aliyuncs.com”,
“https://registry.docker-cn.com”
]
}
[root@boco201 docker]#

七、持久化启动Skywalking-oap
#docker run -itd --name skywalking-oap --restart=always -e TZ=Asia/Shanghai -p 12800:12800 -p 11800:11800 --link elasticsearch:elasticsearch -e SW_STORAGE=elasticsearch -e SW_STORAGE_ES_CLUSTER_NODES=elasticsearch:9200 apache/skywalking-oap-server:8.9.1

八、登录容器Skywalking-oap
#docker exec -it skywalking-oap bash

九、持久化启动Skywalking-ui
#docker run -itd --name skywalking-ui --restart=always -e TZ=Asia/Shanghai -p 8080:8080 --link skywalking-oap:skywalking-oap -e SW_OAP_ADDRESS=skywalking-oap:12800 apache/skywalking-ui:8.9.1

十、访问Skywalking-ui
http://192.168.100.201:8080/

十一、Java服务接入Skywalking
1)下载agent,从https://archive.apache.org/dist/skywalking/8.9.1/ 或 https://skywalking.apache.org/downloads/ 解压获得agent.jar(或agent-analyzer-8.9.1.jar)
2)jar包执行方式
#java -javaagent:/opt/data/skywalking-agent/agent/skywalking-agent.jar -Dskywalking.agent.service_name=my-app-service -Dskywalking.collector.backend_service=192.168.100.201:11800 -jar my-app-service.jar &

#java -javaagent:/opt/data/skywalking-agent/agent/agent-analyzer-8.9.1.jar -Dskywalking.agent.service_name=my-app-service -Dskywalking.collector.backend_service=192.168.100.201:11800 -jar my-app-service.jar &

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!