Arquivo da tag: Linux

O que é FreeTDS?

FreeTDS is a set of libraries for Unix and Linux that allows your programs to natively talk to Microsoft SQL Server and Sybase databases.

Technically speaking, FreeTDS is an open source implementation of the TDS (Tabular Data Stream) protocol used by these databases for their own clients. It supports many different flavors of the protocol and three APIs to access it. Additionally FreeTDS works with other software such as Perl and PHP, providing access from those languages as well.

If you are looking for a Java implementation, we refer you to the jTDS project on SourceForge.

FreeTDS has many possible uses. It has been used by Unix/Linux webservers to present data stored in SQL Server to the web, to port SQL Server database code from NT to Unix, to import data into SQL Server from a Unix source, and to provide database access on platforms (such as realtime systems) that have no native drivers.

The FreeTDS C libraries are available under the terms of the GNU LGPL license. Consult COPYING.LIB in the distribution for details.

http://www.freetds.org/

File name: config_freetds_linux.sh

sudo apt-get install wget
sudo apt-get install build-essential
sudo apt-get install libc6-dev
 
wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.00.27.tar.gz
tar -xzf freetds-1.00.27.tar.gz
cd freetds-1.00.27
./configure --prefix=/usr/local --with-tdsver=7.3
make
sudo make install

Ubuntu – Limpando Memória Cache e Swap Linux

Quando é necessário limpar a memória Cache e Swap do Linux no Ubuntu ?

Depende…. Caso você não use seu Ubuntu em frequências muito altas de processamento e memória talvez nunca irá precisar, mas nós desenvolvedores que usamos as ferramentas que cada vez mais exigem de nosso Hardware é extremamente importante limparmos nossa memória em casos mais extremos de testes locais, por isso neste Post vou citar apenas um script muito simples que utilizo no meu dia a dia que para mim é muito eficaz e espero que seja para você também ?

Abra seu prompt de comando no Ubuntu e digite o comando conforme abaixo:

  • gedit limpezaCacheSwap.sh

Aqui será criado um arquivo chamado limpezaCacheSwap.sh

Dentro deste arquivo cole o conteúdo abaixo:

echo “Limpando Cache e Swap…”

echo 3 > /proc/sys/vm/drop_caches
sysctl -w vm.drop_caches=3 
swapoff -a && swapon -a
clear
echo “Limpeza do Cache e Swap efetuada com sucesso”

Salve e Feche o arquivo:

Agora volte ao seu prompt e dê as permissões necessárias para executarmos o arquivo.

  • sudo chmod 755 limpezaCacheSwap.sh

Execute o comando abaixo para ver em MB como está sua memória Cache:

  • free -m

Imagem Blog UansCarvalho

Para executar seu arquivo lembre-se sempre de executá-lo com o SUDO

  • sudo ./limpezaCacheSwap.sh

Agora execute novamente o comando:

  • free -m

Imagem Blog UansCarvalho

Obs: Frisei o teste em Ubuntu pois não testei estes comandos em outra distribuição Linux.

Limpando Memória Cache e Swap Linux – Ubuntu

How To Install Microsoft SQL Server On Ubuntu Linux

In December 2016 Microsoft made their SQL Server database available in Linux. Here we’ll cover how to install and perform basic setup of MSSQL in the Ubuntu distribution of Linux.

Install MSSQL In Ubuntu 16.10

First we’ll set up the repository file, Microsoft provide a copy of this for Ubuntu here: https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list

We’ll use the wget command to copy this file to the /etc/apt/sources.list.d directory so that we can use it using apt-get. After this we run ‘apt-get update’ in order to sync the package index files with the new source that we’ve just added.

root@ubuntu:~# wget https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list -O /etc/apt/sources.list.d/mssql-server.list
root@ubuntu:~# apt-get update

At the time of writing, the 16.10 directory at https://packages.microsoft.com/ubuntu/16.10/mssql-server/ was empty, so I have instead used the 16.04 files here which seems to have worked just fine.

Now that the repository file is in place, installation is as simple as running the following command. At the time of writing the total size of the package and all dependencies was a 747mb download.

root@ubuntu:~# apt-get install mssql-server -y
...
+-------------------------------------------------------------------+
| Please run /opt/mssql/bin/sqlservr-setup to complete the setup of |
|                  Microsoft(R) SQL Server(R).                      |
+-------------------------------------------------------------------+

Once the installation has completed, we are advised to run the /opt/mssql/bin/sqlservr-setup bash script to complete the setup process.

During my first installation attempt, I got the following error as my virtual machine was only running with 2GB of memory, so be sure that you have enough memory before proceeding.

sqlservr: This program requires a machine with at least 3250 megabytes of memory.
Microsoft(R) SQL Server(R) setup failed with error code 1.

You’ll be able to proceed once you have adequate memory available.

root@ubuntu:~# /opt/mssql/bin/sqlservr-setup
Microsoft(R) SQL Server(R) Setup

You can abort setup at anytime by pressing Ctrl-C. Start this program
with the --help option for information about running it in unattended
mode.

The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746388 and found
in /usr/share/doc/mssql-server/LICENSE.TXT.

Do you accept the license terms? If so, please type "YES": YES

Please enter a password for the system administrator (SA) account:
Please confirm the password for the system administrator (SA) account:

Setting system administrator (SA) account password...

Do you wish to start the SQL Server service now? [y/n]: y
Do you wish to enable SQL Server to start on boot? [y/n]: y
Created symlink /etc/systemd/system/multi-user.target.wants/mssql-server.service â /lib/systemd/system/mssql-server.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mssql-server-telemetry.service â /lib/systemd/system/mssql-server-telemetry.service.

Setup completed successfully.

That’s it, Microsoft SQL Server is now running successfully and listening for traffic on TCP port 1434.

root@ubuntu:~# systemctl status mssql-server
â mssql-server.service - Microsoft(R) SQL Server(R) Database Engine
   Loaded: loaded (/lib/systemd/system/mssql-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2016-12-30 22:55:23 AEDT; 33s ago
 Main PID: 4164 (sqlservr)
   CGroup: /system.slice/mssql-server.service
           ââ4164 /opt/mssql/bin/sqlservr
           ââ4201 /opt/mssql/bin/sqlservr

root@ubuntu:~# netstat -antp | grep 1434
tcp        0      0 127.0.0.1:1434          0.0.0.0:*               LISTEN      4201/sqlservr

Connecting To MSSQL

In order to actually connect to the server from Linux we need to install the mssql-tools package, which comes from a different repository than the one that we just set up. It can be found here: https://packages.microsoft.com/config/ubuntu/16.04/prod.list

First we’ll download a copy of the prod.list file and place it into the /etc/apt/sources.list.d directory.

root@ubuntu:~# wget https://packages.microsoft.com/config/ubuntu/16.04/prod.list -O /etc/apt/sources.list.d/pord.list
root@ubuntu:~# apt-get update

We can now proceed with installing the mssql-tools package, as shown below.

root@ubuntu:~# apt-get install mssql-tools -y

Once this is installed we can use the sqlcmd command to interact with the database. To see how to run sqlcmd, simply run it with the -? option for help.

Unfortunately it appears that when you specify the -P option for the password, the password must be provided in the command line with no option of being prompted for it later. Keep in mind that your password will be stored in your bash history running it this way.

root@ubuntu:~# sqlcmd -U SA -P password
1> create database test;
2> go
1> use test;
2> go
Changed database context to 'test'.
1> create table websites(domain varchar(255));
2> go
1> insert into websites (domain)
2> values ('rootusers.com');
3> go

(1 rows affected)
1> select domain
2> from websites;
3> go
domain
rootusers.com
(1 rows affected)

In this example we create a test database with a table named websites and a column for domain names. We then insert a domain name and pull it back out with select, confirming both that we are able to connect and that basic SQL queries appear to be working as expected.

Summary

Microsoft’s SQL Server is now available for installation on Linux. Personally I don’t think I’ll ever use this over other alternatives such as MariaDB or PostgreSQL, so hopefully someone somewhere actually finds this information useful!

https://www.rootusers.com/how-to-install-microsoft-sql-server-on-ubuntu-linux

CONFIGURANDO DYNDNS NO UBUNTU

Tive dificuldade em achar um tutorial para explicar a configuração do ddclient no GNU/Linux, por isso decidi criar esta dica. Espero que ajude.

O ddclient nada mas é do que um cliente DNS dinâmico. Ele trabalha com vários serviços, mas hoje, mostraremos para funcionamento do dyndns.org.

Instalação via terminal:

sudo apt-get install ddclient

Após a instalação, ele vai pedir os dados do cliente, que são:

  • Nome de usuário;
  • Senha;
  • Nome do host;
  • Interface Internet.

Após preenchido e configurado, vamos adequar sua Internet no próximo passo.

Você deve configurar o ddclient de acordo com a sua Internet. Irei mostrar como ficam os três principais métodos.

1. Arquivo de configuração para uso via NAT: /etc/ddclient.conf

protocol=dyndns2 # Padrão de protocolo DynDNS
use=web, if=eth0 # O web informa que você esta usando NAT e o eth0 informa a interface da Internet
server=members.dyndns.org # Informa qual o serviço
login=usuario cadastrado # Login do usuário
password=’senha cadastrada’ # Senha do usuário entre aspas simples
host cadastrado # host criado. Não deve ter nenhuma descrição antes

2. Arquivo de configuração para IP fixo: /etc/ddclient.conf

protocol=dyndns2 # Padrão de protocolo DynDNS
use=if, if=eth0 # O if informa que você está usando o IP da interface de rede. eth0 informa a interface da Internet
server=members.dyndns.org # informa qual o serviço
login=usuario cadastrado # Login do usuário
password=’senha cadastrada’ # Senha do usuário entre aspas simples
host cadastrado # Host criado. Não deve ter nenhuma descrição antes

3. Arquivo de configuração para PPPoE: /etc/ddclient.conf

protocol=dyndns2 # Padrão de protocolo DynDNS
use=if, if=ppp0 # O if informa que você está usando o IP da interface de rede. ppp0 informa a interface da Internet
server=members.dyndns.org # Informa qual o serviço
login=usuario cadastrado # Login do usuário
password=’senha cadastrada’ # Senha do usuário entre aspas simples
host cadastrado # Host criado. Não deve ter nenhuma descrição antes

Para ele funcionar como daemon e carregar junto com o sistema, você deve seguir os passos abaixo.

Sistema Ubuntu Server 12.04:

sudo mcedit /etc/default/ddclient

Adicione/edite as linhas:

run_daemon=”true” # Linha que ativa o daemon.

daemon_interval=”300″ # Período em segundo que ela vai ficar atualizando o servidor.

Muito obrigado pela atenção.

Espero que tenham gostado do tutorial sobre ddclient com Ubuntu.

https://www.vivaolinux.com.br/dica/Configurando-DynDNS-no-Ubuntu