Nginx+Tomcat+Redis+NFS搭建服务器集群


1、安装nginx及插件

a)  下载插件

https://github.com/yaoweibin/nginx_upstream_check_module从官网下载后解压。

b)  下载nginx,并添加模块

参考:http://www.linuxyan.com/web-server/90.html
首先去这里下载nginx的模块https://github.com/yaoweibin/nginx_upstream_check_module
下面是nginx打上模块补丁的安装

$ wget ‘http://nginx.org/download/nginx-1.9.2.tar.gz’
$ tar -xzvf nginx-1.9.2.tar.gz
$ cd nginx-1.9.2/
$ patch -p0 < /usr/local/src/nginx_upstream_check_module-master/check_1.9.2+.patch
注:因nginx版本更新,1.9以上版本的nginx,补丁为check_1.9.2+.patch
$ ./configure  --add-module=/usr/local/src /nginx_http_upstream_check_module

安装Nginx模块时报错

./configure:error: the HTTP rewrite module requires the PCRE library.

安装pcre-devel解决问题
yum -y install pcre-devel

./configure:error: the HTTP rewrite module requires the ZLIB  library.

则需要安装“zlib-devel”即可。SSH执行以下命令:
yum install -y zlib-devel

 

其他错误的解决方案

http://blog.csdn.net/hfsu0419/article/details/7190152

 

$ make
$ make install

 

c)  配置nginx为服务

http://www.cnblogs.com/meteoric_cry/archive/2011/01/27/1945882.html

 

2、安装redis

http://redis.io/download

 

3、  redis配置服务

http://jingyan.baidu.com/article/ad310e80cc7bf51849f49ec9.html

权限不够时,chmoda+x /etc/init.d/redis

 

4、  安装tomcat

Bin目录无权限时:

chmod u+x *.sh

 

环境变量清除

unset命令

unset CATALINA_HOME

unset CATALINA_BASE

unset  CATALINA_TMPDIR

unset CLASSPATH

http://soft.chinabyte.com/os/169/11412169.shtml

 

grep -r CATALINA_HOME /etc #查找环境变量所在位置

 

 

free –m  #查看内存大小

 

 

 

5、  安装NFS服务端

http://blog.chinaunix.net/uid-20628575-id-72545.html

http://blog.chinaunix.net/uid-20628575-id-72546.html

 

注意事项: service portmap start; 无法启动,是因为portmap已经改名,需使用service rpcbind start 启动服务;

120.25.65.241

 

showmount -e    //默认查看自己共享的服务,前提是要DNS能解析自己,不然容易报错

 

#临时挂载

mount -t nfs IP:/home/hboxs/bbct/static /home/hboxs/bbct/static

 

#服务端开机挂载

Etc/ rc.local文件里加上

servicerpcbind start

Service nfs start

servicenfslock start

 

#客户端开机挂载

Etc/fstab 文件里加上

IP:/home/hboxs/bbct/static/home/hboxs/bbct/static  nfs      defaults        0 0

 

Etc/ rc.local文件里加上

mount -t nfs IP:/home/hboxs/bbct/static /home/hboxs/bbct/static

 

 

6、安装JDK

http://blog.csdn.net/zhangxh1013/article/details/7320860

 


1、安装nginx及插件

a)  下载插件

https://github.com/yaoweibin/nginx_upstream_check_module从官网下载后解压。

b)  下载nginx,并添加模块

参考:http://www.linuxyan.com/web-server/90.html
首先去这里下载nginx的模块https://github.com/yaoweibin/nginx_upstream_check_module
下面是nginx打上模块补丁的安装

$ wget ‘http://nginx.org/download/nginx-1.9.2.tar.gz’
$ tar -xzvf nginx-1.9.2.tar.gz
$ cd nginx-1.9.2/
$ patch -p0 < /usr/local/src/nginx_upstream_check_module-master/check_1.9.2+.patch
注:因nginx版本更新,1.9以上版本的nginx,补丁为check_1.9.2+.patch
$ ./configure  --add-module=/usr/local/src /nginx_http_upstream_check_module

安装Nginx模块时报错

./configure:error: the HTTP rewrite module requires the PCRE library.

安装pcre-devel解决问题
yum -y install pcre-devel

./configure:error: the HTTP rewrite module requires the ZLIB  library.

则需要安装“zlib-devel”即可。SSH执行以下命令:
yum install -y zlib-devel

 

其他错误的解决方案

http://blog.csdn.net/hfsu0419/article/details/7190152

 

$ make
$ make install

 

c)  配置nginx为服务

http://www.cnblogs.com/meteoric_cry/archive/2011/01/27/1945882.html

 

2、安装redis

http://redis.io/download

 

3、  redis配置服务

http://jingyan.baidu.com/article/ad310e80cc7bf51849f49ec9.html

权限不够时,chmoda+x /etc/init.d/redis

当配置完后,修改6379.conf

设置daemonize 为 yes  重启服务,如果 service redis shutdown 提示 没有找到 redis_6379.pid, 那么可以用

src/redis-cli shutdown 关闭服务

4、  安装tomcat

Bin目录无权限时:

chmod u+x *.sh

 

环境变量清除

unset命令

unset CATALINA_HOME

unset CATALINA_BASE

unset  CATALINA_TMPDIR

unset CLASSPATH

http://soft.chinabyte.com/os/169/11412169.shtml

 

grep -r CATALINA_HOME /etc #查找环境变量所在位置

 

 

free –m  #查看内存大小

 

 

 

5、  安装NFS服务端

http://blog.chinaunix.net/uid-20628575-id-72545.html

http://blog.chinaunix.net/uid-20628575-id-72546.html

 

注意事项: service portmap start; 无法启动,是因为portmap已经改名,需使用service rpcbind start 启动服务;

120.25.65.241

 

showmount -e    //默认查看自己共享的服务,前提是要DNS能解析自己,不然容易报错

 

#临时挂载

mount -t nfs IP:/home/hboxs/bbct/static /home/hboxs/bbct/static

 

#服务端开机挂载

Etc/ rc.local文件里加上

servicerpcbind start

Service nfs start

servicenfslock start

 

#客户端开机挂载

Etc/fstab 文件里加上

IP:/home/hboxs/bbct/static/home/hboxs/bbct/static  nfs      defaults        0 0

 

Etc/ rc.local文件里加上

mount -t nfs IP:/home/hboxs/bbct/static /home/hboxs/bbct/static

 

 

6、安装JDK

http://blog.csdn.net/zhangxh1013/article/details/7320860


8、tomcat集群节点安装

  •      方式一:复制现有节点到新服务器,nginx添加节点,reload nginx配置文件
  •      方式二:全新tomcat7,复制jar包到tomcat的lib文件夹,修改conf文件夹中context.xml, 配置连接到redis 。将项目放置ROOT目录下, nginx添加节点,reload nginx配置文件

 tomcat-redis 所需jar包

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值