[关闭]
@yanglt7 2019-02-22T13:54:45.000000Z 字数 2794 阅读 572

厚朴图书设备管理系统上线

网管


虚拟机 ip 功能
LibrarySystem 10.99.1.6 项目主机
Nginx 10.99.1.8 Nginx 主机
PFW001 10.99.1.253&202.116.83.x 端口转发机

本机测试

虚拟机搭建

参考 【Web 集群实战】05_CentOS 7.x 系统安装后的基本配置及调优

安装 Nodejs

  1. wget https://nodejs.org/dist/v9.9.0/node-v9.9.0-linux-x64.tar.xz
  2. tar -xvf node-v9.9.0-linux-x64.tar.xz
  3. mv node-v9.9.0-linux-x64 nodejs
  4. ln -s /Software/nodejs/bin/node /usr/local/bin/
  5. ln -s /Software/nodejs/bin/npm /usr/local/bin/

参考链接:https://www.cnblogs.com/liuqi/p/6483317.html

安装淘宝镜像

  1. npm install -g cnpm --registry=https://registry.npm.taobao.org
  2. npm install

安装 MySQL

  1. tar -xvf mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz
  2. mv mysql-5.5.62-linux-glibc2.12-x86_64 mysql
  3. ll support-files/*.cnf
  4. /bin/cp support-files/my-small.cnf /etc/my.cnf
  5. mkdir /Data/mysql_data
  6. /Software/mysql/scripts/mysql_install_db --basedir=/Software/mysql --datadir=/Software/mysql/data --user=mysql
  7. cp support-files/mysql.server /etc/init.d/mysqld
  8. chmod +x /etc/init.d/mysqld
  9. sed -i 's#/usr/local/mysql#/Software/mysql#g' /Software/mysql/bin/mysqld_safe /etc/init.d/mysqld
  10. /etc/init.d/mysqld start
  11. netstat -lntup|grep mysql
  12. chkconfig --add mysqld
  13. chkconfig mysqld on
  14. echo 'export PATH=/Software/mysql/bin:$PATH' >>/etc/profile
  15. source /etc/profile
  16. echo $PATH
  17. mysqladmin -u root password 'password'

导入项目文件及数据库文件

  1. source /Data/HopeLibrarySystem-master/hopeWechat.sql

导入集群

vmx 转 ovf

  1. cd C:\Program Files (x86)\VMware\VMware Workstation\OVFTool
  2. ovftool D:\HopeLibrarySystem\HopeLibrarySystem.vmx D:\HopeLibrarySystem.ovf

参考链接:
https://blog.51cto.com/wangchunhai/1884052
https://blog.51cto.com/wangchunhai/1884053

配置网络

  1. DEVICE=ens33
  2. IPADDR=10.99.1.6 // 内网 ip
  3. GATEWAY=10.99.1.253 // 端口转发机内网 ip
  4. BOOTPROTO=static
  5. NETMASK=255.255.255.0
  6. TYPE=Ethernet
  7. NM_CONTROLLED=yes
  8. IPV6INIT=no
  9. ONBOOT=yes
  10. PROXY_METHOD=none
  11. BROWSER_ONLY=no
  12. PREFIX=24
  13. DEFROUTE=yes
  14. IPV4_FAILURE_FATAL=no
  15. NAME="System ens33"
  16. UUID=c96bc909-188e-ec64-3a96-6a90982b08ad
  17. ZONE=trusted

端口转发 (PFW001)

在端口转发机(10.86.1.253&202.116.83.x)中,修改端口转发机的 iptables:

  1. -A PREROUTING -d 202.116.83.x/32 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.99.1.13:80 // 原来占据 80 端口的 web 服务器,这条规则删掉
  2. iptables -t nat -A PREROUTING -d 202.116.83.x/32 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.99.1.8:80 // 将 80 端口转发给 Nginx 主机
  3. service iptables save
  4. service iptables reload

安装 Nginx(Nginx 主机)

新建另一台主机,配置 Nginx 服务。

【Web 集群实战】06_Nginx 安装与虚拟主机配置

配置文件:

  1. worker_processes 1;
  2. events {
  3. worker_connections 1024;
  4. }
  5. http {
  6. include mime.types;
  7. default_type application/octet-stream;
  8. sendfile on;
  9. keepalive_timeout 65;
  10. log_format main '$remote_addr - $remote_user [$time_local] '
  11. : '"$request" $status $body_bytes_sent '
  12. : '"$http_referer" "$http_user_agent" "$http_x_forwarded_for"';
  13. server {
  14. listen 80;
  15. access_log logs/access.log;
  16. server_name 202.116.83.xx;
  17. location / {
  18. proxy_pass http://10.99.1.13;
  19. }
  20. location /hopelibrary/ {
  21. rewrite ^/hopelibrary/(.*)$ /$1 break;
  22. proxy_pass http://10.99.1.6:3000/;
  23. }
  24. }
  25. }

pm2 后台永久运行

  1. pm2 start bin/www
  2. pm2 start bin/www --name hopelibrary
  3. pm2 save
  4. pm2 startup
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注