Linux系统集群架构线上项目配置实战(二)

简介:

分发hosts文件到其它服务器
分发服务器使用全网备份服务器
首先创建分发用户

[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用户创建密钥
Linux系统集群架构线上项目配置实战(二)
安装配置expect服务
[root@centos ~]$ yum install expect* -y
编写脚本
Linux系统集群架构线上项目配置实战(二)

[fenfa@centos ~]$ vim fenfa.exp
#!/usr/bin/expect
if {$argc != 2} {
send_user "usage: expect xxxx.exp file host\n"
  it
}
#define var
set file [lindex $argv 0]
set host [lindex $argv 1]
set password "123456"

spawn ssh-copy-id -i $file  fenfa@$host
expect {
        "yes/no"   {send "yes\r";exp_continue}
         "password" {send "$password\r"}
}
expect eof
[fenfa@centos ~]$ vim fenfa_key.sh
#!/bin/sh
. /etc/init.d/functions
for ip in `cat host.list`
do
expect fenfa.exp ~/.ssh/id_dsa.pub $ip >/dev/null 2>&1
if [ $? -eq 0 ];then
   action "$ip" /bin/true
 else
   action "$ip" /bin/false
fi
done 

执行脚本结果如下

[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

编写分发文件脚本
Linux系统集群架构线上项目配置实战(二)
Linux系统集群架构线上项目配置实战(二)
只需要将文件替换成你所需要分发的文件即可

前端反向代理及管理后台服务器的配置
前端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;
    }
}

业务平台管理后台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

商家管理后台 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

Linux系统集群架构线上项目配置实战(二)
模拟用户访问
Linux系统集群架构线上项目配置实战(二)



本文转自 民工哥 51CTO博客,原文链接:http://blog.51cto.com/mingongge/2056986

相关文章
|
1天前
|
Oracle Java 关系型数据库
Linux环境安装配置JDK11
Linux环境安装配置JDK11
17 0
|
1天前
|
Ubuntu Linux
Linux(Ubuntu)系统临时IP以及静态IP配置(关闭、启动网卡等操作)
请注意,以上步骤是在临时基础上进行配置的。如果要永久保存静态IP地址,通常还需要修改 `/etc/network/interfaces`文件,以便在系统重启后保持配置。同时,确保备份相关配置文件以防止出现问题。
13 1
|
2天前
|
Linux 数据安全/隐私保护
Linux系统忘记密码的三种解决办法
这篇博客介绍了三种在Linux忘记密码时重置登录密码的方法:1) 使用恢复模式,通过控制台界面以管理员权限更改密码;2) 利用Linux Live CD/USB启动,挂载硬盘分区并使用终端更改密码;3) 进入单用户模式,自动以管理员身份登录后重置密码。每个方法都提供了详细步骤,提醒用户在操作前备份重要数据。
|
2天前
|
JSON Unix Linux
Linux系统之jq工具的基本使用
Linux系统之jq工具的基本使用
30 2
|
2天前
|
数据采集 监控 安全
linux系统被×××后处理经历
linux系统被×××后处理经历
|
3天前
|
监控 安全 Linux
Linux系统之安装ServerBee服务器监控工具
【4月更文挑战第22天】Linux系统之安装ServerBee服务器监控工具
41 2
|
3天前
|
缓存 Linux
linux系统缓存机制
linux系统缓存机制
|
3天前
|
Ubuntu Linux 测试技术
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试(下)
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试
35 1
|
3天前
|
运维 网络协议 Linux
Linux(28) Linux双网卡配置为连接到Linux主机的PC提供外网访问
Linux(28) Linux双网卡配置为连接到Linux主机的PC提供外网访问
31 1
|
3天前
|
存储 Linux Android开发
RK3568 Android/Linux 系统动态更换 U-Boot/Kernel Logo
RK3568 Android/Linux 系统动态更换 U-Boot/Kernel Logo
18 0