部署gpmall

一、搭建并启动应用商城服务

切换至提供mall节点,搭建并启动应用商城服务,并配置SkyWalking Agent

(1) 修改mall节点主机名

[root@mall ~]# hostnamectl set-hostname mall

修改/etc/hosts配置文件如下:

[root@mall ~]# vi /etc/hosts
10.26.17.211 mall

(2) 配置本地yum源

将提供的gpmall包下载到服务器的/root目录下并解压gpmall.tar.gz,配置本地local.repo文件,具体代码如下所示:

[root@mall ~]# tar -zxvf gpmall.tar.gz
[root@mall ~]# mv /etc/yum.repos.d/* /media/
[root@mall ~]# cd gpmall/
[root@mall gpmall]# tar -zxvf gpmall-repo.tar.gz -C  /root/
[root@mall ~]# vi /etc/yum.repos.d/local.repo 
[mall]
name=mall
baseurl=file:///root/gpmall-repo
gpgcheck=0
enabled=1

(3) 安装基础服务

安装基础服务,包括Java JDK环境、数据库、Redis、Nginx等,安装基础服务的命令具体如下。

3.1 安装Java环境

[root@mall ~]# yum install  -y java-1.8.0-openjdk java-1.8.0-openjdk-devel  
[root@mall ~]# java  -version  
openjdk version  "1.8.0_322"  
OpenJDK Runtime  Environment (build 1.8.0_322-b06)  
OpenJDK 64-Bit Server  VM (build 25.322-b06, mixed mode) 

3.2 安装Redis缓存服务

[root@mall ~]# yum install  redis -y 

3.3 安装Nginx服务

[root@mall ~]# yum  install nginx -y  

3.4 安装MariaDB数据库

[root@mall ~]# yum  install mariadb mariadb-server -y  

3.5 安装ZooKeeper服务,将提供的zookeeper-3.4.14.tar.gz解压,命令如下:

[root@mall gpmall]# tar -zxvf zookeeper-3.4.14.tar.gz -C /root/
[root@mall gpmall]# cd /root/zookeeper-3.4.14/conf/
[root@mall conf]# mv zoo_sample.cfg zoo.cfg
[root@mall conf]# cd ../bin
[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

3.6 安装Kafka服务,将提供的kafka_2.11-1.1.1.tgz解压至/root目录下,命令如下:

[root@mall bin]# tar -zxvf /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或者netstat -ntpl命令查看Kafka是否成功启动,命令如下:
[root@mall bin]# jps
6039 Kafka
1722 QuorumPeerMain
6126 Jps
[root@mall bin]# netstat -ntpl
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    1008/sshd   
tcp     0    0 127.0.0.1:25       0.0.0.0:*      LISTEN    887/master  
tcp6    0    0 :::9092         :::*         LISTEN    6039/java   
tcp6    0    0 :::46949         :::*         LISTEN    6039/java   
tcp6    0    0 :::2181         :::*         LISTEN    1722/java   
tcp6    0    0 :::48677         :::*         LISTEN    1722/java   
tcp6    0    0 :::22          :::*         LISTEN    1008/sshd   
tcp6    0    0 ::1:25          :::*         LISTEN    887/mast 
# 运行结果查看到Kafka服务和9092端口,说明Kafka服务已启动。

(4) 启动服务

4.1 启动数据库并配置

修改数据库配置文件并启动MariaDB数据库,设置root用户密码为123456,并创建gpmall数据库,将提供的gpmall.sql导入。

修改/etc/my.cnf文件,添加字段如下所示:

[root@mall bin]# cd
[root@mall ~]# vi /etc/my.cnf
[mysqld]
…
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
# 启动数据库命令如下。
[root@mall ~]# systemctl start mariadb  
# 设置root用户的密码为123456并登录。
[root@mall ~]# mysqladmin -uroot password 123456
[root@mall ~]# mysql -uroot -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.68-MariaDB MariaDB Server 
​
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
​
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
​
MariaDB [(none)]>
# 设置root用户的权限,命令如下:
MariaDB [(none)]> grant all privileges on *.* to root@localhost identified by '123456' with grant option;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> grant all privileges on *.* to root@"%" identified by '123456' with grant option;
Query OK, 0 rows affected (0.001 sec)
# 创建数据库gpmall并导入/root/gpmall/目录中的gpmall.sql文件。
MariaDB [(none)]> create database gpmall;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> use gpmall;
MariaDB [gpmall]> source /root/gpmall/gpmall.sql
# 退出数据库并设置开机自启。
MariaDB [gpmall]> exit
Bye 
[root@mall ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/mysql.service to /usr/lib/systemd/system/mariadb.service.
Created symlink from /etc/systemd/system/mysqld.service to /usr/lib/systemd/system/mariadb.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

4.2 启动Redis服务

修改Redis配置文件,编辑/etc/redis.conf文件。

将bind 127.0.0.1这一行注释掉;将protected-mode yes 改为 protected-mode no。

启动Redis服务命令如下。

[root@mall ~]# vi /etc/redis.conf
…
\#bind 127.0.0.1
protected-mode no
…
[root@mall ~]# systemctl start redis
[root@mall ~]# systemctl enable redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.

4.3 启动Nginx服务

启动Nginx服务命令如下。

[root@mall ~]# systemctl start nginx
[root@mall ~]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

(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目录下)

5.1 全局变量配置

修改/etc/hosts文件,修改项目全局配置文件如下(原有的172.128.11.42 mall映射删除):

[root@mall ~]# cat /etc/hosts
127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4
::1     localhost localhost.localdomain localhost6 localhost6.localdomain6
10.24.193.168 kafka.mall
10.24.193.168 mysql.mall
10.24.193.168 redis.mall
10.24.193.168 zookeeper.mall

5.2 部署前端

清空默认项目路径下的文件,将dist目录下的文件,复制到Nginx默认项目路径(文件在gpmall目录下)。

[root@mall ~]# rm -rf /usr/share/nginx/html/*
[root@mall ~]# cp -rvf gpmall/dist/* /usr/share/nginx/html/
# 修改Nginx配置文件/etc/nginx/nginx.conf,添加映射如下所示:
[root@mall ~]# vi /etc/nginx/nginx.conf
…
  server {
    listen    80;
    listen    [::]:80;
    server_name  _;
    root     /usr/share/nginx/html;
   \# Load configuration files for the default server block.
​
    include /etc/nginx/default.d/*.conf;
​
    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;
​
# 重启Nginx服务,命令如下:
​
[root@mall ~]# systemctl restart nginx

到此,前端部署完毕。

5.3 部署后端

将node-1节点的/opt/apache-skywalking-apm-bin-es7目录下的agent目录复制到mall节点下(密码为Abc@1234):

[root@mall ~]# scp -r 10.26.20.171:/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:10.24.194.203:11800}
…

采样率修改:agent.sample_n_per_3_secs配置说明:

在访问量较少时,链路全量收集不会对系统带来太大负担,能够完整的观测到系统的运行状况。但是在访问量较大时,全量的链路收集,对链路收集的客户端(agent探针)、服务端(SkyWalking OAP)、存储器(例如说Elastcsearch)都会带来较大的性能开销,甚至会影响应用的正常运行。在访问量级较大的情况下,往往会选择抽样采样,只收集部分链路信息。SkyWalking Agent在agent/config/agent.config 配置文件中,定义了agent.sample_n_per_3_secs配置项,设置每3秒可收集的链路数据的数量。

将gpmall软件包中提供的4个jar包,放置探针并启动,通过设置启动参数的方式检测系统,启动命令如下:

[root@mall ~]# nohup java -javaagent:/root/agent/skywalking-agent.jar  -jar gpmall/shopping-provider-0.0.1-SNAPSHOT.jar &
[1] 20086
[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 &
[2] 20132
[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 &
[3] 20177
[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 &
[4] 20281
[root@mall ~]# nohup: ignoring input and appending output to ‘nohup.out’
\# httpd访问网络配置
[root@mall ~]# setsebool -P httpd_can_network_connect 1

按照顺序运行4个jar包后,至此后端服务部署完毕。

④ 网站访问

打开浏览器,在地址栏中输入http://10.24.193.168,访问界面,如图3所示。

  • 48
    点赞
  • 51
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值