一、安装启动elasticsearch
1.修改主机名 node-1
2.下载软件包lasticsearch-7.17.0-linux-x86_64.tar.gz 并解压到/opt/
# curl -O http://192.168.200.3/cscc/iaas/elasticsearch-7.17.0-linux-x86_64.tar.gz
# tar -zxvf elasticsearch-7.17.0-linux-x86_64.tar.gz -C /opt/
[root@node-1 elasticsearch-7.17.0]# mkdir data
3.修改Elasticsearch配置
[root@node-1 elasticsearch-7.17.0]# vi config/elasticsearch.yml
…
cluster.name: my-application
node.name: node-1
path.data: /opt/elasticsearch-7.17.0/data
path.logs: /opt/elasticsearch-7.17.0/logs
network.host: 0.0.0.0
cluster.initial_master_nodes: ["node-1"]
…
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
4.创建Elasticsearch启动用户,并设置属组及权限:
[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]# vi /etc/security/limits.conf 修改资源限制
* hard nofile 65536
* soft nofile 65536
[root@node-1 elasticsearch-7.17.0]# vi /etc/sysctl.conf
vm.max_map_count=262144
#reboot
5.启动Elasticsearch服务:
[root@node-1 ~]# cd /opt/elasticsearch-7.17.0/
[root@node-1 elasticsearch-7.17.0]# su elsearch
[elsearch@node-1 elasticsearch-7.17.0]$ ./bin/elasticsearch -d
6.查询端口,存在9200则成功启动:
[root@node-1 elasticsearch-7.17.0]# netstat -ntlp
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:111 0.0.0.0:* LISTEN 598/rpcbind
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1086/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1073/master
tcp6 0 0 :::111 :::* LISTEN 598/rpcbind
tcp6 0 0 :::9200 :::* LISTEN 2043/java
访问ip:9200
{ "name" : "node-1", "cluster_name" : "my-application", "cluster_uuid" : "Eq1Ix-j8TACU7EqHSE3-vg", "version" : { "number" : "7.17.0", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "bee86328705acaa9a6daede7140defd4d9ec56bd", "build_date" : "2022-01-28T08:36:04.875279988Z", "build_snapshot" : false, "lucene_version" : "8.11.1", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }
二、部署SkyWalking OAP 服务
1.下载jdk 并配置
[root@node-1 ~]# curl -O http://192.168.200.3/cscc/iaas/jdk-8u144-linux-x64.tar.gz
[root@node-1 ~]# tar -zxvf jdk-8u144-linux-x64.tar.gz -C /usr/local/
# vi /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
2.下载apache-skywalking-apm-es7-8.0.0.tar.gz解压/opt/
# tar -zxvf apache-skywalking-apm-es7-8.0.0.tar.gz -C /opt/
3.进入解压后目录,修改OAP配置文件
[root@node-1 apache-skywalking-apm-bin-es7]# vi config/application.yml
#集群配置使用单机版
cluster:
selector: ${SW_CLUSTER:standalone}
standalone:
…
#数据库使用elasticsearch7
storage:
selector: ${SW_STORAGE:elasticsearch}
…
elasticsearch:
nameSpace: ${SW_NAMESPACE:""}
clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:192.168.200.18:9200}
4.启动OAP 查看端口11800 12800
[root@node-1 apache-skywalking-apm-bin-es7]# ./bin/oapService.sh
SkyWalking OAP started successfully!
三. 部署SkyWalking UI服务
(1)由于SkyWalking UI的默认地址是8080,与很多中间件可能存在冲突,修改一下:
[root@node-1 apache-skywalking-apm-bin-es7]# vi webapp/webapp.yml
…
server:
port: 8888
(2)启动SkyWalking UI服务:
[root@node-1 apache-skywalking-apm-bin-es7]# ./bin/webappService.sh
SkyWalking Web Application started successfully!
四. 搭建并启动应用商城服务
1.切换节点修改主机名
hostnamectl set-hostname mall
修改/etc/hosts配置文件:
192.168.200.18 mall
2.下载gpmall.tar.gz
# tar -zxvf gpmall.tar.gz
配置yum源
gpmall-repo
3.安装基础服务
安装基础服务,包括Java JDK环境、数据库、Redis、Nginx等
yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel -y
yum install redis -y
yum install nginx -y
yum install mariadb-server -y
4.安装zookeeper服务并启动
tar -zxvf zookeeper-3.4.14.tar.gz
cd zookeeper-3.4.14
mv zoo_sample.cfg zoo.cfg
./zkServer.sh start
cd gpmall
tar -zxvf kafka_2.11-1.1.1.tgz
./kafka-server-start.sh -daemon ../config/server.properties
5.启动服务
启动数据库
# vi /etc/my.cnf
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
systemctl start mariadb
设置root用户的密码为123456
[root@mall ~]# mysqladmin -uroot password 123456
[root@mall ~]# mysql -uroot -p123456
设置root用户的权限,命令如下:
grant all on *.* to root@localhost identified by '123456' with grant option;
grant all on *.* to root@'%' identified by '123456' with grant option;
将gpmall.sql文件上传至云主机的/root目录下。创建数据库gpmall并导入gpmall.sql文件。
MariaDB [(none)]> create database gpmall;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> use gpmall;
Database changed
MariaDB [gpmall]> source /root/gpmall/gpmall.sql;
启动redis
修改配置文件
[root@mall gpmall]# systemctl start redis
[root@mall gpmall]# systemctl enable redis
启动nginx
[root@mall gpmall]# systemctl start nginx
[root@mall gpmall]# systemctl enable nginx
(5)应用系统部署
使用提供gpmall-shopping-0.0.1-SNAPSHOT.jar、gpmall-user-0.0.1-SNAPSHOT.jar、shopping-provider-0.0.1-SNAPSHOT.jar、user-provider-0.0.1-SNAPSHOT.jar 、dist这5个包部署应用系统,其中4个jar包为后端服务包,dist为前端包。(包在gpmall目录下)
①全局变量配置
[root@mall ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.200.10 redis.mall
192.168.200.10 kafka.mall
192.168.200.10 mysql.mall
192.168.200.10 zookeeper.mall
②部署前端
rm -rf /usr/share/nginx/html/*
cp -vfr dist/* /usr/share/nginx/html/
[root@mall ~]# vi /etc/nginx/nginx.conf
…
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
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;
}
systemctl start nginx
部署后端
将node-1节点的/opt/apache-skywalking-apm-bin-es7目录下的agent目录复制到mall节点下:
[root@mall ~]# scp -r 192.168.200.18:/opt/apache-skywalking-apm-bin-es7/agent /root/
修改SkyWalking agent配置文件
[root@mall ~]# vi agent/config/agent.config
…
agent.service_name=${SW_AGENT_NAME:my-application}
agent.sample_n_per_3_secs=${SW_AGENT_SAMPLE:1}
…
collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:192.168.200.18:11800}
启动jar包
[root@mall ~]# nohup java -javaagent:/root/agent/skywalking-agent.jar -jar gpmall/shopping-provider-0.0.1-SNAPSHOT.jar &
[root@mall ~]# nohup: ignoring input and appending output to ‘nohup.out’
[root@mall ~]# nohup java -javaagent:/root/agent/skywalking-agent.jar -jar gpmall/user-provider-0.0.1-SNAPSHOT.jar &
[root@mall ~]# nohup: ignoring input and appending output to ‘nohup.out’
[root@mall ~]# nohup java -javaagent:/root/agent/skywalking-agent.jar -jar gpmall/gpmall-shopping-0.0.1-SNAPSHOT.jar &
[root@mall ~]# nohup: ignoring input and appending output to ‘nohup.out’
[root@mall ~]# nohup java -javaagent:/root/agent/skywalking-agent.jar -jar gpmall/gpmall-user-0.0.1-SNAPSHOT.jar &
[root@mall ~]# nohup: ignoring input and appending output to ‘nohup.out’
# httpd访问网络配置
[root@mall ~]# setsebool -P httpd_can_network_connect 1
访问页面,稍等。
再次访问SkyWalking UI,点击右上角的自动按钮(Auto)
本文含有隐藏内容,请 开通VIP 后查看