项目部署

练手项目

停车场系统

  1. 安装python
    1. 安装依赖
      1. 通过 gcc --version 查看,没安装的先安装 yum -y install gcc
      2. 安装其它依赖包 yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
    2. python下载与解压
      1. 下载 wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
      2. 解压 tar -zxvf Python-3.7.3.tgz
    3. 创建目录 mkdir /usr/local/python3
    4. 编译
      1. cd Python-3.6.5
      2. ./configure --prefix=/usr/local/python3
      3. make && make install
    5. 创建软链
      1. ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
      2. ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
    6. 查看版本号 python3 -V(pip3 -V)
  2. mysql安装
    1. 安装命令 yum -y install mariadb mariadb-server
    2. 安装完成MariaDB,首先启动MariaDB systemctl start mariadb
    3. 设置开机启动 systemctl enable mariadb
    4. 取消开机启动 systemctl disable mariadb
  3. 项目包处理
    1. 解压ParkingSys-master.zip代码包到当前目录
    2. 进入源码目录 /opt/ParkingSys-master/ParkingSysApi
  4. 安装程序依赖包
    1. pip3 install -r requirements.txt
    2. pip3 install -r requirements.txt --trusted-host=pypi.python.org --trusted-host=pypi.org --trusted-host=files.pythonhosted.org
  5. 创建数据库
    1. 进入数据库使用mysql -u root -p CREATE DATABASE parking CHARSET=UTF8
    2. 找到config.py 数据的密码设定好,如果没有密码把 :123456 去除掉
  6. 启动停车场系统
    1. 切换目录 cd /opt/ParkingSys-master
    2. 启动停车场系统 执行 python3 apprun.py &
  7. navicat客户端连接数据库,更改mysql数据权限表
    1.进入数据库 mysql -u root -p
    2. use mysql;
    3. update user set Host = '%' where User = 'root' and Host = 'localhost.localdomain';
  8. 重新启动数据库 systemctl restart mariadb
  9. 关闭防火墙(已经关闭的时候可以忽略) systemctl stop firewalld systemctl disable firewalld
  10. 本地连接不上Linux虚拟机mysql
  11. 进入到数据库 mysql -u root -p
  12. 输入命令进行权限设置 grant all privileges on . to root@"%" identified by "密码";(这表示是给本地ip赋予了所有的权限,包括远程访问权限,%百分号表示允许任ip访问数据库。)
  13. 重新加载 flush privileges;
  14. 重启数据库 systemctl restart mariadb

国家电网

  1. 安装centos7操作系统
  2. 检查网络,配置网络参数
    1. ip addr 查看IP地址
    2. /etc/sysconfig/network-scripts/ifcfg-ens33网卡配置文件,将onboot=no改为yesIPV6开头的配置项全部#注释掉
    3. 重启操作系统reboot systemctl restart network
    4. 改为桥接模式继续重启 systemctl restart network
  3. /opt目录下安装JDK
    1. tar -zxvf jdk-8u144-linux-x64.tar.gz(可使用命令 wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz")
    2. vi /etc/profile,在profile下添加如下:
      1. export JAVA_HOME=/opt/jdk1.8.0_144
      2. export PATH=\(JAVA_HOME/bin:\)PATH
      3. export CLASSPATH=.:\(JAVA_HOME/lib/dt.jar:\)JAVA_HOME/lib/tools.jar
      4. source /etc/profile
      5. java -version 检查jdk安装是否完好
    3. 在添加环境的时候,执行之后,导致vi命令不能使用的时候使用如下命令 export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/us
  4. /opt 安装tomcat中间件
    1. tar zxvf apache-tomcat-7.0.82.tar.gz
    2. 目录apache-tomcat-7.0.82名称修改为tomcat
    3. 命令关闭防火墙(先查看是否关闭,已经关闭忽略此步骤) systemctl stop firewalld #停止firewall systemctl disable firewalld #禁止firewall开机启动
    4. 启动tomcat tomcat/bin/startup.sh
    5. 用浏览器访问,http://:8080 测试tomcat安装是否完好
  5. 安装mysql数据库
    1. yum -y install mariadb mariadb-server
    2. 启动MariaDB systemctl start mariadb
    3. 设置开机启动 systemctl enable mariadb
    4. 修改数据库密码(可以不做)mariadb root用户,密码默认为空 mysql_secure_installation
  6. 部署应用
    1. 将KBMS.war拷贝到tomcat/webapps/目录下
    2. 使用脚本创建数据库以及表 mysql -u root -p 以root用户登录数据库 mysql
    3. source /opt/KBMS.sql
  7. 配置数据库连接
    1. 将KBMS.xml数据库配置文件拷贝到tomcat/conf/Catalina/localhost/并且打开修改数据库密码为空 vi tomcat/conf/Catalina/localhost/KBMS.xml→password=""
    2. 打开/etc/my.cnf 在[mysqld]下添加skip-grant-tables
  8. 重新启动mysql
    1. systemctl stop mariadb
    2. systemctl start mariadb
  9. 重新启动tomcat
    1. tomcat/bin/shutdown.sh
    2. tomcat/bin/startup.sh
  10. 浏览器打开应用 http://{ip地址}:8080/KBMS
  11. 修改tomcat默认端口号(8080)tomcat/conf/server.xml 将8080修改为80
  12. 浏览器再次打开应用 http://{ip地址}/KBMS
  13. 查看tomcat日志
    1. 日志所在位置在 tomcat/logs/catalina.out
    2. 根据error/excption 去查找错误内容
  14. mysql默认端口号是3306 oracle 默认端口号是1521
posted @ 2020-11-18 09:00  SunFree  阅读(144)  评论(0编辑  收藏  举报