1、首先,利用scp复制命令配置其他linus服务器的jdk和maven环境
因为我的jdk和maven都安装在apps这个文件夹下面了,所以直接把这个文件夹复制过去其他的linus服务器就ok
最后再新的服务器中,执行刷新一下配置文件就OK了
2、安装nginx
#安装Nginx依赖包
[root@localhost hd]# yum install gcc-c++
[root@localhost hd]# yum install -y pcre pcre-devel
[root@localhost hd]# yum install -y zlib zlib-devel
[root@localhost hd]# yum install -y openssl openssl-devel
#解压:
[root@localhost hd]# tar -zxvf nginx-1.8.0.tar.gz
[root@localhost hd]# cd nginx-1.8.0
#配置
[root@localhost nginx-1.8.0]# configure
#安装
[root@localhost nginx-1.8.0]# make
[root@localhost nginx-1.8.0]# make install
#启动:
[root@localhost nginx-1.8.0]# cd /usr/local/nginx/sbin/
[root@localhost sbin]# ./nginx
#停止
[root@localhost sbin]# ./nginx -s quit
3、通过修改配置文件配置负载均衡nginx.conf,配置到其他的两台服务器
进入到 /usr/local/nginx/conf 路径中,然后输入vi nginx.conf修改配置文件,修改成如下的内容
#注意进入到配置文件中先找到server,然后upstream springboots这个语句是需要自己添加上去的
#192.168.101.5:8080 和 192.168.101.6:8080 是另外两台服务器的IP地址和端口,后面是权重,配置好之后就可以自动分发请求了
upstream springboots{
server 192.168.101.5:8080 weight=10;
server 192.168.101.6:8080 weight=10;
}
server {
listen 80;
location / {
proxy_pass http://springboots;
index index.jsp index.html index.htm;
}
}