Ubuntu Linux MsSQL Kurulumu
4 dk okuma süresi
SUNUCU.COM.TR
Kategoriler:Linux Sunucular
Ubuntu 18.04 LTS MsSQL Kurulumu
Adım 1: MSSQL Server Ubuntu 2019 önizleme deposunu ekleyin
İlk önce sunucu paketlerini güncelleyelim: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804:~# apt-get update -y[/su_note] Sunucu paketleri güncellendikten sonra, eklemek istediğimiz depo için GPG anahtarlarını eklememiz gerekir. GPG anahtarları, Linux kullanıcılarının dosyaların geçerliliğini ve güvenilir kaynaklardan geldiklerini doğrulamaları için bir yoldur: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804:~# wget -qO- https://packages.microsoft.com/keys/microsoft.asc | apt-key add -[/su_note] Artık GPG anahtarları yerinde olduğu için depoyu ekleyebiliriz: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804:~# add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-preview.list)"[/su_note] Yeni eklediğimiz depo bir HTTPS bağlantısı gerektiriyor. Apt'nin repoya bağlanabilmesini sağlamak için https üzerinden bağlanabileceğinden emin olmamız gerekir: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804:~# apt-get install -y apt-transport-https[/su_note]Adım 2: MSSQL Sunucusunu Kuralım
Artık MSSQL Server paketlerini içeren repo kullanıma hazır olduğundan, geriye kalan tek şey apt'nin yeni repoyu bildiğinden ve MSSQL Server'ı yüklediğinden emin olmaktır: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804:~# apt-get update -y apt-get install -y mssql-server[/su_note]Adım 3: MSSQL Sunucusunu Yapılandırma
Yapılandırma adımı hem CentOS 7'de hem de Ubuntu 18.04'te aynıdır. Yapılandırma işlemi sırasında SQL Server sürümünü seçmek, lisans şartlarını kabul etmek ve bir SQL yönetici şifresi girmek için uyarılar olacaktır: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804~]# /opt/mssql/bin/mssql-conf setup usermod: no changes Choose an edition of SQL Server: 1) Evaluation (free, no production use rights, 180-day limit) 2) Developer (free, no production use rights) 3) Express (free) 4) Web (PAID) 5) Standard (PAID) 6) Enterprise (PAID) - CPU Core utilization restricted to 20 physical/40 hyperthreaded 7) Enterprise Core (PAID) - CPU Core utilization up to Operating System Maximum 8) I bought a license through a retail sales channel and have a product key to enter. Details about editions can be found at https://go.microsoft.com/fwlink/?LinkId=852748&clcid=0x409 Use of PAID editions of this software requires separate licensing through a Microsoft Volume Licensing program. By choosing a PAID edition, you are verifying that you have the appropriate number of licenses in place to install and run this software. Enter your edition(1-8): 2 The license terms for this product can be found in /usr/share/doc/mssql-server or downloaded from: https://go.microsoft.com/fwlink/?LinkId=855862&clcid=0x409 The privacy statement can be viewed at: https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x409 Do you accept the license terms? [Yes/No]:Yes Enter the SQL Server system administrator password: Confirm the SQL Server system administrator password: Configuring SQL Server... This is an evaluation version. There are [116] days left in the evaluation period. ForceFlush is enabled for this instance. ForceFlush feature is enabled for log durability. Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /usr/lib/systemd/system/mssql-server.service. Setup has completed successfully. SQL Server is now starting.[/su_note] MSSQL Server şimdi çalışıyor ve etkin durumda. Bunu doğrulamak için aşağıdaki komutu çalıştırabiliriz: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804:~# systemctl status mssql-server --no-pager * mssql-server.service - Microsoft SQL Server Database Engine Loaded: loaded (/lib/systemd/system/mssql-server.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2019-10-24 00:24:23 EDT; 3min 45s ago Docs: https://docs.microsoft.com/en-us/sql/linux Main PID: 19446 (sqlservr) Tasks: 135 Memory: 548.5M CPU: 12.499s CGroup: /system.slice/mssql-server.service |-19446 /opt/mssql/bin/sqlservr `-19485 /opt/mssql/bin/sqlservr[/su_note]4. Adım (İsteğe bağlı): Uzaktan Bağlantılara İzin Vermek
Yeni SQL Server'ınıza uzak bir bağlantı kullanmak istiyorsanız, SQL Server portunu açmak gerekir: Not: Yine dikkatli devam edin. Sunucunuzu erişimi sınırlandırarak güvende tutmak için güvenlik duvarları vardır. SQL Server'a uzaktan erişmeyi planlamıyorsanız, bu bağlantı noktasını açmanız gerekmez. Güvenlik duvarı komutlarını uzun uzun yazmak istemiyorsanız, kısaltmak için, Komplike Olmayan Güvenlik Duvarı olarak bilinen ufw'yi yükleyin: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804:~# apt-get install -y ufw[/su_note] Kurulduktan sonra ufw etkinleştirilmelidir. SSH bağlantınızın kesilebileceğini belirten bir uyarı göreceksiniz. SSH oturumunuz bağlı değilse, tekrar oturum açın ve devam edin: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804:~# ufw enable Command may disrupt existing ssh connections. Proceed with operation (y|n)? y firewall is active and enabled on system startup[/su_note] Artık ufw yerinde ve etkin durumda, 1433 numaralı bağlantı noktasına giden trafiğe izin verelim: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804:~# ufw allow 1433 Rule added Rule added (v6)[/su_note]Adım 5: MSSQL Server komut satırı araçlarını kurun
Öncelikle, MSSQL komut satırı araçlarını içeren repo için bazı yeni GPG anahtarları eklememiz gerekir: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804:~# curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -[/su_note] Şimdi depoyu ekleyebiliriz: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804:~# curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | tee /etc/apt/sources.list.d/msprod.list[/su_note] Bundan sonra apt komutunu güncelleyin ve komut satırı araçlarını yükleyin: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804:~# apt-get update -y t@ubuntu1804:~# apt-get install -y mssql-tools unixodbc-dev[/su_note] Yükleme sırasında aşağıdaki gibi görünen lisansları kabul etmek için bir veya iki onaylı bilgi istemi olmalıdır:
Sunucunun herhangi bir yerinde sqlcmd'nin çalıştırılmasını kolaylaştıralım:
[su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804:~# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile root@ubuntu1804:~# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc[/su_note]
[su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804:~# source ~/.bashrc[/su_note]
Son olarak, yerel olarak MSSQL Sunucusuna bağlanabileceğimizi doğrulayalım:
[su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@ubuntu1804:~# sqlcmd -S localhost -U SA Password: 1>[/su_note]