tags:
- mall
综合实战: mall
[!important] -组织架构
mall
├── mall-common – 工具类及通用代码
├── mall-mbg – MyBatisGenerator生成的数据库操作代码
├── mall-security – SpringSecurity封装公用模块
├── mall-admin – 后台商城管理系统接口
├── mall-search – 基于Elasticsearch的商品搜索系统
├── mall-portal – 前台商城系统接口
└── mall-demo – 框架搭建时的测试代码
技术选型
后端技术
前端技术
技术 | 说明 | 官网 |
---|---|---|
Vue | 前端框架 | https://vuejs.org/ |
Vue-router | 路由框架 | https://router.vuejs.org/ |
Vuex | 全局状态管理框架 | https://vuex.vuejs.org/ |
Element | 前端UI框架 | https://element.eleme.io |
Axios | 前端HTTP框架 | https://github.com/axios/axios |
v-charts | 基于Echarts的图表框架 | https://v-charts.js.org/ |
Js-cookie | cookie管理工具 | https://github.com/js-cookie/js-cookie |
nprogress | 进度条控件 | https://github.com/rstacruz/nprogress |
移动端技术
技术 | 说明 | 官网 |
---|---|---|
Vue | 核心前端框架 | https://vuejs.org |
Vuex | 全局状态管理框架 | https://vuex.vuejs.org |
uni-app | 移动端前端框架 | https://uniapp.dcloud.io |
mix-mall | 电商项目模板 | https://ext.dcloud.net.cn/plugin?id=200 |
luch-request | HTTP请求框架 | https://github.com/lei-mu/luch-request |
开发环境
工具 | 版本号 | 下载 |
---|---|---|
JDK | 1.8 | https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html |
MySQL | 5.7 | https://www.mysql.com/ |
Redis | 7.0 | https://redis.io/download |
MongoDB | 5.0 | https://www.mongodb.com/download-center |
RabbitMQ | 3.10.5 | http://www.rabbitmq.com/download.html |
Nginx | 1.22 | http://nginx.org/en/download.html |
Elasticsearch | 7.17.3 | https://www.elastic.co/downloads/elasticsearch |
Logstash | 7.17.3 | https://www.elastic.co/cn/downloads/logstash |
Kibana | 7.17.3 | https://www.elastic.co/cn/downloads/kibana |
架构图
业务架构图
项目部署实操
#项目部署实操
[!Note]- 在 github 上拉取项目
git clone https://github.com/macrozheng/mall.git
[!NOTE]- 在 gitee 上拉取项目
git clone https://gitee.com/macrozheng/mall.git
主机规划
ID | ROLE | SERVER | IP | MANUAL LINK | configuration |
---|---|---|---|---|---|
1 | mysql-master | mysql | 192.168.30.126 | [[#mysql]] | 2C2G 硬盘20G |
2 | mysql-slave | mysql | 192.168.30.58 | [[#mysql]] | 2C2G 硬盘20G |
3 | mrhost_master | mongodb+redis | 192.168.30.43 | [[#mongodb]],[[#redis]] | 2C2G 硬盘20G |
4 | mrhost_slave | mongodb+redis | 192.168.30.5 | [[#mongodb]],[[#redis]] | 2C2G 硬盘20G |
5 | mrhost_sentry | mongodb+redis | 192.168.30.160 | [[#mongodb]],[[#redis]] | 2C2G 硬盘20G |
6 | rabbit1 | rabbitMQ | 192.168.30.212 | [[#rabbitMQ]] | 2C2G 硬盘20G |
7 | rabbit2 | rabbitMQ | 192.168.30.127 | [[#rabbitMQ]] | 2C2G 硬盘20G |
8 | elasticsearch1 | Elasticsearch | 192.168.30.8 | [[#Elasticsearch]] | 2C4G 硬盘20G |
9 | elasticsearch2 | Elasticsearch | 192.168.30.242 | [[#Elasticsearch]] | 2C4G 硬盘20G |
10 | elasticsearch3 | Elasticsearch | 192.168.30.46 | [[#Elasticsearch]] | 2C4G 硬盘20G |
11 | minio1 | minio | 192.168.30.12 | [[#minio]] | 2C2G 硬盘20G*2 |
12 | minio2 | minio | 192.168.30.68 | [[#minio]] | 2C2G 硬盘20G*2 |
13 | nginx-frontend | nginx 前端+反向代理 | 192.168.30.91 | [[# nginx 前端]] | 4C4G 硬盘20G |
14 | nginx-backend | nginx 后端+反向代理 | 192.168.30.71 | [[#nginx 后端]] | 4C4G 硬盘20G |
中间件版本
SERVER | VERSION |
---|---|
mysql | 5.5.68 |
mongodb | 5.0.23 |
redis | 6.2.13 |
rabbitMQ | 3.10.0 |
Elasticsearch | 8.4.0 |
minio | Release 2024-10-02T17-50-41Z |
nginx | 1.20.1 |
服务规划
[!NOTE]- MySql
{ db: mall # 连接数据库的远程账号 user: admin pwd: admin # 本地用户,不能远程登录 loginpass: root loginuser: root port: 3306 }
[!NOTE]- mongodb
{ replSet: mall_db port: 27017 user: root password: 123456 }
[!NOTE]- redis
{ pwd: 123456 port: 6379 }
[!NOTE]- minio
{ user: minioadmin pwd: minioadmin port: 9000 }
[!NOTE]- rebbit
{ virtual-host: /mall username: mall password: mall port: 5672 }
系统准备
[!warning] -操作系统 : CentOS7
开始部署
[!important]- 前期准备工作
关闭防火墙systemctl stop firewalld.service systemctl disable firewalld.service
关闭 selinux
setenforce 0
配置 aliyun 源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
下载基础包
yum update
yum install -y bash-com* vim wget unzip
[[#MYSQL]]
下载 git 拉取项目 ,项目地址在 #项目部署实操
yum install -y git
yum install -y mariadb-server mariadb
编辑MySQL配置文件 /etc/my.cnf,添加以下内容:
[!Warning] 注意添加到【mysqld】所属组 !!!
[mysqld]
server-id=1
log-bin=/data/mysql/log/mysql-bin-master #开启log-bin日志
为Mysql创建主log-bin目录
mkdir -p /data/mysql/log/
chown mysql.mysql -R /data/mysql/log
启动
sudo systemctl start mariadb --now
mysqladmin -u root password "root"
mysql -uroot -proot
[!Warning] 上述操作需要在主从上分别执行
创建mall仓库和授权,【在主库上】
create database mall;
grant all privileges on mall.* to admin@'%' identified by 'admin';
flush privileges;
建立给从数据库授权
grant replication slave on *.* to slave@'192.168.30.%' identified by 'root';
flush privileges;
[!Warning] 导入数据库并发送给从数据库,从库在导入时应先按上述将数据库先行建立
use mall
source /root/mall/document/sql/mall.sql
[!Warning] 记住这串数字 661406
show master status;
+-------------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------------+----------+--------------+------------------+
| mysql-bin-master.000003 | 661406 | | |
+-------------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
[!NOTE] 从部署
vim /etc/my.cnf
[mysqld]
server-id = 2
relay-log=/data/mysql/log/relay-log-bin #中继日志文件的路径名称
relay-log-index=/data/mysql/log/slave-relay-bin.index #中继日志索引文件的路径名称
mkdir -p /data/mysql/log/
chown mysql.mysql -R /data/mysql/log
启动
sudo systemctl start mariadb --now
mysqladmin -u root password "root"
mysql -uroot -proot
create database mall;
use mall;
source /root/mall/document/sql/mall.sql
[!INOTE]- mall 数据库信息
+-----------------------------------------+
| Tables_in_mall |
±----------------------------------------+
| cms_help |
| cms_help_category |
| cms_member_report |
| cms_prefrence_area |
| cms_prefrence_area_product_relation |
| cms_subject |
| cms_subject_category |
| cms_subject_comment |
| cms_subject_product_relation |
| cms_topic |
| cms_topic_category |
| cms_topic_comment |
| oms_cart_item |
| oms_company_address |
| oms_order |
| oms_order_item |
| oms_order_operate_history |
| oms_order_return_apply |
| oms_order_return_reason |
| oms_order_setting |
| pms_album |
| pms_album_pic |
| pms_brand |
| pms_comment |
| pms_comment_replay |
| pms_feight_template |
| pms_member_price |
| pms_product |
| pms_product_attribute |
| pms_product_attribute_category |
| pms_product_attribute_value |
| pms_product_category |
| pms_product_category_attribute_relation |
| pms_product_full_reduction |
| pms_product_ladder |
| pms_product_operate_log |
| pms_product_vertify_record |
| pms_sku_stock |
| sms_coupon |
| sms_coupon_history |
| sms_coupon_product_category_relation |
| sms_coupon_product_relation |
| sms_flash_promotion |
| sms_flash_promotion_log |
| sms_flash_promotion_product_relation |
| sms_flash_promotion_session |
| sms_home_advertise |
| sms_home_brand |
| sms_home_new_product |
| sms_home_recommend_product |
| sms_home_recommend_subject |
| ums_admin |
| ums_admin_login_log |
| ums_admin_permission_relation |
| ums_admin_role_relation |
| ums_growth_change_history |
| ums_integration_change_history |
| ums_integration_consume_setting |
| ums_member |
| ums_member_level |
| ums_member_login_log |
| ums_member_member_tag_relation |
| ums_member_product_category_relation |
| ums_member_receive_address |
| ums_member_rule_setting |
| ums_member_statistics_info |
| ums_member_tag |
| ums_member_task |
| ums_menu |
| ums_permission |
| ums_resource |
| ums_resource_category |
| ums_role |
| ums_role_menu_relation |
| ums_role_permission_relation |
| ums_role_resource_relation |
±----------------------------------------+
76 rows in set (0.00 sec)
建立主从关系
在从上
[!Warning] master_log_pos 661406
mysql -uroot -proot
stop slave;
change master to master_host='192.168.30.126',master_user='slave',master_password='root',master_log_file='mysql-bin-master.000003',master_log_pos=661406;
start slave;
show slave status\G
********