使用提供的 OpenStack私有云平台,申请一台 centos7.9系统的云主机,使用提供的软件包安装 Elasticsearch服务和 skywalking服务,将 skywalking的 UI访问端口修改为 8888。接下来再申请一台CentOS7.9的云主机,用于搭建gpmall商城应用,并配置SkyWalking Agent, 将gpmall的 jar包放置探针并启动。
[root@skywalking-0001 ~]# hostnamectl set-hostname node-1
[root@node-1 ~]# curl -O http://124.70.150.239/resource/skywalking.tar.gz
[root@node-1 ~]# tar -zxf skywalking.tar.gz
[root@node-1 ~]# cd skywalking/
[root@node-1 skywalking]# ls
apache-skywalking-apm-es7-8.0.0.tar.gz elasticsearch-7.17.0-linux-x86_64.tar.gz gpmall jdk-8u144-linux-x64.tar.gz
[root@node-1 skywalking]# tar zxf elasticsearch-7.17.0-linux-x86_64.tar.gz -C /opt/
[root@node-1 opt]# cd /opt/elasticsearch-7.17.0/
[root@node-1 elasticsearch-7.17.0]# vim config/elasticsearch.yml
17 cluster.name: my-application
23 node.name: node-1
33 path.data: /opt/elasticsearch-7.17.0/data
37 path.logs: /opt/elasticsearch-7.17.0/logs
56 network.host: 0.0.0.0
74 cluster.initial_master_nodes: ["node-1"]
以下为手动写入
97 http.cors.enabled: true
98 http.cors.allow-origin: "*"
99 http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
[root@node-1 elasticsearch-7.17.0]# groupadd elsearch
[root@node-1 elasticsearch-7.17.0]# useradd elsearch -g elsearch -p elasticsearch
[root@node-1 elasticsearch-7.17.0]# chown -R elsearch:elsearch /opt/elasticsearch-7.17.0/
[root@node-1 elasticsearch-7.17.0]# vim /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
[root@node-1 elasticsearch-7.17.0]# vim /etc/sysctl.conf
vm.max_map_count = 262144
[root@node-1 elasticsearch-7.17.0]# reboot
等待30秒重新连接
[root@node-1 ~]# cd /opt/elasticsearch-7.17.0/
[root@node-1 elasticsearch-7.17.0]#
[root@node-1 elasticsearch-7.17.0]# su elsearch
[elsearch@node-1 elasticsearch-7.17.0]$ ./bin/elasticsearch -d
[elsearch@node-1 elasticsearch-7.17.0]$ netstat -ntlp
查询9200与9300端口是否开启
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp6 0 0 :::9200 :::* LISTEN 5853/java
tcp6 0 0 :::9300 :::* LISTEN 5853/java
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 ::1:25 :::* LISTEN -
[elsearch@node-1 elasticsearch-7.17.0]$
访问node-1ip:9200
[root@node-1 ~]# cd /opt/elasticsearch-7.17.0/
[root@node-1 elasticsearch-7.17.0]# cd /root/skywalking/
[root@node-1 skywalking]# tar -zxf jdk-8u144-linux-x64.tar.gz -C /usr/local/
[root@node-1 skywalking]# vim /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_144
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin
[root@node-1 skywalking]# java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
[root@node-1 skywalking]# tar -zxf apache-skywalking-apm-es7-8.0.0.tar.gz -C /opt/
[root@node-1 skywalking]# cd /opt/apache-skywalking-apm-bin-es7/
[root@node-1 apache-skywalking-apm-bin-es7]#vim config/application.yml
84 storage:
85 selector: ${SW_STORAGE:elasticsearch7}
108 elasticsearch7:
109 nameSpace: ${SW_NAMESPACE:""}
110 clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:127.0.0.1:9200}
[root@node-1 apache-skywalking-apm-bin-es7]# ./bin/oapService.sh
SkyWalking OAP started successfully!
[root@node-1 apache-skywalking-apm-bin-es7]# netstat -ntlp
查询12800与11800端口是否开启
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1346/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1123/master
tcp6 0 0 :::9200 :::* LISTEN 5853/java
tcp6 0 0 :::9300 :::* LISTEN 5853/java
tcp6 0 0 :::22 :::* LISTEN 1346/sshd
tcp6 0 0 :::11800 :::* LISTEN 23909/java
tcp6 0 0 ::1:25 :::* LISTEN 1123/master
tcp6 0 0 :::12800 :::* LISTEN 23909/java
[root@node-1 apache-skywalking-apm-bin-es7]#vim webapp/webapp.yml
17 server:
18 port: 8888
[root@node-1 apache-skywalking-apm-bin-es7]# ./bin/webappService.sh
SkyWalking Web Application started successfully!
[root@node-1 apache-skywalking-apm-bin-es7]# netstat -ntlp
查询8888端口是否开启
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1346/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1123/master
tcp6 0 0 :::9200 :::* LISTEN 5853/java
tcp6 0 0 :::9300 :::* LISTEN 5853/java
tcp6 0 0 :::22 :::* LISTEN 1346/sshd
tcp6 0 0 :::8888 :::* LISTEN 4972/java
tcp6 0 0 :::11800 :::* LISTEN 23909/java
tcp6 0 0 ::1:25 :::* LISTEN 1123/master
tcp6 0 0 :::12800 :::* LISTEN 23909/java
[root@node-1 apache-skywalking-apm-bin-es7]#
访问node-1ip:8888
[root@skywalking-0002 ~]# hostnamectl set-hostname mall
[root@mall ~]# curl -O http://124.70.150.239/resource/gpmall-single.tar.gz
[root@mall ~]# tar -zxf gpmall-single.tar.gz
[root@mall ~]# mv gpmall-single gpmall
[root@mall ~]# cd gpmall
[root@mall gpmall]# ls
dist gpmall-shopping-0.0.1-SNAPSHOT.jar gpmall-user-0.0.1-SNAPSHOT.jar shopping-provider-0.0.1-SNAPSHOT.jar zookeeper-3.4.14.tar.gz
gpmall-repo gpmall.sql kafka_2.11-1.1.1.tgz user-provider-0.0.1-SNAPSHOT.jar
[root@mall gpmall]# mv /etc/yum.repos.d/* /mnt/
[root@mall gpmall]# cat >> /etc/yum.repos.d/local.repo << EOF
> [local]
> name=local
> baseurl=file:///root/gpmall/gpmall-repo/
> gpgcheck=0
> enabled=1
> EOF
[root@mall gpmall]# yum clean all && yum makecache
[root@mall gpmall]# yum -y install java* redi* nginx mariad*
[root@mall gpmall]# cd ../zookeeper-3.4.14/
[root@mall zookeeper-3.4.14]# cd ..
[root@mall ~]# cd gpmall
[root@mall gpmall]# cd ../zookeeper-3.4.14/conf/
[root@mall conf]# mv zoo_sample.cfg zoo.cfg
[root@mall conf]# cd ../bin/
[root@mall bin]# ./zk
zkCleanup.sh zkCli.sh zkEnv.sh zkServer.sh zkTxnLogToolkit.sh
zkCli.cmd zkEnv.cmd zkServer.cmd zkTxnLogToolkit.cmd
[root@mall bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /root/zookeeper-3.4.14/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@mall bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /root/zookeeper-3.4.14/bin/../conf/zoo.cfg
Mode: standalone
[root@mall bin]# tar -zxf /root/gpmall/kafka_2.11-1.1.1.tgz -C /root/
[root@mall bin]# cd /root/kafka_2.11-1.1.1/bin/
[root@mall bin]# ./kafka-server-start.sh -daemon ../config/server.properties
使用jps或ntlp查看服务是否启动 9092与2181端口
[root@mall bin]# jps
3330 Jps
3096 Kafka
633 WrapperSimpleApp
27741 QuorumPeerMain
[root@mall bin]# netstat -ntlp
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2183/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1046/master
tcp6 0 0 :::9092 :::* LISTEN 3096/java
tcp6 0 0 :::2181 :::* LISTEN 27741/java
tcp6 0 0 :::45163 :::* LISTEN 3096/java
tcp6 0 0 :::33613 :::* LISTEN 27741/java
tcp6 0 0 :::22 :::* LISTEN 2183/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1046/master
[root@mall ~]# systemctl restart mariadb && systemctl enable mariadb
[root@mall ~]# mysql -uroot -p123456
MariaDB [(none)]> show variables like "char%";
MariaDB [(none)]> exit
Bye
[root@mall ~]#
[root@mall ~]# vim /etc/my.cnf
[mysqld]
character_set_client=utf8
[root@mall ~]# mysql -uroot -p123456
MariaDB [(none)]> create database gpmall;
MariaDB [(none)]> use gpmall;
MariaDB [gpmall]> source /root/gpmall/gpmall.sql
MariaDB [gpmall]> exit
[root@mall ~]# systemctl restart mariadb
[root@mall ~]# vim /etc/redis.conf
bind 0.0.0.0
protected-mode no
[root@mall ~]# vim /etc/hosts
172.16.1.101 node-1
172.16.1.241 kafka.mall
172.16.1.241 mysql.mall
172.16.1.241 redis.mall
172.16.1.241 zookeeper.mall
[root@mall ~]# rm -rf /usr/share/nginx/html/*
[root@mall ~]# cp -rf gpmall/dist/* /usr/share/nginx/html/
[root@mall gpmall]# cat /etc/nginx/nginx.conf
user nobody;
worker_processes 1; # 只启动一个工作进程
events {
worker_connections 1024; # 每个工作进程的最大连接为1024
}
http {
include mime.types; # 引入MIME类型映射表文件
default_type application/octet-stream; # 全局默认映射类型为application/octet-stream
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent” "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on; # 启用零复制机制
keepalive_timeout 65; # 保持连接超时时间为65s
server {
listen 80;
listen [::]:80; # 监听80端口的网络连接请求
server_name _; # 虚拟主机名为localhost
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /user {
proxy_pass http://127.0.0.1:8082;
}
location /shopping {
proxy_pass http://127.0.0.1:8081;
}
location /cashier {
proxy_pass http://127.0.0.1:8083;
}
error_page 404 /404.html;
location = /404.html {
root html;
}
}
}
[root@mall ~]# systemctl restart nginx && systemctl enable nginx
[root@mall ~]# scp -r node-1:/opt/apache-skywalking-apm-bin-es7/agent /root
[root@mall ~]# vim agent/config/agent.config
21 agent.service_name=${SW_AGENT_NAME:my-application}
25 agent.sample_n_per_3_secs=${SW_AGENT_SAMPLE:1}
61 collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:node-1ip:11800}
[root@mall ~]# nohup java -javaagent:/root/agent/skywalking-agent.jar -jar gpmall/shopping-provider-0.0.1-SNAPSHOT.jar &
[root@mall ~]# nohup java -javaagent:/root/agent/skywalking-agent.jar -jar gpmall/user-provider-0.0.1-SNAPSHOT.jar &
[root@mall ~]# nohup java -javaagent:/root/agent/skywalking-agent.jar -jar gpmall/gpmall-shopping-0.0.1-SNAPSHOT.jar &
[root@mall ~]# nohup java -javaagent:/root/agent/skywalking-agent.jar -jar gpmall/gpmall-user-0.0.1-SNAPSHOT.jar &
访问mall节点ip 如图
商城账号test密码test登录购买一件商品
访问node-1ip:8888
点击Reload
点击Topology文章来源:https://www.toymoban.com/news/detail-504238.html
显示图示关系图文章来源地址https://www.toymoban.com/news/detail-504238.html
到了这里,关于云计算赛项-私有云skywalking服务部署与应用的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!