发表于: 2017-05-23 10:22:33
2 1286
今天完成的任务:
一:部署两台WEB,使用Nginx的Upstream来做负载。重新压测.
改变nginx.conf配置想让它生效而不停止服务,如下两种方式都可以:
1) nginx -t; nginx -s reload
2) nginx -t; kill -HUP
nginx -t 检查nginx配置的语法,操作前都要检查一下,很重要,发现错误可及时修正.
以下是昨天配置时候的几个关键句
proxy http://tomcat_local
http://tomcat_local/task-five
hosts
upstream A{}
http://A ?
下面是nginx.conf里面的具体配置
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
# upstream www.dreamguys.org(这里可以将tomcat_local改成这个域名,后面不用proxy_set_header也可以直接访问)
upstream tomcat_local {
# server locahost:8090(加上这一段可以用来加上jetty做8090端口,配置成负载均衡的方式)
server localhost:8080;
}
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
server {
listen 80;
server_name localhost www.dreamguys.org www.dreamguys.org:8080;
# charset koi8-r;
# access_log logs/host.access.log main;
location / {
root html;
index index.jsp index.html mytask8-1.html;
# proxy_pass http://www.dreamguys.org
proxy_pass http://tomcat_local;
#下面这句配置在用tomcat_local这个化名是必须使用,不然服务器解析不到正确的地址
proxy_set_header Host $host;
}
}
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
二.老大Java课程讲解
一.基础环境的搭建
1.Java
2.Maven
3.svn/git
4.eclipse/idea
5.navicat
6.Mysql
1.关系型数据库
2.简单的Sql语句
3.Dal的设计和缓存
4.Dao和Service
5.DynamicSql
三.REST
1.REST
2.Spring MVC
四.分布式
1.SCA/Tuscany
2.Scallop
ps:jar-core,War-web,Tar.gz-service
dal 处理缓存的
1.Excel
2.code-generate
3.code-web
六.打包部署
1.Snapshot和Release
2.Start.sh,


3.stdout.log stderr.log
遇到的问题:
在做Nginx+Tomcat的时候,一直存在以下问题,昨天都解决了
浏览器输入域名显示的是Tomcat的官网首页,而不是自己项目首页.
解决:在Tomcat中server.xml文件中,做如下蓝色部分配置
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<Context
path=""
docBase="/usr/local/tomcat7/webapps/task-five"
debug="0"
reloadable="true"/>
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
收获:
Nginx本身很灵活,需要多用才知道其中的各种功能.加油!
明年的计划:
着手service和web的分离.
评论