【gpmall 1+x商城系统】

商城系统部署搭建


软件包下载链接
提取码:xfi5

一、应用系统基础安装

ip地址主机名系统
192.168.39.3mallCentOS7

二、部署配置

(1)、基础配置

修改名称

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

配置主机名和IP地址之间的隐射

[root@mall ~]# cat >> /etc/hosts <<EOF
192.168.39.3 mall
EOF

配置本地yum源

[root@mall ~]# cat >> /etc/yum.repos.d/local.repo <<EOF
[gpmall-repo]
name=gpmall
baseurl=file:///root/gpmall-repo
gpgcheck=0
enabled=1

[centos]
name=centos
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1
EOF

# 挂载本地yum源
# 需要上传本地镜像
[root@mall ~]# ls | grep CentOS
CentOS-7-x86_64-DVD-1511.iso

# 创建挂载目录
[root@mall ~]# mkdir /mnt/cdrom
[root@mall ~]# mount -o loop /root/CentOS-7-x86_64-DVD-1511.iso /mnt/cdrom

# 设置开机自动挂载
$ echo "/root/CentOS-7-x86_64-DVD-1511.iso /mnt/cdrom iso9660 defaults 0 0" >> /etc/fstab

清除yum缓存、列出可用yum

[root@mall ~]# yum clean all
已加载插件:fastestmirror
正在清理软件源: centos mariadb
Cleaning up list of fastest mirrors
Other repos take up 140 M of disk space (use --verbose for details)

[root@mall ~]# yum makecache fast
[root@mall ~]# yum repolist all
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
源标识                                                源名称                                            状态
centos                                                centos                                            启用: 4,070
gpmall-repo                                           gpmall                                            启用:   165
repolist: 4,235

(2)、安装基础服务

安装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)

安装Redis缓存服务

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

安装Nginx服务

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

安装MariaDB 数据库

启动MariaDB 数据库、设置开机自启动

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

[root@mall ~]# systemctl start mariadb
[root@mall ~]# systemctl enable mariadb

数据库初始化

[root@mall ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS 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  		==>"y"
New password:   					==>"设置密码“123456”
Re-enter new password:			 	==>"分别输入两次密码"
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  ==>"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  ==>"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  ==>"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  ==>"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!

启动数据库、创建database、给用户授权

[root@mall ~]# mysql -uroot -p123456

MariaDB [(none)]> create database gpmall;

MariaDB [(none)]> use gpmall;

MariaDB [gpmall]> source /root/gpmall/gpmall.sql

MariaDB [gpmall]> grant all privileges on *.* to root@localhost identified by '123456' with grant option;

MariaDB [gpmall]> grant all privileges on *.* to root@"%" identified by '123456' with grant option;

MariaDB [gpmall]> flush privileges;

修改mariadb配置文件,配置数据库

[root@mall ~]# cat <<EOF >>/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
EOF

重启数据库

[root@mall ~]# systemctl restart mariadb

(3)、安装 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 ~]# cd zookeeper-3.4.14/conf
[root@mall conf]# mv zoo_sample.cfg zoo.cfg

[root@mall conf]# ls
configuration.xsl  log4j.properties  zoo.cfg

在zookeeper-3.4.14/bin 目录下,启动 ZooKeeper 服务

[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

查看 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

(4)、安装 Kafka 服务

将提供的 kafka_2.11-1.1.1.tgz 包上传到云主机的/opt 目录下,解压该压缩包

[root@mall ~]# tar -zxvf kafka_2.11-1.1.1.tgz 

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

[root@mall ~]# cd 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
12804 QuorumPeerMain
14117 Kafka
14357 Jps

[root@mall bin]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address        	==>能看到9092端口则说明服务启动成功
tcp6       0      0 :::9092                  :::*                   LISTEN      14117/java          
tcp6       0      0 :::2181                 :::*                    LISTEN      12804/java          
tcp6       0      0 :::38631                :::*                    LISTEN      12804/java          
tcp6       0      0 :::3306                 :::*                    LISTEN      11614/mysqld        
tcp6       0      0 :::10250                :::*                    LISTEN      714/kubelet         
tcp6       0      0 :::37011                :::*                    LISTEN      14117/java          
tcp6       0      0 :::22                   :::*                    LISTEN      998/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      1213/master     

(5)、启动 Redis 服务

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

# bind 127.0.0.1 ::1  ==>注释这行
$ sed -i 's/^bind 127.0.0.1/\# bind 127.0.0.1 ::1/g' /etc/redis.conf

# protected-mode no  	  ==>将“yes”改成“no”
$ sed -i 's/protected-mode yes/protected-mode no/g' /etc/redis.conf

启动 Redis 服务

[root@mall bin]# systemctl start redis
[root@mall bin]# systemctl enable redis

(6)、启动Nginx服务

[root@mall bin]# systemctl start nginx
[root@mall bin]# systemctl enable nginx

(7)、安装Elasticsearch服务

安装Elasticsearch服务并启动

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

配置Elasticsearch服务

修改 /etc/elasticsearch/elasticsearch.yml 目录下的配置文件

# 这里我将使用正则表达式sed将如下 4 条语句前的注释符去掉,并修改 network.host 的 IP 为本机 IP
# cluster.name: my-application
# node.name: node-1
# network.host: 192.168.39.3
# http.port: 9200

sed -i 's/#cluster.name: my-application/cluster.name: my-application/g' /etc/elasticsearch/elasticsearch.yml

sed -i 's/#node.name: node-1/node.name: node-1/g' /etc/elasticsearch/elasticsearch.yml

sed -i 's/^#network.host: .*/network.host: 192.168.39.3/g' /etc/elasticsearch/elasticsearch.yml

sed -i 's/#http.port: 9200/http.port: 9200/g' /etc/elasticsearch/elasticsearch.yml


# 用cat命令将如下三条配置信息输出到配置文件最上面
$ cat <<EOF >> /etc/elasticsearch/elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-credentials: true
EOF

启动 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.

应用系统部署

三、部署配置

(1)、配置主机和IP地址之间的映射

全局变量配置

添加IP地址映射条目到/etc/hosts 文件,

[root@mall ~]# cat <<EOF >>/etc/hosts
192.168.39.3 kafka.mall
192.168.39.3 mysql.mall
192.168.39.3 redis.mall
192.168.39.3 zookeeper.mall
EOF

(2)、部署前端

将 dist 目录上传至服务器的/root 目录下。接着将 dist 目录下的文件,复制到 Nginx 默认

项目路径(首先清空默认项目路径下的文件)。

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

#dist在/root/gpmall-host/dist/目录下
[root@zabbix-agent ~]# cp -rvf /root/gpmall-cluster/dist/* /usr/share/nginx/html/

修改 Nginx 配置文件/etc/nginx/conf.d/default.conf,添加映射

[root@mall ~]# vi /etc/nginx/conf.d/default.conf 

 12 # 添加如下配置文件
 13 location /user {
 14     
 15         proxy_pass http://192.168.39.3:8082;
 16     }
 17     
 18  location /shopping {
 19         proxy_pass http://192.168.39.3:8081;
 20     }
 21     
 22  location /cashier {
 23         proxy_pass http://192.168.39.3:8083;
 24     }

重启Nginx服务

# 验证nginx是否有配置错误
[root@kvm-02 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

# 重新加载nginx
[root@kvm-02 ~]# nginx -s reload

(3)、部署后端

将提供的 4 个 jar 包上传到服务器的/root 目录下,并启动

[root@mall ~]# nohup java -jar /root/gpmall/shopping-provider-0.0.1-SNAPSHOT.jar &

[root@mall ~]# nohup java -jar /root/gpmall/user-provider-0.0.1-SNAPSHOT.jar &

[root@mall ~]# nohup java -jar /root/gpmall/gpmall-shopping-0.0.1-SNAPSHOT.jar &

[root@mall ~]# nohup java -jar /root/gpmall/gpmall-user-0.0.1-SNAPSHOT.jar &

(4)、验证

[root@mall ~]# curl 192.168.39.3/#/home/
<!DOCTYPE html><html><head><meta charset=utf-8><title>1+x-示例项目</title><meta name=keywords content=""><meta name=description content=""><meta http-equiv=X-UA-Compatible content="IE=Edge"><meta name=wap-font-scale content=no><link rel="shortcut icon " type=images/x-icon href=/static/images/favicon.ico><link href=/static/css/app.8d4edd335a61c46bf5b6a63444cd855a.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.2d17a82764acff8145be.js></script><script type=text/javascript src=/static/js/vendor.4f07d3a235c8a7cd4efe.js></script><script type=text/javascript src=/static/js/app.81180cbb92541cdf912f.js></script></body></html><style>body{
        min-width:1250px;
  }</style>[root@mall ~]# 

#查看jar包是否挂成功
[root@mall ~]# jps
35569 QuorumPeerMain
37986 Kafka
64916 Elasticsearch
95159 gpmall-shopping-0.0.1-SNAPSHOT.jar
94954 user-provider-0.0.1-SNAPSHOT.jar
95196 gpmall-user-0.0.1-SNAPSHOT.jar
95212 Jps
94606 shopping-provider-0.0.1-SNAPSHOT.jar

  • 浏览器访问验证

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

GPMall是一种基于Web应用的商城系统,用于在线购物和交易。部署GPMall需要以下步骤: 1. 确定服务器要求:首先,需要确定部署GPMall服务器要求,包括操作系统、处理器和内存等。建议使用稳定的Linux操作系统,并根据数据量和用户量合理配置服务器硬件。 2. 安装配置数据库GPMall使用数据库存储商品信息、用户信息和交易记录等。可以选择MySQL或者其他常用的关系型数据库进行安装和配置。 3. 部署Web服务:GPMall是基于Web应用的商城系统,需要部署Web服务来处理用户的访问请求。可以选择常用的Web服务软件如Apache或者Nginx,并将GPMall的代码部署到Web服务的根目录。 4. 导入数据:在部署GPMall之前,需要将商城所需的基础数据导入到数据库中,包括商品数据、用户数据和配置数据等。可以通过数据库导入工具或者编写脚本进行数据导入。 5. 配置参数:为了使GPMall能够正常运行,还需要根据具体的需求进行参数配置。可以根据实际情况修改数据库连接参数、缓存配置和权限控制等。 6. 测试运行:在部署完成后,需要进行系统测试和运行验证。可以通过模拟用户操作进行功能测试,同时检查系统的性能和稳定性。 7. 监控和维护:部署完成后,需要建立监控机制来实时监测商城系统的运行状态。同时,定期进行系统维护,包括数据库清理、系统更新和安全补丁的升级等。 总之,部署GPMall需要合理规划服务器资源、安装配置数据库、部署Web服务,导入数据,配置参数,并进行系统测试和运维。通过以上步骤的完成,GPMall将能够正常运行并提供稳定可靠的在线商城服务。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值