Você está na página 1de 9

7.

4 cp
Copia arquivos. cp [opes] [origem] [destino] onde: origem Arquivo que ser copiado. Podem ser especificados mais de um arquivo para ser copiado usando Curingas (veja Curingas on page 33). destino O caminho ou nome de arquivo onde ser copiado. Se o destino for um diretrio, os arquivos de origem sero copiados para dentro do diretrio. opes i, interactive Pergunta antes de substituir um arquivo existente. Captulo 7. Comandos para manipulao de Arquivos 67 -f, force No pergunta, substitui todos os arquivos caso j exista. -r Copia arquivos dos diretrios e subdiretrios da origem para o destino. recomendvel usar -R ao invs de -r. -R, recursive Copia arquivos e sub-diretrios (como a opo -r) e tambm os arquivos especiais FIFO e dispositivos. -v, verbose Mostra os arquivos enquanto esto sendo copiados. O comando cp copia arquivos da ORIGEM para o DESTINO. Ambos origem e destino tero o mesmo contedo aps a cpia. Exemplos: cp teste.txt teste1.txt Copia o arquivo teste.txt para teste1.txt. cp teste.txt /tmp Copia o arquivo teste.txt para dentro do diretrio /tmp. cp * /tmp Copia todos os arquivos do diretrio atual para /tmp. cp /bin/* . Copia todos os arquivos do diretrio /bin para o diretrio em que nos encontramos no momento. cp -R /bin /tmp Copia o diretrio /bin e todos os arquivos/sub-diretrios existentes para o diretrio /tmp. cp -R /bin/* /tmp Copia todos os arquivos do diretrio /bin (exceto o diretrio /bin) e todos os arquivos/sub-diretrios existentes dentro dele para /tmp. cp -R /bin /tmp Copia todos os arquivos e o diretrio /bin para /tmp.

7.5 mv
Move ou renomeia arquivos e diretrios. O processo semelhante ao do comando cp mas o arquivo de origem apagado aps o trmino da cpia. mv [opes] [origem] [destino] Onde: origem Arquivo/diretrio de origem. destino Local onde ser movido ou novo nome do arquivo/diretrio. opes -f, force Substitui o arquivo de destino sem perguntar. -i, interactive Pergunta antes de substituir. o padro. -v, verbose Mostra os arquivos que esto sendo movidos. O comando mv copia um arquivo da ORIGEM para o DESTINO (semelhante ao cp), mas aps

a cpia, o arquivo de ORIGEM apagado. Exemplos: mv teste.txt teste1.txt Muda o nome do arquivo teste.txt para teste1.txt. mv teste.txt /tmp Move o arquivo teste.txt para /tmp. Lembre-se que o arquivo de origem apagado aps ser movido. mv teste.txt teste.new (supondo que teste.new j exista) Copia o arquivo teste.txt por cima de teste.new e apaga teste.txt aps terminar a cpia.

8.6 find
Procura por arquivos/diretrios no disco. find pode procurar arquivos atravs de sua data de modificao, tamanho, etc atravs do uso de opes. find, ao contrrio de outros programas, Captulo 8. Comandos Diversos 72 usa opes longas atravs de um -. find [diretrio] [opes/expresso] Onde: diretrio Inicia a procura neste diretrio, percorrendo seu sub-diretrios. opes/expresso -name [expresso ] Procura pelo nome [expresso] nos nomes de arquivos e diretrios processados. -depth Processa os sub-diretrios primeiro antes de processar os arquivos do diretrio principal. -maxdepth [num ] Faz a procura at [num] sub-diretrios dentro do diretrio que est sendo pesquisado. -mindepth [num ] No faz nenhuma procura em diretrios menores que [num] nveis. -mount, -xdev No faz a pesquisa em sistemas de arquivos diferentes daquele de onde o comando find foi executado. -size [num ] Procura por arquivos que tiverem o tamanho [num]. [num] pode ser antecedido de + ou - para especificar um arquivo maior ou menor que [num]. A opo -size pode ser seguida de: b - Especifica o tamanho em blocos de 512 bytes. o padro caso [num] no seja acompanhado de nenhuma letra. c - Especifica o tamanho em bytes. k - Especifica o tamanho em Kbytes. -type [tipo ] Procura por arquivos do [tipo] especificado. Os seguintes tipos so aceitos: b - bloco c - caracter d - diretrio p - pipe f - arquivo regular l - link simblico s - sockete A maior parte dos argumentos numricos podem ser precedidos por + ou -. Para detalhes sobre outras opes e argumentos, consulte a pgina de manual. Exemplo: find / -name grep - Procura no diretrio raz e sub-diretrios um arquivo/diretrio chamado grep.

find / -name grep -maxdepth 3 - Procura no diretrio raz e sub-diretrios at o 3o. nvel, um arquivo/diretrio chamado grep. find . -size +1000k - Procura no diretrio atual e sub-diretrios um arquivo com tamanho maior que 1000 kbytes (1Mbyte).

Prev

Chapter 45. Samba Performance Tuning Part VI. Reference Section

Next

Chapter 45. Samba Performance Tuning


Paul Dundee Limb Fitting Centre Cochrane
Dundee Limb Fitting Centre <paulc@dth.scot.nhs.uk>

Jelmer R. The Samba Team Vernooij


The Samba Team <jelmer@samba.org>

John H. Samba Team Terpstra


Samba Team <jht@samba.org> Table of Contents Comparisons Socket Options Read Size Max Xmit Log Level Read Raw Write Raw Slow Logins Client Tuning Samba Performance Problem Due to Changing Linux Kernel Corrupt tdb Files Samba Performance is Very Slow

Comparisons
The Samba server uses TCP to talk to the client, so if you are trying to see if it performs well, you should really compare it to programs that use the same protocol. The most readily available programs for file transfer that use TCP are ftp or another TCP-based SMB server. If you want to test against something like an NT or Windows for Workgroups server, then you will have to disable all but TCP on either the client or server. Otherwise, you may well be using a totally different protocol (such as NetBEUI) and comparisons may not be valid. Generally, you should find that Samba performs similarly to ftp at raw transfer speed. It should perform quite a bit faster than NFS, although this depends on your system. Several people have done comparisons between Samba and Novell, NFS, or Windows NT. In some cases Samba performed the best, in others the worst. I suspect the biggest factor is not Samba

versus some other system, but the hardware and drivers used on the various systems. Given similar hardware, Samba should certainly be competitive in speed with other systems.

Socket Options
There are a number of socket options that can greatly affect the performance of a TCP-based server like Samba. The socket options that Samba uses are settable both on the command line with the -O option and in the smb.conf file. The socket options section of the smb.conf manual page describes how to set these and gives recommendations. Getting the socket options correct can make a big difference to your performance, but getting them wrong can degrade it by just as much. The correct settings are very dependent on your local network. The socket option TCP_NODELAY is the one that seems to make the biggest single difference for most networks. Many people report that adding socket options = TCP_NODELAY doubles the read performance of a Samba drive. The best explanation I have seen for this is that the Microsoft TCP/IP stack is slow in sending TCP ACKs. There have been reports that setting socket options = SO_RCVBUF=8192 in smb.conf can seriously degrade Samba performance on the loopback adaptor (IP Address 127.0.0.1). It is strongly recommended that before specifying any settings for socket options, the effect first be quantitatively measured on the server being configured.

Read Size
The option read size affects the overlap of disk reads/writes with network reads/writes. If the amount of data being transferred in several of the SMB commands (currently SMBwrite, SMBwriteX, and SMBreadbraw) is larger than this value, then the server begins writing the data before it has received the whole packet from the network, or in the case of SMBreadbraw, it begins writing to the network before all the data has been read from disk. This overlapping works best when the speeds of disk and network access are similar, having little effect when the speed of one is much greater than the other. The default value is 16384, but little experimentation has been done as yet to determine the optimal value, and it is likely that the best value will vary greatly between systems anyway. A value over 65536 is pointless and will cause you to allocate memory unnecessarily.

Max Xmit
At startup the client and server negotiate a maximum transmit size, which limits the size of nearly all SMB commands. You can set the maximum size that Samba will negotiate using the max xmit option in smb.conf. Note that this is the maximum size of SMB requests that Samba will accept, but not the maximum size that the client will accept. The client maximum receive size is sent to Samba by the client, and Samba honors this limit. It defaults to 65536 bytes (the maximum), but it is possible that some clients may perform better with a smaller transmit unit. Trying values of less than 2048 is likely to cause severe problems. In most cases the default is the best option.

Log Level
If you set the log level (also known as debug level) higher than 2, then you may suffer a large drop in performance. This is because the server flushes the log file after each operation, which can be quite expensive.

Read Raw
The read raw operation is designed to be an optimized, low-latency file read operation. A server may choose to not support it, however, and Samba makes support for read raw optional, with it being enabled by default. In some cases clients do not handle read raw very well and actually get lower performance using it than they get using the conventional read operations, so you might like to try read raw = no and see what happens on your network. It might lower, raise, or not affect your performance. Only testing can really tell.

Write Raw
The write raw operation is designed to be an optimized, low-latency file write operation. A server may choose to not support it, however, and Samba makes support for write raw optional, with it being enabled by default. Some machines may find write raw slower than normal write, in which case you may wish to change this option.

Slow Logins
Slow logins are almost always due to the password checking time. Using the lowest practical password level will improve things.

Client Tuning
Often a speed problem can be traced to the client. The client (for example Windows for Workgroups) can often be tuned for better TCP performance. Check the sections on the various clients in Samba and Other CIFS Clients.

Samba Performance Problem Due to Changing Linux Kernel


A user wrote the following to the mailing list: I am running Gentoo on my server and Samba 2.2.8a. Recently I changed kernel versions from linux-2.4.19-gentoo-r10 to linux-2.4.20-wolk4.0s. Now I have a performance issue with Samba. Many of you will probably say, Move to vanilla sources! Well, I tried that and it didn't work. I have a 100MB LAN and two computers (Linux and Windows 2000). The Linux server shares directories with DivX files, the client (Windows 2000) plays them via LAN. Before, when I was running the 2.4.19 kernel, everything was fine, but now movies freeze and stop. I tried moving files between the server and Windows, and it is terribly slow. The answer he was given is: Grab the mii-tool and check the duplex settings on the NIC. My guess is that it is a link

layer issue, not an application layer problem. Also run ifconfig and verify that the framing error, collisions, and so on, look normal for ethernet.

Corrupt tdb Files


Our Samba PDC server has been hosting three TB of data to our 500+ users [Windows NT/XP] for the last three years using Samba without a problem. Today all shares went very slow. Also, the main smbd kept spawning new processes, so we had 1600+ running SMDB's (normally we average 250). It crashed the SUN E3500 cluster twice. After a lot of searching, I decided to rm /var/locks/*.tdb. Happy again. Question: Is there any method of keeping the *.tdb files in top condition, or how can I detect early corruption? Answer: Yes, run tdbbackup each time after stopping nmbd and before starting nmbd. Question: What I also would like to mention is that the service latency seems a lot lower than before the locks cleanup. Any ideas on keeping it top notch? Answer: Yes. Same answer as for previous question!

Samba Performance is Very Slow


A site reported experiencing very baffling symptoms with MYOB Premier opening and accessing its data files. Some operations on the file would take between 40 and 45 seconds. It turned out that the printer monitor program running on the Windows clients was causing the problems. From the logs, we saw activity coming through with pauses of about 1 second. Stopping the monitor software resulted in the networks access at normal (quick) speed. Restarting the program caused the speed to slow down again. The printer was a Canon LBP-810 and the relevant task was something like CAPON (not sure on spelling). The monitor software displayed a "printing now" dialog on the client during printing. We discovered this by starting with a clean install of Windows and trying the application at every step of the installation of other software process (we had to do this many times). Moral of the story: Check everything (other software included)!

Prev Chapter 44. Samba and Other CIFS Clients

Up Home

Next Chapter 46. LDAP and Transport Layer Security

18.13 Melhorando a performance do compartilhamento/servidor


Esta seo trar algumas formas de otimizao do servidor SAMBA que fazem diferena quando os valores adequados so utilizados: A primeira a ativao de um cache de gravao/leitura de arquivos. Este cache feito pela opo write cache size e funciona fazendo o cache dos arquivos que sero lidos/gravados. Ele esvaziado assim que o arquivo for fechado ou quando estiver cheio. O valor especificado nesta opo em bytes e o padro "0" para no causar impacto em sistemas com pouca memria (ou centenas de compartilhamentos). Exemplo:
[publico] path = /pub comment = Diretrio de acesso pblico read only = yes public = yes write cache size = 384000

Compartilha o diretrio /pub (path = /pub) como compartilhamento de nome publico ([publico]), seu acesso ser feito como somente leitura (read only = yes) e o tamanho do cache de leitura/gravao reservado de 384Kb (write cache size = 384000). Deixar a opo para seguir links simblicos ativada (follow symlinks) garante mais performance de acesso a arquivos no compartilhamento. A desativao da opo wide links em conjunto com o uso de cache nas chamadas getwd (getwd cache) permite aumentar a segurana e tem um impacto perceptvel na performance dos dados. A desativao da opo global nt smb support tambm melhora a performance de acesso dos compartilhamentos. Esta uma opo til para detectar problemas de negociao de protocolo e por padro, ela ativada. Caso utiliza um valor de depurao de log muito alto (debug level), o sistema ficar mais lento pois o servidor sincroniza o arquivo aps cada operao. Em uso excessivo do servidor de arquivos, isso apresenta uma degradao perceptvel de performance. A opo prediction permite que o SAMBA faa uma leitura adiante no arquivo abertos como somente-leitura enquanto aguarda por prximos comandos. Esta opo associada com bons valores de write cache size pode fazer alguma diferena. Note que o valor de leitura nunca ultrapassa o valor de "read size". A opo read size permite obter um sincronismo fino entre a leitura e gravao do disco com o envio/recebimento de dados da rede. O valor dependente da instalao local, levando em considerao a velocidade de disco rgido, rede, etc. O valor padro 16384. Em casos onde um NFS montado ou at mesmo leitura em discos locais compartilhada, o parmetro strict locking definido para yes pode fazer alguma diferena de performance. Note que nem todos os sistemas ganham performance com o uso desta opo e no deve ser usada em aplicativos que no requisitam o estado do lock de arquivo ao servidor. Caso voc possua aplicativos que fazem o lock corretamente de arquivos, voc poder usar o share modes = no, isto significa que futuras aberturas de arquivo podem ser feitas em em modo leitura/gravao. Caso utiliza um aplicativo muito bem programado que implementa de forma eficiente de lock, voc poder desativar esta opo. O uso de oplocks yes em compartilhamentos aumenta a performance de acesso a arquivos em at 30%, pois utiliza um cdigo de cache no cliente. Tenha certeza do que est fazendo antes de sair usando oplocks em tudo que lugar. A desativao de kernel oplocks necessria para que isto funcione.

A opo read raw e write raw devem ter seus valores experimentados para ver se faz diferena na performance da sua rede, pois diretamente dependente do tipo de cliente que sua rede possui. Alguns clientes podem ficar mais lentos em modo de leitura raw. O tipo de sistema de arquivos adotado na mquina e suas opes de montagem tem um impacto direto na performance do servidor, principalmente com relao a atualizao de status dos arquivos no sistema de arquivos (hora de acesso, data, etc). O cache de leitura adiante de abertura de arquivos em modo somente leitura aumenta a performance com o uso do oplocks nvel 2. Para isto, ajuste a opo level2 oplocks para yes. A recomendao deste tipo de oplock o mesmo do nvel 1. Como o SAMBA faz o transporte NetBEUI via TCP/IP, ajustes no socket fazem diferena nos dados que trafegam na rede. Como isso dependente de rede voc precisar usar tcnicas de leitura/gravao para determinar quais so as melhores que se encaixam em seu caso. A opo socket options usada para fazer tais ajustes, por exemplo:
socket options = SO_SNDBUF=2048 IPTOS_THROUGHPUT=1

Em especial, a opo TCP_NODELAY apresenta uma perceptvel melhoria de performance no acesso a arquivos locais. OBS:: No use espaos entre o sinal de "=" quando especificar as opes do parmetro socket options.

Você também pode gostar