प्रौद्योगिकी साझेदारी

discuz मञ्चं (lvs nginx http mysql nfs) 8 सर्वरं स्थापयतु

2024-07-08

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

discuz मञ्चस्य निर्माणं कुर्वन्तु (lvs nginx http mysql nfs)

1. IP योजना

सेवा नामIP पतासेवते
LVS1192.168.100.110keepalived ipvsadm
LVS2192.168.100.111keepalived ipvsadm
nginx1192.168.100.113ङिन्क्स
nginx2192.168.100.114ङिन्क्स
nfs192.168.100.116नफ्स-उटिल्
web1192.168.100.118httpd php nfs-util इति इति
web2192.168.100.119httpd php nfs-util इति इति
mysql192.168.100.121mysql

आभासी IP

सेवा नामIP पतासेवते
आभासी ip192.168.100.100nginx keepalived इति

2. विन्यासः

1.LVS1

रक्षणभित्तिं निष्क्रियं कुर्वन्तु, selinux

# 关闭防火墙
systemctl stop firewalld

# 关闭selinux
setenforce 0

सेट् ip: 192.168.100.110

# 编辑网卡信息
vi /etc/sysconfig/network-scripts/ifcfg-ens33

# 修改
BOOTPROTO=static
ONBOOT=yes

# 写入
IPADDR=192.168.100.110
NETMASK=255.255.255.0
GATEWAY=192.168.100.2

keepalived and ipvsadm डाउनलोड करें

yum -y install keepalived ipvsadm

पूर्वनिर्धारितविन्याससञ्चिकायाः ​​बैकअपं गृह्यताम्

cp -p /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bak

मूलसञ्चिकाः विलोप्य नूतना सामग्री निर्मायताम्

# 删除原有文件
rm -rf /etc/keepalived/keepalived.conf 

# 创建新文件
vi /etc/keepalived/keepalived.conf 

निम्नलिखित सामग्रीं योजयन्तु

! Configuration File for keepalived

# 配置双机热备(主)
lobal_defs {
   router_id 1
}
vrrp_instance VI_1 {
    state MASTER
    interface ens33
    virtual_router_id 1
    priority 120
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 123456
    }
    virtual_ipaddress {
        192.168.100.100
    }
}

# 虚拟服务器ip及mysql地址
virtual_server 192.168.100.100 80 {
        delay_loop 15
        lb_algo rr
        lb_kind DR
        protocol TCP
        real_server 192.168.100.113 80 {
        weight 1
        TCP_CHECK {
                connect_port 80
                connect_timeout 3
                nb_get_retry 3
                delay_before_retry 4
                }
        }
        real_server 192.168.100.114 80 {
        weight 1
        TCP_CHECK {
                connect_port 80
                connect_timeout 3
                nb_get_retry 3
                delay_before_retry 4
                }
        }
}

keepalived इति आरभत

systemctl start keepalived

सेवा मॉड्यूल

# 加载系统内核的服务模块
modprobe ip_vs

# 查看运行状态
lsmod | grep ip_vs

net network tools डाउनलोड् कुर्वन्तु

yum -y install net-tools

नेटवर्क् कार्ड् सूचनां पश्यन्तु

# 停用物理网卡
ifconfig ens33 down

# 启动物理网卡(如在连接工具上,需到虚拟机上启动)
ifconfig ens33 up

# 查看网卡信息(在ens33网卡下是否有ip:192.168.100.100)
ip a

# 查看LVS-DR群集策略规则
ipvsadm -ln

LVS-DR समूह रणनीति

# 查看策略
ipvsadm -ln
2.LVS2

रक्षणभित्तिं निष्क्रियं कुर्वन्तु, selinux

# 关闭防火墙
systemctl stop firewalld

# 关闭selinux
setenforce 0

सेट् ip: 192.168.100.111

# 编辑网卡信息
vi /etc/sysconfig/network-scripts/ifcfg-ens33

# 修改
BOOTPROTO=static
ONBOOT=yes

# 写入
IPADDR=192.168.100.111
NETMASK=255.255.255.0
GATEWAY=192.168.100.2

keepalived and ipvsadm डाउनलोड करें

yum -y install keepalived ipvsadm

पूर्वनिर्धारितविन्याससञ्चिकायाः ​​बैकअपं गृह्यताम्

cp -p /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bak

मूलसञ्चिकाः विलोप्य नूतना सामग्री निर्मायताम्

# 删除原有文件
rm -rf /etc/keepalived/keepalived.conf 

# 创建新文件
vi /etc/keepalived/keepalived.conf 

निम्नलिखित सामग्रीं योजयन्तु

! Configuration File for keepalived

# 配置双机热备(备)
lobal_defs {
   router_id 2
}
vrrp_instance VI_1 {
    state BACKUP
    interface ens33
    virtual_router_id 1
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 123456
    }
    virtual_ipaddress {
        192.168.100.100
    }
}

# 虚拟服务器ip及mysql地址
virtual_server 192.168.100.100 80 {
        delay_loop 15
        lb_algo rr
        lb_kind DR
        protocol TCP
        real_server 192.168.100.113 80 {
        weight 1
        TCP_CHECK {
                connect_port 80
                connect_timeout 3
                nb_get_retry 3
                delay_before_retry 4
                }
        }
        real_server 192.168.100.114 80 {
        weight 1
        TCP_CHECK {
                connect_port 80
                connect_timeout 3
                nb_get_retry 3
                delay_before_retry 4
                }
        }
}

keepalived इति आरभत

systemctl start keepalived

सेवा मॉड्यूल

# 加载系统内核的服务模块
modprobe ip_vs

# 查看运行状态
lsmod | grep ip_vs

net network tools डाउनलोड् कुर्वन्तु

yum -y install net-tools

नेटवर्क् कार्ड् सूचनां पश्यन्तु

# 停用物理网卡
ifconfig ens33 down

# 启动物理网卡(如在连接工具上,需到虚拟机上启动)
ifconfig ens33 up

# 查看网卡信息(在ens33网卡下是否有ip:192.168.100.100)
ip a

# 查看LVS-DR群集策略规则
ipvsadm -ln

LVS-DR समूह रणनीति

# 查看策略
ipvsadm -ln
३.ङिन्क्स१

अग्निप्रावरणं निष्क्रियं कुर्वन्तु, selinux

# 关闭防火墙
systemctl stop firewalld

# 关闭selinux
setenforce 0

सेट् ip: 192.168.100.113

# 编辑网卡信息
vi /etc/sysconfig/network-scripts/ifcfg-ens33

# 修改
BOOTPROTO=static
ONBOOT=yes

# 写入
IPADDR=192.168.100.113
NETMASK=255.255.255.0
GATEWAY=192.168.100.2

nginx, keepalived वातावरण डाउनलोड करें

# 配置nginx下载源
cat