CentOS Linux üzerine MsSQL Kurulumu

4 dk okuma süresi
SUNUCU.COM.TR
Kategoriler:Linux Sunucular
Bu yazıda Linux'ta Microsoft SQL veya MSSQL'in nasıl kurulacağını anlatacağız. Ortak adı MSSQL olarak adlandırılan Microsoft SQL, Microsoft tarafından oluşturulan ilişkisel bir veritabanı yönetim sistemidir. Açık kaynaklı MySQL ve PostgreSQL tipik olarak Linux dağıtımları ile çalışır, ancak Linux'ta MSSQL ile çalıştırabilirsiniz. MSSQL, açık kaynaklı meslektaşlarının(MySQL, PostgreSQL) yapmadığı bazı özellikler sunar ve uygulama gereksinimlerine bağlı olarak, bir RDBMS için doğru seçim olabilir. Bu yazıda, MsSQL'in CentOS 7 ve Ubuntu 18.04'e nasıl kurulacağını anlatacağız.

Kurulum öncesi kontrol

  • Sunucunuzun en az 2 GB belleğe sahip olduğunu doğrulamanız gerekir.
  • Bu talimatlar, root kullanıcısı olarak CentOS 7 ve Ubuntu 18.04 LTS sunucularında yapılmaktadır.

CentOS 7 MsSQL Kurulumu

Adım 1: MSSQL 2019 Önizleme Repo Ekleme

İlk olarak, en stabil uygulamarı kullanmak için sunucunuzdaki tüm paketlerin güncel olduğundan emin olun: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@centos ~]# yum update -y[/su_note] Daha sonra, paket yöneticisi yum'a, uygun repoyu ekleyerek mssql-server paketini nerede arayacağımızı söylememiz gerekir: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@centos ~]# curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-preview.repo[/su_note]

Adım 2: SQL Server'ı yükleyin

Artık yum, MsSQL deposunun nerede olduğunu biliyor, paketi kurmak için yum kullanabiliriz: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@centos ~]# yum install -y mssql-server[/su_note]

Adım 3: MsSQL Sunucusunu Yapılandırma

Daha sonra, SQL'i bir sistem yöneticisi şifresi ile yapılandırmamız ve kullanmak istediğimiz sürümü onaylamamız gerekiyor. Bu eğitimde, ücretsiz olduğu için, 2. seçimdeki Geliştirici sürümü kullanılacaktır: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@centos ~]# /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] Bundan sonra, mssql hizmetinin çalıştığını doğrulamamız gerekiyor: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@centos ~]# systemctl status mssql-server[/su_note] Çıktı şöyle görünmelidir: [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

SQL sunucunuzun uzaktan erişilebilir olmasını istiyorsanız, SQL Server bağlantı noktasını(port) açmanız gerekir: Not: Dikkatli hareket edin. Sunucunuzun 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çmak gerekmez. [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@centos ~]# firewall-cmd --zone=public --add-port=1433/tcp --permanent[/su_note] Kuralı ekledikten sonra, güvenlik duvarı kurallarımızı yeniden yüklememiz ve bağlantı noktasının açık olduğunu doğrulamamız gerekiyor: [su_note note_color="#f1f1f1" text_color="#000" radius="0"][root@centos ~]# firewall-cmd --reload success root@centos ~]# firewall-cmd --list-ports 1433/tcp[/su_note]

Adım 5: Microsoft Red Hat deposu ekleyin

SQL sunucumuzla etkileşime geçme yoluna ihtiyacımız var. Öncelikle, başka bir repo ekleyelim, böylece SQL Server komut satırı araçlarını yüklemek için yum kullanabiliriz [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@centos ~]# curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo[/su_note]

Adım 6: MSSQL Server komut satırı araçlarını kurun

Yum, kurmak istediğimiz paketleri artık biliyor ve yüklenmesi gerekir. Bu paketlerin kurulumu sırasında, lisans koşullarını kabul etmek için birkaç onay isteği olacağını unutmayın: root@centos ~]# yum install -y mssql-tools unixODBC-devel Kullanım kolaylığı için aşağıdaki yolu ekleyebiliriz [su_note note_color="#f1f1f1" text_color="#000" radius="0"]/opt/mssql-tools/bin/[/su_note] Sunucudaki PATH değişkenini değiştirerek sql komutlarını sunucudaki herhangi bir konumdan çalıştırabiliriz: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@centos ~]# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile root@centos ~]# source ~/.bashrc[/su_note] Son adım, SQL Server ile bağlantı kurabileceğimizi doğrulayalım: [su_note note_color="#f1f1f1" text_color="#000" radius="0"]root@centos ~]# sqlcmd -S localhost -U SA Password: 1>[/su_note]