Microservices architecture diagram

Microservices division diagram

Build a virtual development environment

2. Once you have installed Vagrant Box, create a directory to store it in. For example, create a directory called Vagrant Box. /centOS7

$ mkdir .. /centOS7Copy the code

Initialize a centos/7 system

vagrant init centos/7
Copy the code

4. Start the VM with the default password vagrant

vagrant up
Copy the code

5. Other commands

# Automatically connect to the VIRTUAL machine using the Vagrant user
vagrant ssh 
# Exit this virtual machine
exit
# Stop this virtual machine
vagrant halt
# Destroy this virtual machine
vagrant destroy
Copy the code

The default VIRTUAL machine IP is not fixed. For ease of development, modify it in Vagrantfile:

config.vm.network "private_network", ip: "192.168.33.10"(The IP address here refers to the IP address of the physical machine, which can be found by using ipconfig and then changed to specify the subnet address)Copy the code

6. By default, only SSH login is allowed for ease of operation, file uploading, etc. You can configure the account and password to log in

Vagrant SSH login vi etc/ssh/sshd_config Modify PasswordAuthentication yes/no Restart the service. You can use the SSH connection tool to connect to the service SSHD restart

Use Docker technology

yum install docker
Copy the code

After the installation is complete, configure Ali Cloud image

# Check the docker version
docker -v
# start docker
systemctl start docker
# stop docker
systemctl stop docker
# restart docker
systemctl restart docker
# Check docker status
systemctl status docker
# Boot
systemctl enable docker
Copy the code

MySQL deployment

Mysql image pulls the latest version by default
docker pull mysql
# specify version pullDocker pull mysql: 5.7# mirror
docker images
Create and start MySQL container
#-p stands for port mapping in the format of host mapped port: container run port
-v mounts the host directory to the container
MYSQL_ROOT_PASSWORD is the login password of user root
#-d Run the container in the background and return the container ID
docker run -p 3306:3306 --name mysql  -v /mydata/mysql/log:/var/log/mysql  -v /mydata/mysql/data:/var/lib/mysql  -v    /mydata/mysql/conf:/etc/mysql  -e MYSQL_ROOT_PASSWORD=root  -dMysql: 5.7Enter the mysql container
docker exec -it javali_mysql /bin/bash
# in mysql
mysql -u root -p
Copy the code

You can also connect to MySQL through a remote graphical interface

Mysql container IP
docker inspect javali_mysql
Copy the code

3. Redis deployment

# pull redis
docker pull redis
# Check to see if it is installed
docker images
Create a directory and redis profile
mkdir -p /mydata/redis/conf
touch /mydata/redis/conf/redis.conf
Create an instance and start it
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
Run redis-cli command connection using redis image
docker exec -it redis redis-cli
Copy the code

Initialize database data

Information – Baidu Cloud link: pan.baidu.com/s/1ftzBq3p-… Extraction code: 9TDF

Use renren open source to build background management system

To separate the front end from the back end, deploy the back end before deploying the front end page.

Back-end deployment: 1. Download renren-fast source code through git

git clone https://gitee.com/renrenio/renren-fast.git
Copy the code

SQL > create database renren_fast; MySQL > create database renren_fast; MySQL > create database renren_fast; Update the MySQL account and password 5, IO operation. Renren. RenrenApplication. Java main method, can start the project

Front-end deployment: Renren-fast-vue based on vue, element-UI construction and development, renren-fast back-end management front-end function, need to install nodeJS, common error:

   # Clone project
    git clone https://gitee.com/renrenio/renren-fast-vue.git
    # install dependencies
    npm install
    # start service
    npm run dev
Copy the code

The password of the foreground login account is admin/admin

Use open source reverse engineering for everyone

# Clone project
git clone https://gitee.com/renrenio/renren-generator.git
Copy the code

Open the project and make changes to application.yml. As long as you change the database name, account, password, you can. The database name indicates the database where the table to be generated resides.

Url: JDBC :mysql:// Your database address/your database name? useUnicode=true&characterEncoding= utf-8 username: your username password: your user passwordCopy the code

Configuration file: Generator. properties Configures package names, author information, table prefixes, and type conversions. Where, type conversion refers to the type in MySQL and JavaBean type, is how a corresponding relationship. If there are missing types, add them in the generator.properties file

# the package name
package=com.daiaho.mall
# the author
author=DAIHAO
#Email
[email protected]
# table prefixes (class names do not contain table prefixes)
tablePrefix=tb_
Type conversion, configuration information
tinyint=Integer
smallint=Integer
mediumint=Integer
int=Integer
integer=Integer
bigint=Long
float=Float
double=Double
decimal=BigDecimal
bit=Boolean
char=String
varchar=String
tinytext=String
text=String
mediumtext=String
longtext=String
date=Date
datetime=Date
timestamp=Date
Copy the code

Then start the renren-Generator project (run the main method of renrenApplication.java), go to the front page and select the table generation code that needs to be generated.