nginx 1.9 + tomcat8 + nfs 配置集群环境

启动tomcat8, 访问地址为:
192.168.1.207:8080
192.168.1.208:8080
nginx:
#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#yum makecache
#wget http://nginx.org/download/nginx-1.9.12.tar.gz
#tar zxvf nginx-1.9.12.tar.gz 
#cd nginx-1.9.12/
#./configure   
#yum -y install gcc  #安装c 编译环境
#./configure  --prefix=/usr/local/nginx 
#yum -y install pcre-devel openssl openssl-devel #安装错误: ./configure: error: the HTTP rewrite module requires the PCRE library.
#./configure  --prefix=/usr/local/nginx
#make && make install
#cd /usr/local/nginx/sbin/
#./nginx
#netstat -tunlpa





lsof -p 进程PID #查看进程在调用哪些文件


[root@pptp-redis opt]# ll
总用量 160156
drwxr-xr-x  9 root root      4096 7月  22 13:47 apache-tomcat-8.0.24
-rw-r--r--  1 root root   9106353 7月  22 13:23 apache-tomcat-8.0.24.tar.gz
-rw-r--r--  1 root root 153512879 7月  22 13:23 jdk-7u79-linux-x64.tar.gz
drwxrwxr-x  6 root root      4096 7月  14 15:42 redis-3.0.2
-rw-r--r--  1 root root   1360182 7月  14 15:10 redis-3.0.2.tar.gz
drwxr-xr-x. 2 root root      4096 11月 22 2013 rh
[root@pptp-redis opt]# tar zxf apache-tomcat-8.0.24.tar.gz 
[root@pptp-redis opt]# cd apache-tomcat-8.0.24
[root@pptp-redis apache-tomcat-8.0.24]# ./bin/startup.sh 
	Using CATALINA_BASE:   /opt/apache-tomcat-8.0.24
	Using CATALINA_HOME:   /opt/apache-tomcat-8.0.24
	Using CATALINA_TMPDIR: /opt/apache-tomcat-8.0.24/temp
	Using JRE_HOME:        /usr
	Using CLASSPATH:       /opt/apache-tomcat-8.0.24/bin/bootstrap.jar:/opt/apache-tomcat-8.0.24/bin/tomcat-juli.jar
	Tomcat started.
[root@pptp-redis apache-tomcat-8.0.24]# 

#user  nobody;
worker_processes  auto;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  10240;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;


    upstream sports_server {
        server 172.16.1.200:8080 weight=3;
        server 172.16.1.204:8080 weight=3;
    }

    server {
        listen       80;
        server_name  172.16.1.203;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm index.php;
            proxy_pass http://sports_server;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME   /usr/local/nginx/html$fastcgi_script_name;
            include        fastcgi_params;
        }

        #location ~ /\.ht {
        #    deny  all;
        #}
        location /nginx_stat {
                 stub_status on;       # Turn on nginx stats
                 access_log   off;     # We do not need logs for stats
                 allow 127.0.0.1;      # Security: Only allow access from IP
                 allow 172.16.1.195;
                 allow 172.16.1.188;
                 deny all;             # Deny requests from the other of the world
                }
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

nfs:centos 6.6 预装好了
服务端:
[root@203-test shared]# vim /etc/exports 
/opt/shared    172.16.1.0/24(rw,sync,no_root_squash)
说明:/opt/shared 为共享的目录位置; *(rw,no_root_squash)  *为任意IP都可以访问  rw为可进行读写访问  no_root_squash 为拥有这个目录所有者的权限。
[root@203-test shared]# service nfs restart
客户端:
 mount -t nfs -o rw 192.168.109.130:/opt/shared /opt/shared  命令完成挂载(远端/opt/shared  挂载到本地/opt/shared)
 要想每次启动机器的时候自动挂载,可使用命令 vi /etc/fstab 编辑,在最后面加上 192.168.109.130:/var/ftp  /nfs/ftp  nfs  defaults 0 0 ,保存退出。这样在每次启动的时候就会自动挂载 192.168.109.130:/var/ftp 这个NFS 共享了。
用 mount 方式挂载 NFS 并不是个很可靠的方式,当遇到断网或挂载时 NFS 服务器重启,都会导致客户端上的 NFS 无法访问的问题。但这也是能解决的,使用 autofs 服务的方式挂载就不会有这个问题了。回头找时间把这个经验也分享出来。
<span style="font-size:10px;">#umount /data1/logs/web1logs
umount.nfs: /data1/logs/web1logs: device is busy
umount.nfs: /data1/logs/web1logs: device is busy</span>
方法一:
fuser -m -v /data/
          用户  进程号  权限   命令
/data/:   root  2798    ..c..  bash
          root  2996    ..c..  su
如上所示,有两个进程占用了,将其kill掉,再重新取消挂载。
kill -9 2798 2996
umount /data1/logs/web1logs

方法二:
umount  -l  /data1/logs/web1logs

方法三:
fuser -km /data1/logs/web1logs



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值