Vue+springboot+springcloud project combat (1) – project introduction and environment construction

【Day01】Photon Mall

Based on SpringBoot2.x, SpringCould 2.x, redis, [docker] , vue…

1. Project introduction

A B2C model e-commerce platform that sells self-operated products to users

Second, the project microservice [architecture] diagram

3. Environment Construction

1. Linux [virtual machine]

I’m using VMware 12 to install CentOS 7.8 here

At the beginning of the NAT mode used in the network mode, the virtual machine could ping the host, but the host could not ping the virtual machine, and then Baidu made a call, followed the operation on the Internet, and restored the default network settings, and then found that ens33 could not be enabled…

After that, you can reset the network. The reference article is: /aeolian/p/8882790.html, this article has a complete introduction to the virtual machine network configuration, and solved the problems I encountered.

2, Linux installation docker

It is strongly recommended to use docker to build the environment, it is simply not convenient

3. Docker installs common services

3.1 Install mysql

My pull here is mysql 5.7

#pull image
docker pull mysql:5.7
#Run mysql container
docker run -p 3306:3306 --name mysql \ # Map port 3306 of the container to port 3306 of the host
> -v /mydata/mysql/ log :/var/ log /mysql \ # Mount the log folder to the host
 > -v /mydata/mysql/data:/var/lib/mysql \ # Mount the data folder Go to the host
 > -v /mydata/mysql/conf:/etc/mysql \ # Hang the configuration folder on the host
 > -e MYSQL_ROOT_PASSWORD=root \ # Initialize the root user's password
 > -d mysql:5.7

Create a my.conf configuration file at /mydata/mysql/conf/ and configure it

cd /mydata/mysql/conf/
touch my.conf
vim my.conf
# The configuration content is as follows
[client]
default-character-set=utf-8

[mysql]
default-character-set=utf-8

[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAME utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve

Restart the mysql container for the configuration to take effect

Use the host’s navicat to connect to the data just run to see if the connection is normal

When the test link shows that the connection is successful, it means that the mysql environment is successfully built.

3.2 Install redis

I am pulling redis 6.0 here

# Pull the image docker 
pull redis:6.0.12 #  Run the container docker run -p 6379:6379 --name redis \


-v /mydata/redis/data:/data \
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis \
redis-server /etc/redis/redis.conf

At the same time, create a redis.conf configuration file under /mydata/redis/conf/ and configure it

mkdir  -p /mydata/redis/conf 
cd  /mydata/redis/conf/ 
touch  redis.conf 
vim  redis.conf 

# Configuration content 
appendonly  yes 
bind  0.0.0.0 
protected-mode  no

Here I have only performed the most basic configuration. If you want to configure more content, you can go to the redis official website to find the relevant configuration file, download, modify and replace the file. Specific address: https://redis.io/topics/configfind your own version to download and modify

Then test the operation of the redis container on the host

Here you can use the redis visualization tool RedisDesktopManagerto test through the virtual machine ip and redis port number

When this pop-up window appears, the environment configuration is successful.

# This command can make redis start automatically with the start of docker, and mysql can also set 
docker update  --restart=always myredis like this

3.3 Install nocas

pull the latest version of the mirror

docker pull nacos/nacos-server

Set the mount directory and modify the configuration file

mkdir -p /home/nacos/logs/ #Create a new logs directory
mkdir -p /home/nacos/init.d/          
vim /home/nacos/init.d/custom.properties #Modify the configuration file
# configure content
server.contextPath=/nacos
server.servlet.contextPath=/nacos
server.port=8848

spring.datasource.platform=mysql

db.num=1
db.url.0=jdbc:mysql://xx.xx.xx.x:3306/nacos_devtest_prod?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=user
db.password=pass

nacos.cmdb.dumpTaskInterval= 3600 
nacos.cmdb.eventTaskInterval= 10 
nacos.cmdb.labelTaskInterval= 300 
nacos.cmdb.loadDataAtStart= false

management.metrics.export.elastic.enabled=false

management.metrics.export.influx.enabled=false

server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i


nacos.security.ignore.urls=/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/login,/v1/console/health/**,/v1/cs/**,/v1/ns/**,/v1/cmdb/**,/actuator/**,/v1/console/server/**
nacos.naming.distro.taskDispatchThreadCount=1
nacos.naming.distro.taskDispatchPeriod=200
nacos.naming.distro.batchSyncKeyCount=1000
nacos.naming.distro.initDataRatio=0.9
nacos.naming.distro.syncRetryDelay=5000
nacos.naming.data.warmup=true
nacos.naming.expireInstance=true

start the container

docker run -p 8848:8848 --name nacos -d \
--privileged=true \
--restart=always \
-e JVM_XMS=256m \
-e JVM_XMX=256m \
-e MODE=standalone \
-e PREFER_HOST_MODE=hostname \
-v /home/nacos/logs:/home/nacos/logs \
-v /home/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties \
nacos/nacos-server

4. Development tools

5. git configuration

Enter the git bash window and enter the following command

ssh-keygen -t rsa -C "xxxxx@xxx.com"  # Get the ssh key, just press Enter three times

View key

cat ~/.ssh/id_rsa.pub

Copy the key to the ssh public key in the code cloud

carry out testing

ssh -T git@gitee.com

If there is successfully, the configuration is successful

6. Project structure creation

6.1 Create a new warehouse

Create a new warehouse in the code cloud

Then open the idea and import the git project, enter the address of the warehouse to import

6.2 Create a microservice module

Use Spring Initializrto quickly build each SpringBoot submodule, and select the dependencies of Web and OpenFeign in each module

Copy a pom.xml under gzmall to aggregate each module

Ignore unwanted subfiles under .gitignore under gzmall

**/mvnw
**/mvnw.cmd

**/.mvn
**/target/

.idea
**/.gitignore

6.3 Submit to Code Cloud

7. Database initialization

Remotely connect to the mysql database through naviat to create the corresponding database for each microservice module

Leave a Comment

Your email address will not be published. Required fields are marked *