1. 防火墙端口修改
- vi /etc/sysconfig/iptables
- 增加:-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
- 重启生效:service iptables restart
2.tomcat 多实例启动修改端口
(1).修改http访问端口(默认为8080端口):
<Connector port=”8080” protocol=”HTTP/1.1″
connectionTimeout=”20000″
redirectPort=”8443″ URIEncoding=”gb2312″/>
(2).修改Shutdown端口(默认为8005端口):
<Server port=”8005” shutdown=”SHUTDOWN”>
(3).修改JVM启动端口(默认为8009端口):
<Connector port=”8009” protocol=”AJP/1.3″ redirectPort=”8443″ />
3. nginx启动和停止
- /usr/local/nginx-1.7.8/sbin/nginx
- /usr/local/nginx-1.7.8/sbin/nginx -s reload
- /usr/local/nginx-1.7.8/sbin/nginx -s stop
4.nginx集群主要配置
http {
upstream tomcat {
server localhost:8080;
server localhost:8081;
}
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost:8888;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://tomcat;
}
...
}
5. redis 启动和停止
redis-server /etc/redis/6379.conf
redis-cli
key "*" 和 get "xxx" 查看session数据
6. tomcat中用到的lib
commons-pool2-2.0.jar jedis-2.5.2.jar redissession.jar
下载地址
7. tomcat中context.xml配置session复制
<Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
<Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
host="localhost"
port="6379"
database="0"
maxInactiveInterval="60" />