线上考试系统部署(thirty-six day)

一、线上考试系统的数据 虚拟化技术部署

1、部署前端服务器

(1)将资源上传到服务器
scp -r dist/ root@192.168.1.11:~
(2)创建基础容器 在服务器上
systemctl start docker.service

docker pull centos

docker run -it --name c1 centos:latest /bin/bash
(3)在容器中修改yum源
rm -rf /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo  #阿里云镜像

yum clean all && yum makecache
(4)在容器中安装epel
yum -y install epel-release
(5)在容器中安装nginx
yum -y install nginx
(6)ctrl+p+q
(7)导出tar包
docker export -o centos_nginx.tar c1
(8)引入tar包,称为镜像
docker import -m "山不向我走来,我就向山走去" centos_nginx centos:nginx
(9)查看镜像
docker images ls
docker images

(10)停用c1容器,删除c1容器
docker stop c1
docker rm c1
(11)创建新的centos nginx容器,在创建的同时指定端口,以及挂载目录
docker run -it --name c1 -p80:80/tcp -v /opt/:/usr/share/nginx/html/ centos:nginx /bin/bash

nginx      #在容器内部启动nginx

ctrl+p+q

cp -r dist/* /opt/
(12)浏览器访问192.168.1.11

2、docker创建mysql环境

(1)启动docker守护进程 
systemctl start docker.service
(2)搜索mysql镜像
docker search mysql
(3)拉取mysql镜像
docker pull mysql
(4)创建镜像容器
[root@Docker ~]# docker run -it --name mysql0 mysql:latest /bin/bash
(5)管理mysql
[root@Docker ~]# docker exec -it m0 mysql -uroot -proot
具体操作
[root@Docker ~]# systemctl start docker

[root@Docker ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
centos       nginx     28eae436e8fc   3 hours ago   366MB
centos       latest    5d0da3dc9764   2 years ago   231MB

[root@Docker ~]# docker run -it --name mysql0 mysql:latest /bin/bash
Unable to find image 'mysql:latest' locally
latest: Pulling from library/mysql
6e839ac3722d: Pull complete 
ad912193ad5f: Pull complete 
25d13d87fd8d: Pull complete 
004d383c75ef: Pull complete 
6d9bbc82a0b8: Pull complete 
81fec07ea550: Pull complete 
83357cb2d3a5: Pull complete 
8ffe968b82c1: Pull complete 
30dfd9a7ed57: Pull complete 
35844ae33cbe: Pull complete 
Digest: sha256:86cdfe832c81e39a89cfb63c3fde1683c41cc00ef91e67653c9c1df0ba80f454
Status: Downloaded newer image for mysql:latest
bash-5.1# 

bash-5.1# exit
exit

[root@Docker ~]# docker ps --all
CONTAINER ID   IMAGE          COMMAND                   CREATED          STATUS                     PORTS                               NAMES
ce66ba050af6   mysql:latest   "docker-entrypoint.s…"   39 seconds ago   Exited (0) 8 seconds ago                                       mysql0
4e6ec10ab435   centos:nginx   "/bin/bash"               3 hours ago      Up 3 hours                 0.0.0.0:80->80/tcp, :::80->80/tcp   c1

[root@Docker ~]# docker start mysql0
mysql0

[root@Docker ~]# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
Digest: sha256:86cdfe832c81e39a89cfb63c3fde1683c41cc00ef91e67653c9c1df0ba80f454
Status: Image is up to date for mysql:latest
docker.io/library/mysql:latest

[root@Docker ~]# docker run -d --name m0 -e MYSQL_ROOT_PASSWORD=root -p3306:3306 mysql:latest
2d4f51a55f6e5e6e955550e7ddf71f390d53313d15e785f96ecd2bae3fd902d4

[root@Docker ~]# docker ps
CONTAINER ID   IMAGE          COMMAND                   CREATED          STATUS          PORTS                                                  NAMES
2d4f51a55f6e   mysql:latest   "docker-entrypoint.s…"   18 seconds ago   Up 17 seconds   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   m0
ce66ba050af6   mysql:latest   "docker-entrypoint.s…"   4 minutes ago    Up 3 minutes    3306/tcp, 33060/tcp                                    mysql0
4e6ec10ab435   centos:nginx   "/bin/bash"               3 hours ago      Up 3 hours      0.0.0.0:80->80/tcp, :::80->80/tcp                      c1

[root@Docker ~]# docker exec -it m0 mysql -uroot -proot
mysql> 

打开Navicat连接虚拟机mysql,然后上传sql文件,在进入虚拟机查看

mysql> show databases;
+---------------------+
| Database            |
+---------------------+
| information_schema  |
| mysql               |
| performance_schema  |
| project_exam_system |
| sys                 |
+---------------------+
5 rows in set (0.00 sec)

mysql> use project_exam_system;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-------------------------------+
| Tables_in_project_exam_system |
+-------------------------------+
| admin                         |
| category                      |
| com_city                      |
| com_nation                    |
| course                        |
| dept                          |
| dept_student                  |
| exam                          |
| exam_dept                     |
| exam_process 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值