一、案例分析
1.规划节点

IP 主机名
192.168.94.1 mall

2.基础准备
centos7.2系统、yum源使用gpmall-repo包,安装基础环境
二、案例实施
1.修改主机名
修改主机名命令如下:

[root@localhost ~]# hostnamectl set-hostname mall
[root@mall ~]# hostnamectl Static hostname: mallIcon name: computer-vmChassis: vmMachine ID: dae72fe0cc064eb0b7797f25bfaf69dfBoot ID: af0da0209e864a9badd064fcc9ad7b0eVirtualization: kvmOperating System: CentOS Linux 7 (Core)CPE OS Name: cpe:/o:centos:centos:7Kernel: Linux 3.10.0-229.el7.x86_64Architecture: x86_64

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

[root@mall ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.94.1 mall

2.配置本地yum源
将提供的packages包上传到服务器的/opt目录下,并配置本地local.repo文件,具体代码如下所示。

mkdir -p /opt/centos
mount /dev/cdrom /opt/centos
cat /etc/yum.repo.d/local.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[mall]
name=mall
baseurl=file:///opt/gpmall-repo
gpgcheck=0
enabled=1

3.安装基础服务
安装基础服务,包括java JDK环境、数据库、Redis、Nginx等,安装基础服务的具体命令如下:
(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_222"
OpenJDK Runtime Environment (build 1.8.0_222-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

(2)安装Redis缓存服务

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

(3)安装Elasticsearch服务

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

(4)安装Nginx服务

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

(5)安装Mariadb服务

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

(6)安装zookeeper服务
将提供的zookeeper-3.4.14.tar.gz上传至云主机的/opt内,解压压缩包命令如下:

[root@mall ~]# tar -zxvf zookeeper-3.4.14.tar.gz

进入到zookeeper-3.4.14/conf目录下,将zoo_sample.cfg文件重命名为zoo.cfg,命令如下:

[root@mall conf]# mv zoo_sample.cfg zoo.cfg

进入到zookeeper-3.4.14/bin目录下,启动ZooKeeper服务,命令如下:

[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

查看ZooKeeper状态,命令如下:

[root@mall bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /root/zookeeper-3.4.14/bin/../conf/zoo.cfg
Mode: standalone

(7)安装kafka服务
将提供的kafka_2.11-1.1.1.tgz包上传到云主机的/opt目录下,解压该压缩包,命令如下:

tar -zxvf kafka_2.11-1.1.1.tgz

进入到kafka_2.11-1.1.1/bin目录下,启动Kafka服务,命令如下:

[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/master

运行结果查看到Kafka服务和9092端口,说明Kafka服务已启动。
4.启动服务
(1)启动数据库并配置
修改数据库配置文件并启动Mariadb数据库,设置root用户密码为123456,并创建gpmall数据库,将提供的gpmall.sql导入。
修改/etc/my.cnf文件,添加字段如下所示:

#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[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 ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):    #默认按回车
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:                               #输入数据库root密码123456
Re-enter new password:                        #重复输入密码123456
Password updated successfully!
Reloading privilege tables..... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n... skipping.
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y- Dropping test database...... Success!- Removing privileges on test database...... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB![root@mall ~]# mysql -uroot –p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.3.18-MariaDB MariaDB ServerCopyright (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.sql文件上传至云主机的/root目录下。创建数据库gpmall并导入gpmall.sql文件。

MariaDB [(none)]> create database gpmall;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> use gpmall;
MariaDB [mall]> source /root/gpmall.sql

退出数据库并设置开机自启。

MariaDB [mall]> Ctrl-C -- exit!
Aborted
[root@mall ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

(2)启动Redis服务
修改Redis配置文件,编辑/etc/redis.conf文件。
将bind 127.0.0.1这一行注释掉:
将protected-mode yes 改为protect-mode no。
启动Redis服务命令如下:

[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.

(3)配置Elasticsearch服务并启动
配置Elasticsearch服务命令如下:

[root@mall ~]# vi /etc/elasticsearch/elasticsearch.yml

在文件最上面加入3条语句如下:

http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-credentials: true

将如下4条语句前的注释符去掉,并修改network.host的IP为本机IP。

cluster.name: my-application
node.name: node-1
network.host: 192.168.94.1
http.port: 9200

最后修改完之后保存退出。然后启动Elasticsearch并设置开机自启,命令如下。

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

(4)启动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.全局变量配置
修改/etc/hosts文件,修改项目全局配置文件如下:

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

6.部署前端
将dist目录上传至服务器的/root目录下。接着dist目录下的文件,复制到Nginx默认项目路径(首先清空默认路径下的文件)。

[root@mall ~]# rm -rf /usr/share/nginx/html/*
[root@mall ~]# cp -rvf dist/* /usr/share/nginx/html/

修改Nginx配置文件/etc/nginx/conf.d/default.conf,添加映射如下所示:

[root@mall ~]# vi /etc/nginx/conf.d/default.conf
server {listen       80;server_name  localhost;#charset koi8-r;#access_log  /var/log/nginx/host.access.log  main;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

到此,前端部署完毕。
7.部署后端
将提供的4个jar包上传到服务器的/root目录下,并启动,启动命令如下:

[root@mall gpmall]# nohup java -jar shopping-provider-0.0.1-SNAPSHOT.jar &
[1] 6432
[root@mall gpmall]# nohup: ignoring input and appending output to ‘nohup.out’[root@mall gpmall]# nohup java -jar user-provider-0.0.1-SNAPSHOT.jar &
[2] 6475
[root@mall gpmall]# nohup: ignoring input and appending output to ‘nohup.out’[root@mall gpmall]# nohup java -jar gpmall-shopping-0.0.1-SNAPSHOT.jar &
[3] 6523
[root@mall gpmall]# nohup: ignoring input and appending output to ‘nohup.out’[root@mall gpmall]# nohup java -jar gpmall-user-0.0.1-SNAPSHOT.jar &
[4] 6563
[root@mall gpmall]# nohup: ignoring input and appending output to ‘nohup.out’

按照顺序运行4个jar包之后,后端部署完成。
8.网站访问
打开浏览器,在地址栏输入http://192.168.94.1,访问界面,见如下图即可。

单击右上角“头像”,进行登录操作,使用用户名/密码为test/test进行登录

登录后,可进行购买商品操作,单击首页“地平线8号”旅行箱图片

进入购买界面,单击“现在购买”按钮,进行购买商品操作

单击“现在购买”按钮,跳转到提交订单界面

至此,单机部署应用系统完成。

单节点部署gpmall商城系统相关推荐

  1. openstack 系列: 基于CentOS7系统使用packstack工具单节点部署openstacktrain---Part-I安装简易命令

    1说明 本人非linux专业人士,更不是云计算专家 部署过程是从各大博客自己百度知道 各种搜索排查,硬是搭起了train环境 过程纠结,先是在win 10 vmware 上安装centos7 再基于c ...

  2. Ubuntu下用devstack单节点部署Openstack

    一.实验环境 本实验是在Vmware Workstation下创建的单台Ubuntu服务器版系统中,利用devstack部署的Openstack Pike版. 宿主机:win10 1803  8G内存 ...

  3. k8s二进制单节点部署

    k8s二进制单节点部署 常见的k8s部署方式 Kubernetes二进制部署(单节点) 环境准备 部署etcd集群(这里就不在单独的服务器上部署,直接部署在各节点上,节省资源) 下载证书制作工具 利用 ...

  4. Graylog 日志服务器单节点部署

    资料 https://docs.graylog.org/docs/ 简介 Graylog项目由Lennart Koopmann在2009年左右启动.当时,最着名的日志管理软件vendor发布了他们产品 ...

  5. ruoyi 多模块部署_大数据时代,独立部署的商城系统具有哪些优势?

    独立部署是把一个可部署软件包安装到一个指定IT环境上并让其按预定流程提供服务的过程. 现如今,越来越多的商家开始搭建网上商城系统,从而为自己积攒多年的客户群体提供更为便捷的购物模式,让购物变得更加智能 ...

  6. 啃K8s之快速入门,以及哭吧S(k8s)单节点部署

    啃K8s之快速入门,以及哭吧S(k8s)单节点部署 一:Kubernets概述 1.1:Kubernets是什么? 1.2:Kubernets特性 1.3:Kubernets群集架构与组件 1.3.1 ...

  7. Elasticsearch在Linux中的单节点部署和集群部署

    目录 一.Elasticsearch简介 二.Linux单节点部署 1.软件下载解压 2.创建用户 3.修改配置文件 4.切换到刚刚创建的用户启动软件 5.测试 三.Linux集群配置 1.拷贝文件 ...

  8. skywalking单节点部署

    skywalking单节点部署 skywalking服务部署 下载skywalking服务文件 下载地址:http://skywalking.apache.org/downloads/ 我使用的是Bi ...

  9. ElasticSearch学习(四)——Linux 单节点部署

    文章名称 地址 ElasticSearch学习(一)--概述 前往 ElasticSearch学习(二)--索引.文档简单操作 前往 ElasticSearch学习(三)--Windows 集群部署 ...

最新文章

  1. python调用shell命令-Python调用shell命令常用方法(4种)
  2. php进程SIGBUS,SIGSEGV错误
  3. Xamarin效果第十八篇之GIS中复合型Mark
  4. linux用户取消密码,[Linux]linux下取消用户名和密码直接登录
  5. 用JSON-server模拟REST API(一) 安装运行
  6. 洛谷 P1080 国王游戏
  7. linux mysql配置修改_【Mysql】linux下mysql的配置修改
  8. electron打包失败在下载nsis的地方
  9. ignite集群的启动
  10. 提示java不是内部命令_Win7命令窗口提示“javac不是内部或外部命令”怎么解决?...
  11. 怎么改java的gre_GRE怎样完成60天小白到大神的蜕变?
  12. aws ecs 通过efs挂载实现动态更新firelens日志配置
  13. 几何算法合集(3D)
  14. A - Linearization of the kernel functions in SVM (模拟)
  15. OEE Worksheet
  16. Flink常用算子Transformation介绍
  17. 7-1 最长公共子序列 (20 分)
  18. System.Windows.Freezable 在未被引用的程序集中定义
  19. 看这篇就够了!能源企业数字化升级,推动绿色低碳发展
  20. java jdk1.9下载

热门文章

  1. 现如今社群乱象,社群玩法正解
  2. Ural1671 Anansi's Cobweb 并查集
  3. 计算机大四找不到工作怎么办?应届生如何找到合适的工作?
  4. GO connectex: A connection attempt failed because the connected party did not properly respond 已解决
  5. 第一次用python编写的小程序
  6. centos7 安装 oceanbase 单机版测试
  7. Redis系列(三)--过期策略
  8. 2020年有寓意的领证日期_2020有寓意的领证日期 2020有意义的领证日子 - 中国万年历...
  9. 人民币大小写转换格式
  10. 码、候选码、主码、全码和外码的区分