<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Arquivos cache - Remontti</title>
	<atom:link href="https://blog.remontti.com.br/tag/cache/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.remontti.com.br/tag/cache</link>
	<description>rudimar@remontti</description>
	<lastBuildDate>Wed, 06 Nov 2024 12:23:47 +0000</lastBuildDate>
	<language>pt-BR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.remontti.com.br/wp-content/uploads/2024/09/icone-rr-80x80.png</url>
	<title>Arquivos cache - Remontti</title>
	<link>https://blog.remontti.com.br/tag/cache</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Balanceamento de Carga</title>
		<link>https://blog.remontti.com.br/328</link>
					<comments>https://blog.remontti.com.br/328#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Tue, 09 Jun 2009 18:04:28 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[balance]]></category>
		<category><![CDATA[balanceamento]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[cool]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[flush]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[ping]]></category>
		<category><![CDATA[rotas]]></category>
		<category><![CDATA[route]]></category>
		<category><![CDATA[uplink]]></category>
		<guid isPermaLink="false">http://www.remontti.com.br/blog/?p=328</guid>

					<description><![CDATA[<p>Este tuto foi feito em cima da distribuição Debian 5, com dois links de mesma velocidade. Neste exemplo teremos 3 interface [eth0 192.168.1.100 e eth1 192.168.2.100 as duas internet] [eth2 192.168.3.1 rede local] Primeiramente&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/328">Balanceamento de Carga</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Este tuto foi feito em cima da distribuição Debian 5, com dois links de mesma velocidade.<br />
Neste exemplo teremos 3 interface [eth0 192.168.1.100 e eth1 192.168.2.100 as duas internet] [eth2 192.168.3.1 rede local]</p>
<p>Primeiramente instalamos o pacote iproute 2<br />
<span style="color: #ff6600;"># aptitude update<br />
# aptitude install iproute</span></p>
<p>Após configure as tabelas:</p>
<p><span style="color: #ff6600;"># vim /etc/iproute2/rt_tables</span><br />
Adicione essas duas linhas no final do arquivo:</p>
<p><span style="color: #008080;">200 uplink1<br />
201 uplink2</span></p>
<p><span style="color: #008080;"><span id="more-328"></span></span>Vamos configurar nossa interface onde em eth0 192.168.1.1 / eth1 192.168.2.1 são os gateways<br />
<span style="color: #ff6600;"># vim /etc/network/interfaces</span></p>
<pre class="remontti-code"># LOCALHOST
auto lo
iface lo inet loopback

# LINK 1

auto eth0
iface eth0 inet static
        address 192.168.1.100
        netmask 255.255.255.0

        post-up ip route add 192.168.1.1/32 dev eth1 src 192.168.1.100 table uplink1
        post-up ip route add default via 192.168.1.1 table uplink1
        post-up ip rule add from 192.168.1.100 table uplink1
        post-down ip rule del from 192.168.1.100 table uplink1

# LINK 2

auto eth1
iface eth1 inet static
        address 192.168.2.100
        netmask 255.255.255.0

        post-up ip route add 192.168.2.1/32 dev eth1 src 192.168.2.210 table uplink2
        post-up ip route add default via 192.168.2.1 table uplink2
        post-up ip rule add from 192.168.2.210 table uplink2
        post-down ip rule del from 192.168.2.210 table uplink2

# REDE CLIENTE
auto eth2
iface eth2 inet static
        address 192.168.3.1
        netmask 255.255.255.0</pre>
<p>Reinicie o serviço:<br />
<span style="color: #ff6600;"># /etc/init.d/networking  restart</span></p>
<p>Agora vamos criar um firewall, criaremos as rotas.</p>
<pre class="remontti-code">#! /bin/sh

# Ativa forward
echo &quot;1&quot; &gt; /proc/sys/net/ipv4/ip_forward

# Limpa regras
/sbin/iptables -F
/sbin/iptables -X
/sbin/iptables -t nat -F
/sbin/iptables -X -t nat
/sbin/iptables -F -t mangle
/sbin/iptables -X -t mangle

# Carrega modulos
/sbin/modprobe iptable_nat
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ipt_LOG
/sbin/modprobe ipt_REJECT
/sbin/modprobe ipt_MASQUERADE

#Libera navegacao nas interfaces
/sbin/iptables -t nat -A POSTROUTING -s 192.168.30/24 -o eth0 -j MASQUERADE
/sbin/iptables -t nat -A POSTROUTING -s 192.168.30/24 -o eth1 -j MASQUERADE

# Configurações Proxy
# /sbin/iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 80 -j REDIRECT --to-port 3128
# /sbin/iptables -A PREROUTING -t mangle -s 192.168.3.0/24 -d 0/0 -j MARK --set-mark 3
# /sbin/iptables -t mangle -A OUTPUT -p TCP -d ! 192.168.3.0/24 --dport 80 -m owner --uid-owner 23 -j MARK --set-mark 3

# Faz com que o servico dns faca consultas pelo outro link
/sbin/iptables -t mangle -A OUTPUT -p UDP --dport 53 -m owner --uid-owner 25 -j MARK --set-mark 2

# Deleta rotas
route del default

# Load balance
ip route add default scope global nexthop via 192.168.1.1 dev eth0 weight 1 nexthop via 192.168.2.1 dev eth1 weight 1

# Limpa cache
ip route flush cached</pre>
<p>Use o comando &#8220;ip route show table main&#8221; para ver como ficou&#8230;<br />
<span style="color: #ff6600;"> # ip route show table main</span></p>
<p><span style="color: #999999;">192.168.1.1/24 dev eth0  proto kernel  scope link  src 192.168.1.100<br />
<em>192.168.2.1/24 dev eth1  proto kernel  scope link  src 192.168.2.100<br />
192.168.3.1/24 dev eth2  proto kernel  scope link  src 192.168.3.1<br />
default<br />
nexthop via 192.168.1.100  dev eth0 weight 1<br />
nexthop via 192.168.2.100  dev eth1 weight 1</em></span></p>
<p>Adicione no cron o comando para limpar o cache dos dns a cada 10 min<br />
<span style="color: #ff6600;"> # vim /etc/crontab</span><br />
00-59/10   *   * * *   root   ip route flush cached</p>
<p>Aqui fiz o siguinte script para verificar se algum dos link cai, assim refazendo a rota e deixadondo para o que estiver online.</p>
<p><span style="color: #ff6600;"># vim /root/uplink.sh</span></p>
<pre class="remontti-code">#! /bin/sh
# - - - - - - - - - - - - - - - #
# Script por Rudimar Remontti   #
# www.remontti.com.br           #
# - - - - - - - - - - - - - - - #
echo -e &#039;\e[33;1mVerificando Links: \e[m&#039;

# - - - - - - - - - - - #
# Configuracoes         #
# - - - - - - - - - - - #
GTW_1=192.168.1.1
ITF_1=eth0
GTW_2=192.168.2.1
ITF_2=eth1
RT_BRT_1=200.176.3.142 # Ip do terra.com.br ele ira pingar p/ verificar se responde
RT_BRT_2=200.176.3.142 # Ip do terra.com.br...
# - - - - - - - - - - - #

echo
echo -e &quot;\e[30;1mLink 1: $GTW_1\e[m&quot;
echo -e &quot;\e[30;1mLink 2: $GTW_2\e[m&quot;
echo 

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
PING_1=`ping $RT_BRT_1 -I $ITF_1 -c 1 |grep packets |cut -c 24`
PING_2=`ping $RT_BRT_2 -I $ITF_2 -c 1 |grep packets |cut -c 24`
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #

UP=`echo &quot;($PING_1 + $PING_2)&quot; | bc`
if [ $UP = 2 ]; then 

        route del default
        ip route add default scope global nexthop via $GTW_1 dev $ITF_1 weight 1 nexthop via $GTW_2 dev $ITF_2 weight 1
        ip route flush cached

        echo -n &#039;Link 1 e Link 2  Status:     &#039;
        echo -e &#039;\e[32;1m[ ON ] \e[m&#039;
        echo

elif [ $UP = 0 ]; then

        route del default
        ip route add default scope global nexthop via $GTW_1 dev $ITF_1 weight 1 nexthop via $GTW_2 dev $ITF_2 weight 1
        ip route flush cached

        echo
        echo -n Link 1:
        echo -e &#039;\e[32;1m  [  OKAY  ] \e[m&#039;
        echo -n Link 2:
        echo -e &#039;\e[32;1m  [  OKAY  ] \e[m&#039;
        echo

elif [ $UP = 1 ]; then
        echo
        if [ $PING_1 = 1 ]; then
                echo -n Link 1:
                echo -e &#039;\e[32;1m  [  OKAY  ] \e[m&#039;
        else
                route del default
                ip route add default scope global nexthop via $GTW_2 dev $ITF_2 weight 1
                ip route flush cached
                data=`date`
                echo &quot;$data -&gt; Link 1 OFF&quot; &gt;&gt; /root/links.log
                echo -n Link 1:
                echo -e &#039;\e[31;1m  [  OFF   ] \e[m&#039;
        fi
        if [ $PING_2 = 1 ]; then
                echo -n Link 2:
                echo -e &#039;\e[32;1m  [  OKAY  ] \e[m&#039;
        else
                route del default
                ip route add default scope global nexthop via $GTW_1 dev $ITF_1 weight 1
                ip route flush cached
                data=`date`
                echo &quot;$data -&gt; Link 2 OFF&quot; &gt;&gt; /root/links.log
                echo -n Link 2:
                echo -e &#039;\e[31;1m  [  OFF   ] \e[m&#039;

        fi
        echo
        if [ $PING_1 = 0 ]; then
                echo -e &#039;\e[30;1mRotas reconfigurada, gatway através do Link 2.\e[m&#039;
                ROTE=`ip route show |grep default |cut -c 9-100`
                echo -e &quot;\e[30;1m$ROTE\e[m&quot;

        elif [ $PING_2 = 0 ]; then
                echo -e &#039;\e[30;1mRotas reconfigurada, gatway através do Link 1.\e[m&#039;
                ROTE=`ip route show |grep default |cut -c 9-100`
                echo -e &quot;\e[30;1m$ROTE\e[m&quot;
        fi
else
        echo ERRO!
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
echo
ip route show |grep nexthop
echo</pre>
<p><span style="color: #ff6600;"># chmod 755 /root/uplink.sh</span></p>
<p>Adicionamos ao cron (5min)<br />
<span style="color: #ff6600;"> # vim /etc/crontab</span><br />
<span style="color: #008080;"> 00-59/5   *   * * *   root   /root/uplink.sh</span></p>
<p>Carregue seu firewall na inicialização do sistema, utilize o iptraf para ver o trafego saindo pelas duas interfaces.<br />
Se vc tem dois link com cargas diferente altere o weight.</p>
<p>Abraço</p>
<p>O post <a href="https://blog.remontti.com.br/328">Balanceamento de Carga</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/328/feed</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Script para limpar memória cache/swap do Linux</title>
		<link>https://blog.remontti.com.br/92</link>
					<comments>https://blog.remontti.com.br/92#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Fri, 17 Apr 2009 04:51:57 +0000</pubDate>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[buster]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[cheio]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[jessie]]></category>
		<category><![CDATA[memoria]]></category>
		<category><![CDATA[Stretch]]></category>
		<guid isPermaLink="false">http://remontti.com.br/blog/?p=92</guid>

					<description><![CDATA[<p>Distribuição Testada: Debian 8/9/10/11/12 Vamos criar um arquivinho para checar nossa memória e limpar ela. Comandos: # vim /bin/limpamemoria #!/bin/sh # ********************** # # remontti.com.br # # ********************** # # Porcentagem máxima (mude se&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/92">Script para limpar memória cache/swap do Linux</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Distribuição Testada: Debian 8/9/10/11/12</p>
<p>Vamos criar um arquivinho para checar nossa memória e limpar ela.<br />
Comandos:</p>
<pre class="remontti-code"># vim /bin/limpamemoria</pre>
<p><span id="more-92"></span></p>
<pre class="remontti-code">#!/bin/sh

# ********************** #
#    remontti.com.br     #
# ********************** #

# Porcentagem máxima (mude se você achar necessário)
percent=85

# Total da memoria:
ramtotal=`grep -F &quot;MemTotal:&quot; &lt; /proc/meminfo | awk &#039;{print $2}&#039;`
# Memoria livre:
ramlivre=`grep -F &quot;MemFree:&quot; &lt; /proc/meminfo | awk &#039;{print $2}&#039;`

# RAM utilizada pelo sistema:
ramusada=`expr $ramtotal - $ramlivre`

# Porcentagem de RAM utilizada pelo sistema:
putil=`expr $ramusada \* 100 / $ramtotal`

echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
date
echo
echo &quot;Mem. utilizada: $putil %&quot;;

if [ $putil -gt $percent ]
then
date=`date`
echo $date &gt;&gt; /var/log/memoria.log
echo &quot;Mem. utilizada: $putil %&quot; &gt;&gt; /var/log/memoria.log

echo &quot;Memoria acima de $percent %, cache foi limpado!&quot;;
sync
# &#039;Dropando&#039; cache:
echo 3 &gt; /proc/sys/vm/drop_caches
# Caso nao esteja utilizanod debian, descomente a linha abaixo
# sysctl -w vm.drop_caches=3 
# Zera SWAP
swapoff -a
swapon -a
echo
free -m
echo
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
else
echo &quot;Cache não foi limpado!&quot;;
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
unset percent ramtotal ramlivre ramusada putil
exit $?
fi</pre>
<p>De permissão para executá-lo:</p>
<pre class="remontti-code"># chmod +x /bin/limpamemoria</pre>
<p><strong>Agendando no CRON</strong></p>
<p>Vamos adicionar ao cron para rodar a cada 30 min.<br />
Adicione ao final de /etc/crontab:</p>
<pre class="remontti-code"># echo &#039;# Limpa memoria a cada 30min&#039; &gt;&gt; /etc/crontab
# echo &#039;*/30 *  * * *   root   /bin/limpamemoria&#039; &gt;&gt; /etc/crontab</pre>
<p>Verifique se inseriu</p>
<pre class="remontti-code"># cat /etc/crontab</pre>
<p>Reinicie o CRON</p>
<pre class="remontti-code"># systemctl restart cron</pre>
<p>Para distribuição mais antigas</p>
<pre class="remontti-code"># /etc/init.d/cron restart</pre>
<p>Feito, cada vez q ele limpar vai gerar um log em <strong>/var/log/memoria.log</strong></p>
<p>Gostou? Quer me ajudar? <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p><strong>Se quiser fazer uma doação para o café ficarei muito feliz pelo seu reconhecimento!</strong><br />
<a href="https://blog.remontti.com.br/doar"><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/quero-doar-remontti.png" /></a></p>
<p>Se não puder doar pode deixar seu agradecimento nos comentário também ficarei feliz em saber que ajudei. Se tiver qualquer pergunta deixe-a também. Se preferir entrar em Contato <a href="https://blog.remontti.com.br/meucontato" rel="noopener noreferrer" target="_blank">clique aqui.</a></p>
<p>O post <a href="https://blog.remontti.com.br/92">Script para limpar memória cache/swap do Linux</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/92/feed</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
			</item>
	</channel>
</rss>
