Page tree
Skip to end of metadata
Go to start of metadata

环境说明

操作系统:CentOS 7.x

  1. MySQL(数据库)
    1. 版本:MySQL 5.6
    2. 安装目录:/home/mysql
    3. 数据目录:/home/mysql/data
    4. root用户密码:MYdb@2019%com
    5. 程序连接地址:mysql-server:3306
    6. 程序连接用户:iotp 
    7. 程序连接密码:IOTP@2019%com
  2. 基础服务(docker运行)
    1. rabbitmq(消息队列)
      1. 端口:5672
      2. 账号:admin
      3. 密码:Rabbitmq@2019%com
    2. redis-server(Redis)
      1. 端口:6379
      2. 密码:Redis@2019%com
    3. Zookeeper(注册中心)
      1. 端口:2181
    4. kkfileview(文档在线预览)
      1. 端口:8012
      2. 域名:http://view.aftvc.com
  3. 依赖组建(docker运行)
    1. user-center(用户中心)
      1. 端口:8000
    2. attach-center(附件中心)
      1. 端口:8001
      2. 域名:http://file.aftvc.com
    3. xxl-job-admin(任务调度中心)
      1. 端口:8002
      2. 域名:http://xxl-job.aftvc.com
      3. 控制台账号:admin
      4. 控制台密码:XxlJob@2019%com
  4. 后端服务(docker运行)
    1. manager(管理端)
      1. 端口:8003 
      2. 访问地址:http://manager.aftvc.com
    2. student(学生端)
      1. 端口:8004
    3. teacher(教师端)
      1. 端口:8005
  5. 前端页面(Nginx代理)
    1. stu-html(学生端)
      1. 访问地址:http://stu.aftvc.com
      2. 静态页面路径:/home/nginx/html/stu-html
    2. tch-html(教师端)
      1. 访问地址:http://tch.aftvc.com
      2. 静态页面路径:/home/nginx/html/tch-html

一、安装前准备

1、安装常用软件包

yum -y install lrzsz wget vim zip net-tools 

2、配置防火墙并关闭SElinux

# 开放80和3306端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload

# 关闭SELinux
setenforce 0 
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config 

3、下载项目文件到/root目录并解压

wget http://wget.itcast.cn/iotp-ahcm.zip
unzip iotp-ahcm.zip 

4、安装docker

# 设置 yum repository 
yum install -y yum-utils device-mapper-persistent-data lvm2 
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 安装并启动 docker 
yum install -y docker-ce-18.09.7 docker-ce-cli-18.09.7 containerd.io
systemctl enable docker 
systemctl start docker 
# 安装docker-compose
cp /root/itcast-iotp/docker-compose /usr/local/sbin/
chmod +x /usr/local/sbin/docker-compose 

5、设置docker镜像仓库

mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
  "bip": "10.30.1.0/16",
  "registry-mirrors": ["https://9e73zm0u.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker

6、登入docker仓库

docker login registry.cn-hangzhou.aliyuncs.com
Username: itcast_bxg
Password: Itcast2019!@#$%
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

二、部署数据库

1、卸载centos7自带mariadb并安装mysql依赖包

yum remove -y mariadb-* 
yum -y install gcc gcc-c++ libaio bison ncurses-devel readline-devel autoconf

2、创建mysql用户组

groupadd mysql && useradd -g mysql mysql -s /sbin/nologin 

3、上传并解压压缩文件

cd /root/itcast-iotp/mysql
tar zxvf mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz 
mv mysql-5.6.46-linux-glibc2.12-x86_64/* /home/mysql/ 
mkdir -p /home/mysql/logs && touch /home/mysql/logs/mysql.err 
chown -R mysql.mysql /home/mysql 

4、上传[my.cnf]到/etc/目录下后初始化数据库

cp /root/itcast-iotp/mysql/my.cnf /etc/my.cnf 
mkdir -p /etc/my.cnf.d 
cd /home/mysql/scripts/
./mysql_install_db --user=mysql --basedir=/home/mysql/ --datadir=/home/mysql/data 

5、配置环境变量

echo "MYSQL_HOME=/home/mysql" >>/etc/profile 
echo "PATH=\$PATH:\$MYSQL_HOME/bin" >> /etc/profile 
source /etc/profile 

6、启动mysql并配置开启自启

cp /home/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld 
sed -i 's#/usr/local#/home#' /etc/rc.d/init.d/mysqld 
chkconfig --add mysqld 
chkconfig mysqld on 
systemctl start mysqld 
systemctl status mysqld 

7、设置数据库root登入密码

mysqladmin -uroot password 'MYdb@2019%com' 

8、创建数据库并导入数据文件

mysql -uroot -pMYdb@2019%com
# ----------------- 以下命令在数据库中执行 ---------------------
create database attachment_center; 
use attachment_center;
source /root/itcast-iotp/mysql/initsql/attachment_center.sql;

create database user_center;
use user_center;
source /root/itcast-iotp/mysql/initsql/user_center.sql

create database university;
use university;
source /root/itcast-iotp/mysql/initsql/university.sql;

create database xxl_job;
use xxl_job;
source /root/itcast-iotp/mysql/initsql/xxl_job.sql;

CREATE USER 'iotp'@'%' IDENTIFIED BY 'IOTP@2019%com';
GRANT SELECT, INSERT, UPDATE, DELETE,EXECUTE, CREATE ROUTINE, ALTER ROUTINE ON *.* TO 'iotp'@'%';
exit; 

三、更改配置文件

mkdir /home/itcast-iotp
cp -r /root/itcast-iotp/docker/* /home/itcast-iotp/
# 获取服务器IP地址
ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.157  netmask 255.255.255.0  broadcast 172.17.0.255
        inet6 fe80::5054:ff:feeb:796d  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:eb:79:6d  txqueuelen 1000  (Ethernet)
        RX packets 827357  bytes 949760036 (905.7 MiB)
        RX errors 0  dropped 16313  overruns 0  frame 0
        TX packets 299451  bytes 24237850 (23.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# 更改配置文件中IP地址(此文档中服务器地址为172.17.0.141,请根据真实情况设置)
sed -i 's/IPAddress/172.17.0.141/' /home/itcast-iotp/docker-compose.yml

四、部署容器

cd /home/itcast-iotp
docker-compose up -d
docker-compose ps 
    Name                   Command               State                                      Ports                                    
-------------------------------------------------------------------------------------------------------------------------------------
attach-center   catalina.sh run                  Up      0.0.0.0:8001->8080/tcp                                                      
iotp-manager    catalina.sh run                  Up      0.0.0.0:8003->8080/tcp                                                      
iotp-student    catalina.sh run                  Up      0.0.0.0:8004->8080/tcp                                                      
iotp-teacher    catalina.sh run                  Up      0.0.0.0:8005->8080/tcp                                                      
kkfileview      java -Dfile.encoding=UTF-8 ...   Up      0.0.0.0:8012->8012/tcp                                                      
rabbitmq        docker-entrypoint.sh rabbi ...   Up      15671/tcp, 0.0.0.0:15672->15672/tcp, 25672/tcp, 4369/tcp, 5671/tcp, 5672/tcp
redis-server    docker-entrypoint.sh redis ...   Up      0.0.0.0:6379->6379/tcp                                                      
user-center     catalina.sh run                  Up      0.0.0.0:8000->8080/tcp                                                      
xxl-job-admin   catalina.sh run                  Up      0.0.0.0:8002->8080/tcp                                                      
zookeeper       /docker-entrypoint.sh zkSe ...   Up      0.0.0.0:2181->2181/tcp, 2888/tcp, 3888/tcp, 8080/tcp   

注:全部启动后等待1分钟左右再重启以下三个后端,确保能连上注册中心。

docker restart iotp-manager iotp-student iotp-teacher

五、安装Nginx

# 安装依赖
yum -y install gcc gcc-c++ make libtool zlib zlib-devel pcre pcre-devel openssl openssl-devel
# 编译安装Nginx
tar zxf /root/itcast-iotp/nginx/nginx-1.16.1.tar.gz -C /tmp/
groupadd nginx && useradd -g nginx nginx -s /sbin/nologin
cd /tmp/nginx-1.16.1/
./configure --prefix=/home/nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-pcre --with-http_ssl_module --with-http_gzip_static_module --with-stream --user=nginx --group=nginx && make && make install
ln -s /home/nginx/sbin/nginx /usr/sbin/nginx

# 更改Nginx配置文件
/usr/bin/cp /root/itcast-iotp/nginx/nginx.conf /home/nginx/conf/
/usr/bin/cp -r /root/itcast-iotp/nginx/vhost /home/nginx/conf/

# 将前端文件移动到Nginx网页目录中
/usr/bin/cp -r /root/itcast-iotp/nginx/stu-html /home/nginx/html/
/usr/bin/cp -r /root/itcast-iotp/nginx/tch-html /home/nginx/html/
chown -R nginx.nginx /home/nginx/html

# 检测配置文件语法
nginx -t
# 检测显示以下内容说明配置成功
nginx: the configuration file /home/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /home/nginx/conf/nginx.conf test is successful
# 启动Nginx并加入开机自起
nginx
echo "/home/nginx/sbin/nginx" >> /etc/rc.local 

六、部署FTP服务用于上传视频

yum install -y vsftpd ftp 
useradd -d /home/itcast-iotp/data/attachment/video vsftp -s /sbin/nologin
chmod 755 -R /home/itcast-iotp/data/attachment/video
chown vsftp.root /home/itcast-iotp/data/attachment/video



六、配置DNS解析

平台名主机地址域名
管理端服务器出口IPmanager.aftvc.com
学生端服务器出口IPstu.aftvc.com
教师端服务器出口IPtch.aftvc.com
附件中心服务器出口IPfile.aftvc.com
文件预览服务器出口IPview.aftvc.com
xxl-job控制台服务器出口IPxxl-job.aftvc.com
MQ控制台服务器出口IPrabbitmq.aftvc.com

注:xxl-job和rabbitmq一般不做DNS解析,可在管理员电脑配置hosts方式访问。


Write a comment…