linux kvm虚拟化架构实战指南_Linux系统集群架构线上项目配置实战(二)

c006c0a50ccd17774a2263252a4fe6a1.png

接上一篇:Linux系统集群架构线上项目配置实战(一)

1、配置SSH免密登录

分发服务器使用全网备份服务器

首先创建分发用户

[root@centos ~]# useradd fenfa -u 999

[root@centos ~]# echo "123456"|passwd --stdin fenfa

Changing password for user fenfa.

passwd: all authentication tokens updated successfully.

[root@centos ~]# /bin/cp /etc/sudoers /etc/sudoers.bak

[root@centos ~]# echo "fenfa ALL=(root) NOPASSWD:/usr/bin/rsync" >>/etc/sudoers

[root@centos ~]# tail -1 /etc/sudoers

fenfa ALL=(root) NOPASSWD:/usr/bin/rsync

切换到fenfa用户创建密钥

012554302bf2c950faad0d95ef9eb675.png

2、配置expect批量分发工具

安装配置expect服务

[root@centos ~]$ yum install expect* -y

编写脚本

e7eabe763d3808f91ef3258c6e2856bc.png

eb27ae1a882b7edd9c68ee9980ff8428.png

执行脚本结果如下

[fenfa@centos ~]$ sh fenfa_key.sh

10.0.0.1    [  OK  ]

10.0.0.2   [  OK  ]

10.0.0.3   [  OK  ]

10.0.0.4    [  OK  ]

10.0.0.5    [  OK  ]

10.0.0.6   [  OK  ]

10.0.0.7   [  OK  ]

10.0.0.8   [  OK  ]

10.0.0.9   [  OK  ]

10.0.0.10  [  OK  ]

10.0.0.11  [  OK ]

10.0.0.12  [  OK  ]

10.0.0.13   [  OK  ]

10.0.0.14  [  OK  ]

切换到分发用户下查看是否分发成功

[root@centos ~]# su - fenfa

[fenfa@centos ~]$ ll /home/fenfa/.ssh/

total 4

-rw------- 1 fenfa fenfa 602 Sep 21 12:14 authorized_keys

根据上面的脚本编写分以hosts文件脚本

5fdfc1458d165db96b93379d249b48fa.png

脚本执行结果如下

sh fenfa_file.sh host.list /etc/

[fenfa@centos ~]$ ll /etc/host.list

-rw-rw-r-- 1 fenfa fenfa 131 Sep 16 12:45 /etc/host.list

6c79300401e787ec6b0b74af0c723d42.png

只需要将host.list文件替换成你所需要分发的文件就OK了,

3、前端反向代理及管理后台服务器的配置

前端nginx反向代理服务器配置

安装所需的依赖包

[root@centos ~]# yum install pcre-devel zlib-devle openssl-devel gcc-c++ –y

编译安装nginx

cd /download/tools/

wget http://nginx.org/download/nginx-1.12.1.tar.gz

tar zxf nginx-1.12.1.tar.gz

cd nginx-1.12.1

./configure --prefix=/app/nginx-1.12.1

make && make install

[root@centos ~]# cd /app/

[root@centos app]# ln -s nginx-1.12.1 nginx

[root@centos ~]# cd /app/nginx/conf/

[root@centos conf]# mkdir extra

[root@centos conf# cp nginx.conf nginx.conf.bak

在nginx.conf文件后增加下面的配置

include extra/*.conf;

[root@centos ~]# cd /app/nginx/conf/extra/

[root@centos extra]# vim admin.mingongge.conf

#
# HTTPS server configuration
# 

server {

    listen       80;

    server_name admin.mingongge.com;

    location / {

        proxy_pass http://10.0.0.6:8080;

        proxy_connect_timeout 600;

        proxy_read_timeout 600;

        proxy_send_timeout 600;

    }

}
[root@centos extra]# vim shangjia.mingongge.conf

#

# HTTPS server configuration

#

server {

    listen       80;

    server_name shangjia.mingongge.com;

    location / {

        proxy_pass http://10.0.0.7:8080;

        proxy_connect_timeout 600;

        proxy_read_timeout 600;

        proxy_send_timeout 600;

    }

}

业务平台管理后台http://admin.mingongge.com

JDK Tomcat环境安装

tar zxf apache-tomcat-8.5.9.tar.gz

mv apache-tomcat-8.5.9 /usr/local/tomcat

tar zxf jdk-8u111-linux-x64.tar.gz -C /usr/local/

cd /usr/local/

ln -s jdk1.8.0_111 jdk

cat >>/etc/profile <<EOF

export JAVA_HOME=/usr/local/jdk1.8.0_111

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$JAVA_HOME/bin:$PATH

export CATALINA_HOME=/usr/local/apache-tomcat-8.5.9

EOF

[root@centos local]# source /etc/profile

[root@centos local]# java -version

java version "1.8.0_111"

Java(TM) SE Runtime Environment (build 1.8.0_111-b14)

Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

JDK Tomcat环境配置

<Context path="" docBase="/www/admin" debug="0" reloadable="true" crossContext="true" />

echo "this is the admin.mingongge.com" >/www/admin/index.html

/usr/local/tomcat/bin/startup.sh

商家管理后台 http://shangjia.mingongge.com

JDK Tomcat环境安装请参考前面的步骤

<Context path="" docBase="/www/shangjia" debug="0" reloadable="true" crossContext="true" />

echo "this is the shangjia.mingongge.com" >/www/shangjia/index.html

/usr/local/tomcat/bin/startup.sh

测试反向代理

[root@centos ~]# curl http://admin.mingongge.com

this is the admin.mingongge.com

[root@centos ~]# curl http://shangjia.mingongge.com

this is the shangjia.mingongge.com

34ac64123fda4a8674e34f277214fbaf.png

模拟用户访问

a206eb875296c862a8b69a6dc5d43035.png

如有错误或其它问题,欢迎小伙伴留言评论、指正。如有帮助,欢迎点赞+转发分享。

更多相关开源技术文章,请持续关注民工哥知乎技术专栏。

我是民工哥,一个爱折腾的IT技术老司机,欢迎关注我,我们一起学习,共同成长!!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值