GNU/Linux >> Linux Esercitazione >  >> Cent OS

Installa Pound – Apache Load Balancer – Ubuntu 14.04 / 15.04 / CentOS 7 / Fedora 22

Il bilanciamento del carico è il metodo per distribuire le richieste Web che provengono da Internet a più server interni, tali server servono lo stesso contenuto ai client. Pound è uno dei pacchetti che ti aiuta a configurare il bilanciamento del carico per il server web, fornisce proxy inverso e supporta anche le richieste HTTPS.

1. Quando i client richiedono contenuto Web su Internet, le richieste vengono inviate al gateway Pound (server principale pubblico) 102.108.12.10 al porto n. 80 o 443 .

2. Gateway Pound già configurato con il servizio web apache interno (192.168.12.11 e 192.168.12.12 )

3. Il gateway Pound inoltra tutte le query ai server interni con la porta n. 80 o 443 .

4. Il gateway Pound eseguirà il proxy inverso per restituire i contenuti Web ai client.

Contenuto:

  1. Installa server Web
  2. Installa Pound
  3. Configura libbra
  4. Firewall
  5. Extra
  6. Risoluzione dei problemi

Installa server Web:

Installa il server Apache su entrambi i server interni usando il comando yum.

### Ubuntu 15.04 / Ubuntu 14.04 ### 

$ sudo su -
# apt-get update
# apt-get install apache2

### CentOS 7 / RHEL 7 / Fedora 22 ###

# yum install httpd
# systemctl start httpd.service

Inserisci il test index.html in /var/www/html su server interni.

Per 192.168.12.11

echo "This is 192.168.12.11" > /var/www/html/index.html

Per 192.168.12.12

echo "This is 192.168.12.12" > /var/www/html/index.html

Verifica i server web visitando http://192.168.12.11 e http://192.168.12.12; dovresti vedere "Questo è 192.168.12.11 " e "Questo è 192.168.12.12 rispettivamente ”

Installa Pound:

Ora installa il pacchetto Pound sul server gateway (102.108.12.10 ). Pound non è disponibile nel repository di base CentOS o RHEL 7, quindi è necessario configurare EPEL.

### Only for CentOS 7 / RHEL 7 ###
# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Installa Pound rpm.

### Ubuntu 15.04 / Ubuntu 14.04 ###

# apt-get install pound

### CentOS 7 / RHEL 7 / Fedora 22 ###

# yum install Pound

Configura libbra:

pound.cfg è il file di configurazione e si trova all'interno della directory /etc, apri il file di configurazione per distribuire le richieste tra due server interni. Se non hai il certificato SSL installato sul gateway Pound, rimuovi la stanza ListenHTTPS.

### Ubuntu 15.04 / Ubuntu 14.04 ###

# nano /etc/pound/pound.cfg

### CentOS 7 / RHEL 7 / Fedora 22 ###

# vi /etc/pound.cfg

Modifica il file di configurazione.

ListenHTTP
    Address 102.108.12.10
    Port 80
End

### Remove below ListenHTTPS stanza, if you do not wish to balance HTTPS request.
ListenHTTPS
    Address 102.108.12.10
    Port    443
    Cert    "/etc/ssl/pound.pem"
End

Service
    BackEnd
        Address 192.168.12.11
        Port    80
    End

    BackEnd
        Address 192.168.12.12
        Port    80
    End
End

Avvia il servizio Pound.

### Ubuntu 15.04 / Ubuntu 14.04 ###

# service pound start

### CentOS 7 / RHEL 7 / Fedora 22 ###

# systemctl start  pound.service

Firewall:

Configura il firewall per consentire 80 e 443 porte , esegui il comando seguente.

### CentOS 7 / RHEL 7 / Fedora 22 ###

# firewall-cmd --add-service=http
# firewall-cmd --add-service=https
# firewall-cmd --permanent --add-service=http
# firewall-cmd --permanent --add-service=https
# systemctl restart firewalld

Ora visita http://102.102.12.10 , aggiorna la pagina continuamente. Potresti vedere la home page del web server interno, allo stesso tempo puoi notare che la home page cambia continuamente ad ogni richiesta.

Se hai intenzione di bilanciare le richieste HTTPS, devi generare un nuovo certificato per pound e il file pound.cfg deve essere aggiornato di conseguenza.

cd /etc/ssl && openssl req -x509 -newkey rsa:1024 -keyout pound.pem -out pound.pem  -days 365 -nodes

Extra:

Ad esempio, se desideri utilizzare Pound Gateway come uno dei server web interni (102.108.12.10 ); make Apache web server in ascolto su qualche altra porta invece della porta 80, perché Pound usa la porta 80 . Di seguito è riportata la piccola configurazione per fungere da entrambi (gateway Pound e Web Server). Pound è in ascolto su Porta 80 allo stesso tempo Apache ascolta su p ort 808.

ListenHTTP
    Address 102.108.12.10
    Port 80
End

### Remove below ListenHTTPS stanza, if you do not wish to balance HTTPS request.
ListenHTTPS
    Address 102.108.12.10
    Port    443
    Cert    "/etc/ssl/pound.pem"
End

Service
    BackEnd
        Address 102.108.12.10
        Port    808
    End

    BackEnd
        Address 192.168.12.11
        Port    80
    End
End

Risoluzione dei problemi:

Se ricevi un errore come di seguito,

PID file /var/run/pound.pid not readable (yet?) after start.

Modifica il file /usr/lib/systemd/system/pound.service.

vi /usr/lib/systemd/system/pound.service

Commenta la voce PID come di seguito.

#PIDFile=/var/run/pound.pid

Il sistema di bilanciamento del carico è la soluzione più importante nell'ambiente aziendale in cui il server riceve milioni di richieste, garantisce al client di ottenere il contenuto Web in tempo e libera anche il carico sui server.


Cent OS
  1. Come installare Apache Cassandra su CentOS 8

  2. Come installare Apache su CentOS 7

  3. Come installare Apache Hadoop su CentOS 7, Ubuntu 18.04 e Debian 9

  4. Installa Ruby on Rails su CentOS / Ubuntu / Fedora dal sorgente

  5. Come installare Apache Kafka su CentOS 8

Come installare Apache ServiceMix su CentOS 7

Installa Ruby on Rails su Ubuntu 16.04 / CentOS 7 / Fedora 26 usando rbenv

Come installare Apache Cassandra in CentOS

Installa Apache OpenOffice su CentOS 8

Come installare Apache Solr 8.9 su Fedora 34/33 e CentOS 7

Come installare elgg su CentOS 8