网站集群架构图-前后端分离项目
部署xzs-mysql数据库
docker-compose目录结构

构建数据库镜像
编写docker-compose
[root@db02 /server/docker-compose/xzs-mysql]# cat docker-compose.yml
services:
exam_db:
image: "mysql:8.0-debian"
container_name: exam_db
restart: always
environment:
MYSQL_ROOT_PASSWORD: "1"
MYSQL_DATABASE: "exam"
MYSQL_USER: "exam"
MYSQL_PASSWORD: "exam"
ports:
- 3306:3306
volumes:
- exam_db:/var/lib/mysql/
volumes:
exam_db:
#启动镜像
docker-compose up -d

数据库文件
[root@db02 /server/docker-compose/xzs-mysql]# cat xzs-mysql.sql
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for t_exam_paper
-- ----------------------------
DROP TABLE IF EXISTS `t_exam_paper`;
CREATE TABLE `t_exam_paper` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`subject_id` int NULL DEFAULT NULL,
`paper_type` int NULL DEFAULT NULL,
`grade_level` int NULL DEFAULT NULL,
`score` int NULL DEFAULT NULL,
`question_count` int NULL DEFAULT NULL,
`suggest_time` int NULL DEFAULT NULL,
`limit_start_time` datetime NULL DEFAULT NULL,
`limit_end_time` datetime NULL DEFAULT NULL,
`frame_text_content_id` int NULL DEFAULT NULL,
`create_user` int NULL DEFAULT NULL,
`create_time` datetime NULL DEFAULT NULL,
`deleted` bit(1) NULL DEFAULT NULL,
`task_exam_id` int NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of t_exam_paper
-- ----------------------------
-- ----------------------------
-- Table structure for t_exam_paper_answer
-- ----------------------------
DROP TABLE IF EXISTS `t_exam_paper_answer`;
CREATE TABLE `t_exam_paper_answer` (
`id` int NOT NULL AUTO_INCREMENT,
`exam_paper_id` int NULL DEFAULT NULL,
`paper_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`paper_type` int NULL DEFAULT NULL,
`subject_id` int NULL DEFAULT NULL,
`system_score` int NULL DEFAULT NULL,
`user_score` int NULL DEFAULT NULL,
`paper_score` int NULL DEFAULT NULL,
`question_correct` int NULL DEFAULT NULL,
`question_count` int NULL DEFAULT NULL,
`do_time` int NULL DEFAULT NULL,
`status` int NULL DEFAULT NULL,
`create_user` int NULL DEFAULT NULL,
`create_time` datetime NULL DEFAULT NULL,
`task_exam_id` int NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of t_exam_paper_answer
-- ----------------------------
-- ----------------------------
-- Table structure for t_exam_paper_question_customer_answer
-- ----------------------------
DROP TABLE IF EXISTS `t_exam_paper_question_customer_answer`;
CREATE TABLE `t_exam_paper_question_customer_answer` (
`id` int NOT NULL AUTO_INCREMENT,
`question_id` int NULL DEFAULT NULL,
`exam_paper_id` int NULL DEFAULT NULL,
`exam_paper_answer_id` int NULL DEFAULT NULL,
`question_type` int NULL DEFAULT NULL,
`subject_id` int NULL DEFAULT NULL,
`customer_score` int NULL DEFAULT NULL,
`question_score` int NULL DEFAULT NULL,
`question_text_content_id` int NULL DEFAULT NULL,
`answer` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`text_content_id` int NULL DEFAULT NULL,
`do_right` bit(1) NULL DEFAULT NULL,
`create_user` int NULL DEFAULT NULL,
`create_time` datetime NULL DEFAULT NULL,
`item_order` int NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of t_exam_paper_question_customer_answer
-- ----------------------------
-- ----------------------------
-- Table structure for t_message
-- ----------------------------
DROP TABLE IF EXISTS `t_message`;
CREATE TABLE `t_message` (
`id` int NOT NULL AUTO_INCREMENT,
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`create_time` datetime NULL DEFAULT NULL,
`send_user_id` int NULL DEFAULT NULL,
`send_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`send_real_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`receive_user_count` int NULL DEFAULT NULL,
`read_count` int NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of t_message
-- ----------------------------
-- ----------------------------
-- Table structure for t_message_user
-- ----------------------------
DROP TABLE IF EXISTS `t_message_user`;
CREATE TABLE `t_message_user` (
`id` int NOT NULL AUTO_INCREMENT,
`message_id` int NULL DEFAULT NULL,
`receive_user_id` int NULL DEFAULT NULL,
`receive_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`receive_real_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`readed` bit(1) NULL DEFAULT NULL,
`create_time` datetime NULL DEFAULT NULL,
`read_time` datetime NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of t_message_user
-- ----------------------------
-- ----------------------------
-- Table structure for t_question
-- ----------------------------
DROP TABLE IF EXISTS `t_question`;
CREATE TABLE `t_question` (
`id` int NOT NULL AUTO_INCREMENT,
`question_type` int NULL DEFAULT NULL,
`subject_id` int NULL DEFAULT NULL,
`score` int NULL DEFAULT NULL,
`grade_level` int NULL DEFAULT NULL,
`difficult` int NULL DEFAULT NULL,
`correct` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
`info_text_content_id` int NULL DEFAULT NULL,
`create_user` int NULL DEFAULT NULL,
`status` int NULL DEFAULT NULL,
`create_time` datetime NULL DEFAULT NULL,
`deleted` bit(1) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of t_question
-- ----------------------------
-- ----------------------------
-- Table structure for t_subject
-- ----------------------------
DROP TABLE IF EXISTS `t_subject`;
CREATE TABLE `t_subject` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`level` int NULL DEFAULT NULL,
`level_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`item_order` int NULL DEFAULT NULL,
`deleted` bit(1) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of t_subject
-- ----------------------------
-- ----------------------------
-- Table structure for t_task_exam
-- ----------------------------
DROP TABLE IF EXISTS `t_task_exam`;
CREATE TABLE `t_task_exam` (
`id` int NOT NULL AUTO_INCREMENT,
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`grade_level` int NULL DEFAULT NULL,
`frame_text_content_id` int NULL DEFAULT NULL,
`create_user` int NULL DEFAULT NULL,
`create_time` datetime NULL DEFAULT NULL,
`deleted` bit(1) NULL DEFAULT NULL,
`create_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of t_task_exam
-- ----------------------------
-- ----------------------------
-- Table structure for t_task_exam_customer_answer
-- ----------------------------
DROP TABLE IF EXISTS `t_task_exam_customer_answer`;
CREATE TABLE `t_task_exam_customer_answer` (
`id` int NOT NULL AUTO_INCREMENT,
`task_exam_id` int NULL DEFAULT NULL,
`create_user` int NULL DEFAULT NULL,
`create_time` datetime NULL DEFAULT NULL,
`text_content_id` int NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of t_task_exam_customer_answer
-- ----------------------------
-- ----------------------------
-- Table structure for t_text_content
-- ----------------------------
DROP TABLE IF EXISTS `t_text_content`;
CREATE TABLE `t_text_content` (
`id` int NOT NULL AUTO_INCREMENT,
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
`create_time` datetime NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of t_text_content
-- ----------------------------
-- ----------------------------
-- Table structure for t_user
-- ----------------------------
DROP TABLE IF EXISTS `t_user`;
CREATE TABLE `t_user` (
`id` int NOT NULL AUTO_INCREMENT,
`user_uuid` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`real_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`age` int NULL DEFAULT NULL,
`sex` int NULL DEFAULT NULL,
`birth_day` datetime NULL DEFAULT NULL,
`user_level` int NULL DEFAULT NULL,
`phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`role` int NULL DEFAULT NULL,
`status` int NULL DEFAULT NULL,
`image_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`create_time` datetime NULL DEFAULT NULL,
`modify_time` datetime NULL DEFAULT NULL,
`last_active_time` datetime NULL DEFAULT NULL,
`deleted` bit(1) NULL DEFAULT NULL,
`wx_open_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of t_user
-- ----------------------------
INSERT INTO `t_user` VALUES (1, 'd2d29da2-dcb3-4013-b874-727626236f47', 'student', 'D1AGFL+Gx37t0NPG4d6biYP5Z31cNbwhK5w1lUeiHB2zagqbk8efYfSjYoh1Z/j1dkiRjHU+b0EpwzCh8IGsksJjzD65ci5LsnodQVf4Uj6D3pwoscXGqmkjjpzvSJbx42swwNTA+QoDU8YLo7JhtbUK2X0qCjFGpd+8eJ5BGvk=', '学生', 18, 1, '2019-09-01 16:00:00', 1, '19171171610', 1, 1, 'https://www.mindskip.net:9008/image/ba607a75-83ba-4530-8e23-660b72dc4953/头像.jpg', '2019-09-07 18:55:02', '2020-02-04 08:26:54', NULL, b'0', NULL);
INSERT INTO `t_user` VALUES (2, '52045f5f-a13f-4ccc-93dd-f7ee8270ad4c', 'admin', 'D1AGFL+Gx37t0NPG4d6biYP5Z31cNbwhK5w1lUeiHB2zagqbk8efYfSjYoh1Z/j1dkiRjHU+b0EpwzCh8IGsksJjzD65ci5LsnodQVf4Uj6D3pwoscXGqmkjjpzvSJbx42swwNTA+QoDU8YLo7JhtbUK2X0qCjFGpd+8eJ5BGvk=', '管理员', 30, 1, '2019-09-07 18:56:07', NULL, NULL, 3, 1, NULL, '2019-09-07 18:56:21', NULL, NULL, b'0', NULL);
-- ----------------------------
-- Table structure for t_user_event_log
-- ----------------------------
DROP TABLE IF EXISTS `t_user_event_log`;
CREATE TABLE `t_user_event_log` (
`id` int NOT NULL AUTO_INCREMENT,
`user_id` int NULL DEFAULT NULL,
`user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`real_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
`create_time` datetime NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of t_user_event_log
-- ----------------------------
-- ----------------------------
-- Table structure for t_user_token
-- ----------------------------
DROP TABLE IF EXISTS `t_user_token`;
CREATE TABLE `t_user_token` (
`id` int NOT NULL AUTO_INCREMENT,
`token` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`user_id` int NULL DEFAULT NULL,
`wx_open_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`create_time` datetime NULL DEFAULT NULL,
`end_time` datetime NULL DEFAULT NULL,
`user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of t_user_token
-- ----------------------------
SET FOREIGN_KEY_CHECKS = 1;
#进入容器,导入数据库
docker exec -it exam_db /bin/bash
#从宿主机传输mysql文件到容器中导入
docker cp xzs-mysql.sql exam_db:/tmp/
#在/tmp/目录下执行
mysql -uexam -pexam exam < xzs-mysql.sql
部署学之思后端服务器
构建后端服务器目录结构

构建后端服务器镜像
编写Dockerfile
[root@web03 /server/docker-compose/exam_java]# cat Dockerfile
FROM harbor.zmx.cn/zhangmx/tengine:3.1.0
LABEL author=zhang desc="后端"
ENV SRC sources.list
ENV TZ Asia/Shanghai
ENV CODE /app/code/exam/
ADD ${SRC} /etc/apt/sources.list
RUN apt update \
&& DEBIAN_FRONTEND=noninteractive &&apt-get install -y tzdata \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone \
&& apt install -y openjdk-8-jdk
RUN mkdir -p ${CODE}
WORKDIR ${CODE}
COPY application-prod.yml .
COPY xzs-3.9.0.jar .
ADD entry.sh /
EXPOSE 8080
CMD ["/entry.sh"]
HEALTHChECK --interval=5s --timeout=20s --retries=2 CMD curl 10.0.0.9:8080
编写docker-compose
[root@web03 /server/docker-compose/exam_java]# cat docker-compose.yml
services:
exam_hou:
image: "web:exam_hou"
build:
context: .
dockerfile: Dockerfile
container_name: exam_v1
ports:
- 8000:8000
restart: always
编写后端文件连接数据库
[root@web03 /server/docker-compose/exam_java]# cat application-prod.yml
server:
port: 8000
undertow:
io-threads: 16
worker-threads: 4000
buffer-size: 1024
direct-buffers: true
compression:
enabled: true
min-response-size: 1
#日志
logging:
path: /app/code/exam/
#数据库,redis等等配置
spring:
datasource:
#mysql://数据库地址:端口号/库名字?
url: jdbc:mysql://172.16.1.52:3306/exam?useSSL=false&useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: exam
password: exam
driver-class-name: com.mysql.cj.jdbc.Driver
启动java服务脚本文件
[root@web03 /server/docker-compose/exam_java]# cat entry.sh
#!/bin/bash
##############################################################
# File Name:entry.sh
# Version:V1.0
# Author:zmx
# Organization:www.zmx.com
# Desc:
##############################################################
#后端启动命令
java -Duser.timezone=Asia/Shanghai -jar -Dspring.profiles.active=prod xzs-3.9.0.jar
apt源文件
[root@web03 /server/docker-compose/exam_java]# cat sources.list
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
# deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
构建镜像
cd /server/docker-compose/exam_java/
#构建镜像
docker-compose build
#启动容器
docker-compose up -d

本机IP访问测试
部署学之思前端服务器
构建前端服务器目录结构

构建前期服务器镜像
编写Dockerfile
[root@web01 /server/docker-compose/exam_html]# cat Dockerfile
FROM harbor.zmx.cn/zhangmx/web:tengine_3.1.0
LABEL author=zhang desc="前端"
ENV DIR=/app/code/exam/
RUN mkdir -p ${DIR}
WORKDIR ${DIR}
ADD exam-web.tar.gz .
ADD exam.conf /etc/nginx/conf.d/
EXPOSE 81
CMD ["nginx","-g","daemon off;"]
编写docker-compose
[root@web01 /server/docker-compose/exam_html]# cat docker-compose.yml
services:
exam_qian:
image: "web:exam_qian"
build:
context: .
dockerfile: Dockerfile
container_name: exam_v1
ports:
- 81:81
restart: always
学之思前端配置文件
[root@web01 /server/docker-compose/exam_html]# cat exam.conf
server {
listen 81;
server_name admin.zmx.cn;
root /app/code/exam/admin;
location / {
index index.html;
}
location /api/ {
proxy_pass http://10.0.0.3:8000;
}
}
server {
listen 81;
server_name stu.zmx.cn;
root /app/code/exam/student;
location / {
index index.html;
}
#转发动态资源到后端服务器
location /api/ {
proxy_pass http://10.0.0.3:8000;
}
}
apt源文件
[root@web01 /server/docker-compose/exam_html]# cat sources.list
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
# deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
构建镜像
cd /server/docker-compose/exam_html
#构建镜像
docker-compose build
#启动容器
docker-compose up -d
本机IP访问测试
接入负载均衡与高可用服务
配置七层负载
[root@lb01 /etc/nginx/conf.d]# cat exam.conf
upstream l7_pools {
server 10.0.0.7:81;
server 10.0.0.8:81;
hash $remote_addr consistent;
}
server {
listen 81;
server_name admin.zmx.cn;
location / {
proxy_pass http://l7_pools;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-Ip $remote_addr;
}
}
server {
listen 81;
server_name student.zmx.cn;
location / {
proxy_pass http://l7_pools;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-Ip $remote_addr;
}
}
配置四层负载
[root@lb01 ~]# cat /etc/nginx/nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
#四层负载
stream {
upstream exam_pools {
server 10.0.0.9:8000;
server 10.0.0.10:8000;
hash $remote_addr consistent;
}
log_format basic '$remote_addr [$time_local]'
'$protocol $status $bytes_sent $bytes_received'
'$session_time';
access_log /var/log/nginx-14.log basic;
server {
listen 8000;
proxy_pass exam_pools;
}
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
#检查高可用VIP
hostname -I
本机IP访问测试
IP解析到本地hosts解析

- 学生端
账号:student
密码:123456


- 教师端
账号:admin
密码:123456


学之思接入七牛云存储
七牛云存储空间
新建空间

复制存储域名

复制AK密钥

access-key: 4ZhEl3CKC0O0cp4hItsKi1M-NiS0H_hBy7Mjm_JC
secret-key: i2PTbPBEwz6kkPekOUQ2Jvw7oSWckd6MaWgEuMoQ
配置后端服务器连接文件
vim /server/docker-compose/exam_java/application-prod.yml

server:
port: 8000
undertow:
io-threads: 16
worker-threads: 4000
buffer-size: 1024
direct-buffers: true
compression:
enabled: true
min-response-size: 1
#日志
logging:
path: /app/code/exam/
#数据库,redis等等配置
spring:
datasource:
#mysql://数据库地址:端口号/库名字?
url: jdbc:mysql://172.16.1.52:3306/exam?useSSL=false&useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: exam
password: exam
driver-class-name: com.mysql.cj.jdbc.Driver
system:
qn:
url: t10vpntjo.hn-bkt.clouddn.com
bucket: zhangmx
access-key: 4ZhEl3CKC0O0cp4hItsKi1M-NiS0H_hBy7Mjm_JC
secret-key: i2PTbPBEwz6kkPekOUQ2Jvw7oSWckd6MaWgEuMoQ
region: z2
up-host: http://up-z2.qiniup.com
上传图片测试

