以前、CentOS 7にMicrosoft SQL Server 2017をインストールしました。
今回はCentOS 8にMicrosoft SQL Server 2019をインストールしてみました。
Quickstart: Install SQL Server and create a database on Red Hat
https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-red-hat?view=sql-server-ver15
RHEL 8にSQL Server 2019をインストールするにはpython2が必要とのことです。
Note
The following commands for SQL Server 2019 points to the RHEL 8 repository. RHEL 8 does not come preinstalled with python2, which is required by SQL Server. Before you begin the SQL Server install steps, execute the command and verify that python2 is selected as the interpreter:
環境
・CentOS Linux release 8.2.2004 (Core)
・4.18.0-193.6.3.el8_2.x86_64
- python2のインストール
- compat-openssl10のインストール
- Repositoryのダウンロード
- MS SQL Serverのインストール
- セットアップの実行
- 確認
- Firewallの許可
1 2 3 4 5 6 7 8 9 |
[root@centos8 ~]# alternatives --config python There is 1 program that provides 'python'. Selection Command ----------------------------------------------- *+ 1 /usr/libexec/no-python Enter to keep the current selection[+], or type selection number: |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
[root@centos8 ~]# dnf -y install python2 Dependencies resolved. ================================================================================ Package Arch Version Repo Size ================================================================================ Installing: python2 x86_64 2.7.17-1.module_el8.2.0+381+9a5b3c3b AppStream 108 k Installing dependencies: python2-libs x86_64 2.7.17-1.module_el8.2.0+381+9a5b3c3b AppStream 6.0 M python2-pip-wheel noarch 9.0.3-16.module_el8.2.0+381+9a5b3c3b AppStream 1.2 M python2-setuptools-wheel noarch 39.0.1-11.module_el8.2.0+381+9a5b3c3b AppStream 289 k Installing weak dependencies: python2-pip noarch 9.0.3-16.module_el8.2.0+381+9a5b3c3b AppStream 1.9 M python2-setuptools noarch 39.0.1-11.module_el8.2.0+381+9a5b3c3b AppStream 643 k Enabling module streams: python27 2.7 Transaction Summary ================================================================================ Install 6 Packages Total download size: 10 M Installed size: 38 M Downloading Packages: (1/6): python2-2.7.17-1.module_el8.2.0+381+9a5b 1.8 MB/s | 108 kB 00:00 (2/6): python2-pip-wheel-9.0.3-16.module_el8.2. 7.9 MB/s | 1.2 MB 00:00 (3/6): python2-pip-9.0.3-16.module_el8.2.0+381+ 7.3 MB/s | 1.9 MB 00:00 (4/6): python2-setuptools-39.0.1-11.module_el8. 8.3 MB/s | 643 kB 00:00 (5/6): python2-setuptools-wheel-39.0.1-11.modul 8.6 MB/s | 289 kB 00:00 (6/6): python2-libs-2.7.17-1.module_el8.2.0+381 9.6 MB/s | 6.0 MB 00:00 -------------------------------------------------------------------------------- Total 9.7 MB/s | 10 MB 00:01 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : python2-setuptools-wheel-39.0.1-11.module_el8.2.0+38 1/6 Installing : python2-pip-wheel-9.0.3-16.module_el8.2.0+381+9a5b3c 2/6 Installing : python2-libs-2.7.17-1.module_el8.2.0+381+9a5b3c3b.x8 3/6 Installing : python2-pip-9.0.3-16.module_el8.2.0+381+9a5b3c3b.noa 4/6 Installing : python2-setuptools-39.0.1-11.module_el8.2.0+381+9a5b 5/6 Installing : python2-2.7.17-1.module_el8.2.0+381+9a5b3c3b.x86_64 6/6 Running scriptlet: python2-2.7.17-1.module_el8.2.0+381+9a5b3c3b.x86_64 6/6 Verifying : python2-2.7.17-1.module_el8.2.0+381+9a5b3c3b.x86_64 1/6 Verifying : python2-libs-2.7.17-1.module_el8.2.0+381+9a5b3c3b.x8 2/6 Verifying : python2-pip-9.0.3-16.module_el8.2.0+381+9a5b3c3b.noa 3/6 Verifying : python2-pip-wheel-9.0.3-16.module_el8.2.0+381+9a5b3c 4/6 Verifying : python2-setuptools-39.0.1-11.module_el8.2.0+381+9a5b 5/6 Verifying : python2-setuptools-wheel-39.0.1-11.module_el8.2.0+38 6/6 Installed: python2-2.7.17-1.module_el8.2.0+381+9a5b3c3b.x86_64 python2-libs-2.7.17-1.module_el8.2.0+381+9a5b3c3b.x86_64 python2-pip-9.0.3-16.module_el8.2.0+381+9a5b3c3b.noarch python2-pip-wheel-9.0.3-16.module_el8.2.0+381+9a5b3c3b.noarch python2-setuptools-39.0.1-11.module_el8.2.0+381+9a5b3c3b.noarch python2-setuptools-wheel-39.0.1-11.module_el8.2.0+381+9a5b3c3b.noarch Complete! |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@centos8 ~]# alternatives --config python There are 2 programs which provide 'python'. Selection Command ----------------------------------------------- *+ 1 /usr/libexec/no-python 2 /usr/bin/python2 Enter to keep the current selection[+], or type selection number: 2 [root@centos8 ~]# alternatives --config python There are 2 programs which provide 'python'. Selection Command ----------------------------------------------- * 1 /usr/libexec/no-python + 2 /usr/bin/python2 Enter to keep the current selection[+], or type selection number: |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
[root@centos8 ~]# dnf -y install compat-openssl10 Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: compat-openssl10 x86_64 1:1.0.2o-3.el8 AppStream 1.1 M Transaction Summary ================================================================================ Install 1 Package Total download size: 1.1 M Installed size: 3.2 M Downloading Packages: compat-openssl10-1.0.2o-3.el8.x86_64.rpm 4.1 MB/s | 1.1 MB 00:00 -------------------------------------------------------------------------------- Total 2.1 MB/s | 1.1 MB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : compat-openssl10-1:1.0.2o-3.el8.x86_64 1/1 Running scriptlet: compat-openssl10-1:1.0.2o-3.el8.x86_64 1/1 Verifying : compat-openssl10-1:1.0.2o-3.el8.x86_64 1/1 Installed: compat-openssl10-1:1.0.2o-3.el8.x86_64 Complete! |
1 2 3 4 5 6 7 8 9 10 11 |
[root@centos8 ~]# curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2019.repo % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 231 100 231 0 0 453 0 --:--:-- --:--:-- --:--:-- 452 [root@centos8 ~]# cat /etc/yum.repos.d/mssql-server.repo [packages-microsoft-com-mssql-server-2019] name=packages-microsoft-com-mssql-server-2019 baseurl=https://packages.microsoft.com/rhel/8/mssql-server-2019/ enabled=1 gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.asc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
[root@centos8 ~]# dnf -y install mssql-server packages-microsoft-com-mssql-server-2019 2.1 MB/s | 1.9 MB 00:00 Dependencies resolved. ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: mssql-server x86_64 15.0.4043.16-4 packages-microsoft-com-mssql-server-2019 209 M Installing dependencies: cyrus-sasl x86_64 2.1.27-1.el8 BaseOS 96 k Transaction Summary ================================================================================ Install 2 Packages Total download size: 210 M Installed size: 1.0 G Downloading Packages: (1/2): cyrus-sasl-2.1.27-1.el8.x86_64.rpm 1.0 MB/s | 96 kB 00:00 (2/2): mssql-server-15.0.4043.16-4.x86_64.rpm 9.1 MB/s | 209 MB 00:23 -------------------------------------------------------------------------------- Total 8.8 MB/s | 210 MB 00:23 warning: /var/cache/dnf/packages-microsoft-com-mssql-server-2019-e6d048b9178d6297/packages/mssql-server-15.0.4043.16-4.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY packages-microsoft-com-mssql-server-2019 3.0 kB/s | 983 B 00:00 Importing GPG key 0xBE1229CF: Userid : "Microsoft (Release signing) <gpgsecurity@microsoft.com>" Fingerprint: BC52 8686 B50D 79E3 39D3 721C EB3E 94AD BE12 29CF From : https://packages.microsoft.com/keys/microsoft.asc Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: cyrus-sasl-2.1.27-1.el8.x86_64 1/2 Installing : cyrus-sasl-2.1.27-1.el8.x86_64 1/2 Running scriptlet: cyrus-sasl-2.1.27-1.el8.x86_64 1/2 Running scriptlet: mssql-server-15.0.4043.16-4.x86_64 2/2 Installing : mssql-server-15.0.4043.16-4.x86_64 2/2 Running scriptlet: mssql-server-15.0.4043.16-4.x86_64 2/2 +--------------------------------------------------------------+ Please run 'sudo /opt/mssql/bin/mssql-conf setup' to complete the setup of Microsoft SQL Server +--------------------------------------------------------------+ Verifying : cyrus-sasl-2.1.27-1.el8.x86_64 1/2 Verifying : mssql-server-15.0.4043.16-4.x86_64 2/2 Installed: cyrus-sasl-2.1.27-1.el8.x86_64 mssql-server-15.0.4043.16-4.x86_64 Complete! |
Express (free) Editionで設定しました。またadministrator(SA)のパスワードも設定します。
Make sure to specify a strong password for the SA account (Minimum length 8 characters, including uppercase and lowercase letters, base 10 digits and/or non-alphanumeric symbols).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
[root@centos8 ~]# /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=2109348 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): 3 The license terms for this product can be found in /usr/share/doc/mssql-server or downloaded from: https://go.microsoft.com/fwlink/?LinkId=2104294 The privacy statement can be viewed at: https://go.microsoft.com/fwlink/?LinkId=853010 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... The licensing PID was successfully processed. The new edition is [Express Edition]. ForceFlush is enabled for this instance. ForceFlush feature is enabled for log durability. Created symlink /etc/systemd/system/multi-user.target.wants/mssql-server.service -> /usr/lib/systemd/system/mssql-server.service. Setup has completed successfully. SQL Server is now starting. |
setupが完了すると自動起動設定、MSSQLが起動が完了しています。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
[root@centos8 ~]# systemctl list-unit-files | grep mssql-server mssql-server.service enabled [root@centos8 ~]# systemctl status mssql-server * mssql-server.service - Microsoft SQL Server Database Engine Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendo> Active: active (running) since Tue 2020-07-27 13:24:13 JST; 41s ago Docs: https://docs.microsoft.com/en-us/sql/linux Main PID: 2790 (sqlservr) Tasks: 149 Memory: 646.5M CGroup: /system.slice/mssql-server.service |-2790 /opt/mssql/bin/sqlservr `-2814 /opt/mssql/bin/sqlservr Jul 27 13:24:18 centos8.rootlinks.net sqlservr[2790]: [158B blob data] Jul 27 13:24:18 centos8.rootlinks.net sqlservr[2790]: [155B blob data] Jul 27 13:24:18 centos8.rootlinks.net sqlservr[2790]: [61B blob data] Jul 27 13:24:18 centos8.rootlinks.net sqlservr[2790]: [96B blob data] Jul 27 13:24:18 centos8.rootlinks.net sqlservr[2790]: [66B blob data] Jul 27 13:24:18 centos8.rootlinks.net sqlservr[2790]: [96B blob data] Jul 27 13:24:18 centos8.rootlinks.net sqlservr[2790]: [100B blob data] Jul 27 13:24:18 centos8.rootlinks.net sqlservr[2790]: [71B blob data] Jul 27 13:24:18 centos8.rootlinks.net sqlservr[2790]: [124B blob data] Jul 27 13:24:22 centos8.rootlinks.net sqlservr[2790]: [315B blob data] |
Configure the Windows Firewall to Allow SQL Server Access
https://docs.microsoft.com/ja-jp/sql/sql-server/install/configure-the-windows-firewall-to-allow-sql-server-access?view=sql-server-ver15
Firewalldのサービスに/usr/lib/firewalld/services/mssql.xmlがありました。
1433/tcpの許可だけでしたが。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
[root@centos8 ~]# cat /usr/lib/firewalld/services/mssql.xml <?xml version="1.0" encoding="utf-8"?> <service> <short>mssql</short> <description>Microsoft SQL Server</description> <port protocol="tcp" port="1433"/> </service> [root@centos8 ~]# firewall-cmd --add-service=mssql --permanent success [root@centos8 ~]# firewall-cmd --reload success [root@centos8 ~]# firewall-cmd --list-all public (active) target: default icmp-block-inversion: no interfaces: ens160 sources: services: cockpit dhcpv6-client mssql ssh ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: |
Windows PCにインストールしたSQL Server Management Studioから接続できました。