Linux系统集群架构在线项目配置实战(一)Linux系统集群架构在线项目配置实战(二)分发文件管理、前端反向代理、管理后台服务器的配置操作前面介绍过,今天介绍一下前端负载和APPServer(用户和商户)、官网、FTP服务器配置操作1.前端负载均衡配置和安装所需依赖包yuminstallpcre-develzlib-devleopenssl-develgcc-c++–y编译安装nginxcd/download/tools/wgethttp://nginx.org/download/nginx-1.12.1.tar.gztarzxfnginx-1.12.1.tar.gzcdnginx-1.12.1./configure--prefix=/app/nginx-1.12.1make&&makeinstall[root@centos~]#cd/app/[root@centosapp]#ln-snginx-1.12.1nginx[root@centos~]#cd/app/nginx/conf/[root@centosconf]#mkdirextra[root@centosconf]#cpnginx.confnginx.conf.bak在nginx.conf文件后添加如下配置includeextra/*.conf;[root@centosconf]#cdextra/[root@centosextra]#vimuser.app.conf##HTTPS服务器配置#upstreamuserapp{server10.0.0.4:8080;服务器10.0.0.4:8081;}服务器{听80;server_nameapp.mingonggepro.com;通过xy_location/{http://userapp;proxy_connect_timeout600;proxy_read_timeout600;proxy_send_timeout600;}[root@centosconf]#cdextra/[root@centosconf]#vimsj.app.conf##HTTPS服务器配置#upstreamsjapp{server10.0.0.5:8080;服务器10.0.0.5:8081;}服务器{听80;server\_namesjapp.mingongge.com;location/{proxy_passhttp://sjapp;proxy_connect_timeout600;proxy_read_timeout600;proxy_send_timeout600;}}2、后端APP服务器配置后端APP服务器JAVA环境安装配置[root@centostools]#lltotal181168-rw-r--r--1rootroot185515842-Sep20jd4k5-linux-x64.tar.gz[root@centostools]#tarzxfjdk-8u144-linux-x64.tar.gz-C/usr/local/[root@centostools]#ln-s/usr/local/jdk1.8.0_144/usr/local/jdk[root@centostools]#cat>>/etc/profile<****#添加上记站目录[root@centosconf]#mkdir/www/userapp-pecho"thisisthefristuserappserver">/www/userapp/index.html[root@centosconf]#../bin/startup.shUsingCATALINA_BASE:/usr/local/apache-tomcat-8.5.20使用CATALINA_HOME:/usr/local/apache-tomcat-8.5.20使用CATALINA_TMPDIR:/usr/local/apache-tomcat-8.5.20/temp使用JRE_HOME:/usr/local/jdk使用CLASSPATH:/usr/local/apache-tomcat-8.5.20/bin/bootstrap.jar:/usr/local/apache-tomcat-8.5.20/bin/tomcat-juli.jarTomcat已启动。[root@centosconf]#lsof-i:8080COMMANDPIDUSERFDTYPEDEVICESIZE/OFFNODENAMEjava1587root48uIPv6181370t0TCP*:webcache(LISTEN)另一个用户APP服务器按照上面的配置[root@centosconf]#mkdir/www/userapp-pecho"这是第二个userapp》>/www/userapp/index.html商户APP环境配置,请参考上面的配置[root@centosconf]#mkdir/www/sjapp-pecho"这是第一个sjapp">/www/userapp/index.htmlecho"thisisthesecondsjapp">/www/userapp/index.html接下来测试负载均衡前端负载均衡测试[root@centosconf]#curlhttp://10.0.0.1这是用户应用服务器[root@centosconf]#curlhttp://10.0.0.1这是第二个用户应用[root@centosconf]#curlhttp://app.mingongge.com这是userappserver[root@centosconf]#curlhttp://app.mingongge.com这是第二个userapp[root@centosextra]#curlhttp://sjapp.mingongge.com这是第一个sjappserver[root@centosextra]#curlhttp://sjapp.mingongge.com这是第二次sjapp浏览器访问测试本地浏览器测试需要配置hosts文件10.0.0.1app.mingongge.com10.0.0.1sjapp.mingongge.com3、官网和图片服务器配置的基本架构也和使用反向代理一样。为了后面扩展整体架构,NginxFTP的安装不再赘述。太简单了,也太累了。之前的反向代理配置如下[root@centosextra]#vimweb.mingongge.conf##HTTPS服务器配置#server{listen80;server_namewww.mingongge.com;location/{proxy_passhttp://10.0.0.8;proxy_connect_timeout600;proxy_read_timeout600;proxy_send_timeout600;}}[root@centosextra]#vimftp.mingongge.com##HTTPS服务器配置#server{listen80;服务器\_nameftp.mingongge.com;位置/{proxy_passhttp://10.0.0.8:88;proxy_connect_timeout600;proxy_read_timeout600;proxy_send_timeout600;tomingongge.swebstie!!!!!!!!!!!![root@centos~]#/usr/local/nginx/sbin/nginx-tnginx:配置文件/usr/local/nginx/conf/nginx.conf语法oknginx:配置文件/usr/local/nginx/conf/nginx.conf测试成功[root@centos~]#/usr/local/nginx/sbin/nginx[root@centos~]#curl10.0.0.8welcometomingongge.swebstie!!!!!!!!!!!!FTP的配置其实就是通过管理后台的应用上传图片,之前的用户可以通过nginx访问到正确的页面。但是由于离线测试环境,无法使用生产代码做实验,所以无法模拟管理后台上传的图片。过程是后台上传的图片通过FTP功能上传到指定目录,然后前端使用nginx调用这张图片。显示配置下可以访问图片[root@centosconf]#cdextra/[root@centosextra]#vimftp.mingongge.confserver{listen88;服务器名称本地主机;位置/{根/www/ftp;}upload图片通过前端反向代理测试直接访问域名读取图片,实现应用调用图片显示在其他前端页面的功能。可以找到,可以正常访问