# Esta configuração teste, foi realizada com clones de máquinas virtuais, com uma instalação mínima do CentOS 6.7
# Substitua os nomes dos servidores, endereços IP´s e outros, para o que você for utilizar em sua rede.
# Desabilite o Selinux
vi /etc/selinux/config
SELINUX=disabled
# Nas máquinas clonadas é necessário reconfigurar as placas de rede de eth1 para eth0, eliminando a antiga…
vi /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”08:00:27:10:53:f6″, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth0″
# Acertar os nomes dos hosts
# Servidor 1:
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=servidor1.intranet.edu.br
# Servidor 2:
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=servidor2.intranet.edu.br
# Servidor 1 e 2:
# Desative o firewall provisoriamente..
chkconfig iptables off
chkconfig ip6tables off
# Configure os endereços IPS que você ira usar, em nosso caso não usaremos o NetworkManager
vi /etc/sysconfig/network-scripts/ifcfg-eth0
# Servidor 1
DEVICE=eth0
HWADDR=08:00:27:38:0D:F8
TYPE=Ethernet
UUID=19b47870-6f0e-4d41-81e5-a7f21a304196
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=192.168.3.105
GATEWAY=192.168.3.2
DNS1=192.168.3.2
DNS2=8.8.4.4
DNS3=8.8.8.8
# Servidor 2
DEVICE=eth0
HWADDR=08:00:27:9F:72:ED
TYPE=Ethernet
#UUID=19b47870-6f0e-4d41-81e5-a7f21a304196
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.3.110
PREFIX=24
GATEWAY=192.168.3.2
DNS1=192.168.3.2
DNS2=8.8.4.4
DNS3=8.8.8.8
# Reinicie os servidores para continuar…
# Nos dois servidores
yum update -y
yum install nmap tcpdump iproute iptraf ntsysv wget rpcbind nfs-utils telnet ntp ntpdate -y
# Para a sincronização entre os servidores é necessário que o horario também esteja sincronizado.
service ntpd restart
chkconfig ntpd on
### Configurar o arquivo hosts
# Servidor 1:
[root@servidor1 ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.3.105 servidor1
192.168.3.110 servidor2
# Servidor 2:
[root@servidor2 ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.3.105 servidor1
192.168.3.110 servidor2
# Servidor 1 e 2:
mkdir /usr/src/glusterfs_files
cd /usr/src/glusterfs_files/
wget http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/epel-6.7/x86_64/glusterfs-3.7.6-1.el6.x86_64.rpm
wget http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/epel-6.7/x86_64/glusterfs-api-3.7.6-1.el6.x86_64.rpm
wget http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/epel-6.7/x86_64/glusterfs-api-devel-3.7.6-1.el6.x86_64.rpm
wget http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/epel-6.7/x86_64/glusterfs-cli-3.7.6-1.el6.x86_64.rpm
wget http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/epel-6.7/x86_64/glusterfs-client-xlators-3.7.6-1.el6.x86_64.rpm
wget http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/epel-6.7/x86_64/glusterfs-debuginfo-3.7.6-1.el6.x86_64.rpm
wget http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/epel-6.7/x86_64/glusterfs-devel-3.7.6-1.el6.x86_64.rpm
wget http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/epel-6.7/x86_64/glusterfs-extra-xlators-3.7.6-1.el6.x86_64.rpm
wget http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/epel-6.7/x86_64/glusterfs-fuse-3.7.6-1.el6.x86_64.rpm
wget http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/epel-6.7/x86_64/glusterfs-ganesha-3.7.6-1.el6.x86_64.rpm
wget http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/epel-6.7/x86_64/glusterfs-geo-replication-3.7.6-1.el6.x86_64.rpm
wget http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/epel-6.7/x86_64/glusterfs-libs-3.7.6-1.el6.x86_64.rpm
wget http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/epel-6.7/x86_64/glusterfs-rdma-3.7.6-1.el6.x86_64.rpm
wget http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/epel-6.7/x86_64/glusterfs-server-3.7.6-1.el6.x86_64.rpm
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/pyxattr-0.5.0-1.el6.x86_64.rpm
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/u/userspace-rcu-0.7.9-1.el7.x86_64.rpm
rpm -ivh glusterfs-libs-3.7.6-1.el6.x86_64.rpm
rpm -ivh glusterfs-cli-3.7.6-1.el6.x86_64.rpm
rpm -ivh glusterfs-libs-3.7.6-1.el6.x86_64.rpm
rpm -ivh –nodeps glusterfs-api-3.7.6-1.el6.x86_64.rpm
rpm -ivh glusterfs-3.7.6-1.el6.x86_64.rpm
rpm -ivh glusterfs-client-xlators-3.7.6-1.el6.x86_64.rpm
rpm -ivh glusterfs-fuse-3.7.6-1.el6.x86_64.rpm
rpm -ivh glusterfs-api-3.7.6-1.el6.x86_64.rpm
rpm -ivh pyxattr-0.5.0-1.el6.x86_64.rpm
rpm -ivh userspace-rcu-0.7.9-1.el7.x86_64.rpm
rpm -ivh glusterfs-server-3.7.6-1.el6.x86_64.rpm
# Criar o diretório de uso para exportação dos arquivos atualizados entre os servidores
mkdir -p /export/replicate
# Iniciar serviços
/etc/rc.d/init.d/glusterd start
chkconfig glusterd on
/etc/rc.d/init.d/glusterfsd start
chkconfig glusterfsd on
# Servidor 1:
[root@servidor1 ~]# gluster peer probe servidor2
peer probe: success.
# Servidor 2:
[root@servidor2 ~]# gluster peer probe servidor1
peer probe: success.
# Status
[root@servidor1 ~]# gluster peer status
# Number of Peers: 1
#
# Hostname: servidor2
# Uuid: 6076541b-f166-4872-90d2-10a2848c52ee
# State: Peer in Cluster (Connected)
# Servidor 1: Apenas
# Agora criar os volumes com a seguinte sintaxe…
# Para volume distribuido
# gluster volume create dist-volume host1:/dist1 host2:/dist2 host3:/dist3
# Para volume replicado
# gluster volume create rep-volume replica 3 host1:/rep1 host2:/rep2 host3:/rep3
# Para volume fracionado (despojado)
# gluster volume create strip-volume strip 3 host1:/strip1 host2:/strip2 host3:/strip3
# Em nosso caso vamos usar o volume replicado para o serviço de e-mail
# gluster volume create rep-volume replica 3 host1:/rep1 host2:/rep2 host3:/rep3
gluster volume create replicate-volume replica 2 servidor1:/export/replicate servidor2:/export/replicate force
# Servidor 1 e 2:
# Iniciar o volume
gluster volume start replicate-volume
# Info
[root@servidor1 ~]# gluster volume info
Volume Name: replicate-volume
Type: Replicate
Volume ID: 2437b037-20fb-45ad-8dd3-ade3dc937d77
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: servidor1:/export/replicate
Brick2: servidor2:/export/replicate
# Servidor 1 e 2
# Criar a pasta para o serviço de e-mail
mkdir /home/vmail
chmod 770 /home/vmail
# Servidor 1:
mount -t glusterfs servidor2:/replicate-volume /home/vmail
# Servidor 2:
mount -t glusterfs servidor1:/replicate-volume /home/vmail
# Servidor 1 e 2
# Adicionar ao /etc/fstab dos servidores os pontos de montagem
# host1.example.com:/rep-volume /mnt/replicated glusterfs defaults,_netdev 0 0
[root@servidor1 ~]# cat /etc/fstab
# servidor2:/replicate-volume /home/vmail glusterfs defaults 0 0
echo “servidor2:/replicate-volume /home/vmail glusterfs defaults 0 0” >> /etc/fstab
[root@servidor2 ~]# cat /etc/fstab
# servidor1:/replicate-volume /home/vmail glusterfs defaults 0 0
echo “servidor1:/replicate-volume /home/vmail glusterfs defaults 0 0” >> /etc/fstab
# Reinicie os servidores para testar se os volumes montam automaticamente
##### instalar os pacotes de e-mail
yum -y groupinstall Servidor\ Web
yum -y install openssl-devel openssl php-mysql php php-pear -y
yum -y install httpd* php-mysql php php-devel php-pear php-snmp rrdtool-php -y
rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum update -y
yum install roundcubemail dovecot dovecot-mysql dovecot-pigeonhole cyrus-sasl-devel cyrus-sasl-sql subversion mc -y
yum install perl-MailTools perl-MIME-EncWords perl-MIME-Charset perl-Email-Valid perl-Test-Pod perl-TimeDate perl-Mail-Sender perl-Log-Log4perl imapsync offlineimap amavisd-new clamav clamd razor-agents perl-Convert-BinHex php-mbstring php-imap -y
wget http://sourceforge.net/projects/postfixadmin/files/latest/download
useradd -r -u 101 -g mail -d /home/vmail -s /sbin/nologin -c “Virtual mailbox” vmail
chown vmail:mail /home/vmail
vi /etc/httpd/conf.d/postfixadmin.conf
alias /mailadmin /usr/share/postfixadmin
<directory “/usr/share/postfixadmin”>
AllowOverride AuthConfig
</directory>
service httpd restart
yum install mysql mysql-* -y
service mysqld restart
/usr/bin/mysql_secure_installation
mysql -u root -p -e “CREATE DATABASE postfix;”
mysql -u root -p -e “CREATE USER postfix@localhost IDENTIFIED BY ‘senha’;”
mysql -u root -p -e “GRANT ALL PRIVILEGES ON postfix . * TO postfix@localhost;”
tar -zxpvf postfixadmin-2.93.tar.gz
mv postfixadmin-2.93 /usr/share/postfixadmin
cd /usr/share/postfixadmin
vi config.inc.php
vi /etc/httpd/conf.d/welcome.conf
touch /etc/postfix/virtual_regexp
chown apache.apache /usr/share/postfixadmin/ -R
useradd -r -d /var/spool/vacation -s /sbin/nologin -c “Virtual vacation” vacation
mkdir /var/spool/vacation
chmod 770 /var/spool/vacation
cp /usr/share/postfixadmin/VIRTUAL_VACATION/vacation.pl /var/spool/vacation/
echo “autoreply.intranet.edu.br vacation:” > /etc/postfix/transport
postmap /etc/postfix/transport
chown -R vacation:vacation /var/spool/vacation
echo “127.0.0.1 autoreply.intranet.edu.br” >> /etc/hosts
# Configurando postfix
cd /etc/postfix
cp main.cf main.cf.save
cp master.cf master.cf.save
vi main.cf
vi master.cf
vi /etc/postfix/mynetworks
vi /etc/postfix/mysql-virtual_mailbox_maps.cf
vi /etc/postfix/mysql-virtual_mailbox_limit_maps.cf
vi /etc/postfix/mysql-virtual_alias_maps.cf
vi /etc/postfix/mysql-virtual_domains_maps.cf
vi /etc/postfix/mysql-relay_domains_maps.cf
vi /etc/postfixadmin/vacation.conf
# Dovecot
mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.save
vi /etc/dovecot/dovecot.conf
vi /etc/dovecot/trash.conf
mkdir /home/sieve
vi /home/sieve/globalfilter.sieve
chown -R vmail:mail /home/sieve
mv /etc/clamd.conf /etc/clamd.conf.default
vi /etc/clamd.conf
freshclam
service clamd restart
sa-update
vi /etc/amavisd.conf
service amavisd start
vi /etc/postfix/master.cf
service postfix restart
ll /home/vmail/
chkconfig httpd on
chkconfig dovecot on
chkconfig mysqld on
tail -f /var/log/maillog
# edit parametros do arquivo php.ini
vi /etc/php.ini
max_input_time = 180
memory_limit = 128M (aconselho aumentar isso para ate 1/4 da memoria total)
display_errors = On (aconselhavel equanto se instala os servidores, pode retornar depois)
display_startup_errors = On
error_log = syslog
post_max_size = 8M ( é melhor aumentar para em torno de 80M, isso influencia muito quando usa-se webmail)
upload_tmp_dir = /tmp
upload_max_filesize = 2M (aumente isso, mesmo caso do webmail)
date.timezone = “America/Sao_Paulo”
# Agora, como os servidores utilizam-se de banco de dados, precisamos sincronizar os mesmos.
# Vamos usar a relicação do banco de dados no modo Master/Master
# Verificando a configuração de logs binários
mysql> SHOW GLOBAL VARIABLES WHERE Variable_name = ‘log_bin’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| log_bin | OFF |
+—————+——-+
1 row in set (0.02 sec)
# Editar o arquivo /etc/my.cnf para ativar os logs binários
vi /etc/my.cnf # acrescente após a seção [mysqld]
log-bin=/var/lib/mysql/mysql-bin.log
# Número de identificação do servidor. 1 para master 2,3… para slaves
server-id=1
# No primeiro servidor
mysql> GRANT REPLICATION SLAVE ON *.* TO ‘replication’@’192.168.0.2’ IDENTIFIED BY ‘senhasecreta’;
Query OK, 0 rows affected (0.01 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
# Verificando a posicao do log binario no servidor 1
mysql> SHOW MASTER STATUS;
+——————+———-+————–+——————+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+——————+———-+————–+——————+
| mysql-bin.000005 | 502 | | |
+——————+———-+————–+——————+
1 row in set (0.00 sec)
# se o banco de dados ja estiver em producao, faça um mysqldump de todas as bases para exportar no novo servidor.
# depois entre no servidor 2
mysql> CHANGE MASTER TO
MASTER_HOST=’192.168.0.1′,
MASTER_USER=’replication’,
MASTER_PASSWORD=’senhasecreta’,
MASTER_LOG_FILE=’mysql-bin.000005′,
MASTER_LOG_POS=502;
mysql> START SLAVE;
Query OK, 0 rows affected (0.00 sec)
# Verificação
mysql> SHOW SLAVE STATUS \G
# Repita os procedimentos no outro servidor para que o servidor master seja o slave do outro
# inserir as linha abaixo no /etc/my.cnf do primeiro servidor
auto-increment-increment = 2
auto-increment-offset = 1
E no my.cnf do segundo servidor:
auto-increment-increment = 2
auto-increment-offset = 2