株式会社ヴァンデミックシステム

Blog

<スポンサーリンク>

CentOS7.4にSQL Server 2017をインストールしてみたよ。
ちなみにメモリは4GB割り振ったよ。インストール時に3250MB空きメモリがないとインストールできないみたいよ。
MSの以下サイトを参考にしたよ。
https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-red-hat

 

SQL Serverのインストール

#SQL Server用リポジトリを登録
[root@SQLSERVER ~]# curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo -k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   232  100   232    0     0    299      0 --:--:-- --:--:-- --:--:--   299

#証明書エラーが出力されてインストールできないので、「sslverify=0」を追記
[root@SQLSERVER ~]# vi /etc/yum.repos.d/mssql-server.repo
[packages-microsoft-com-mssql-server-2017]
name=packages-microsoft-com-mssql-server-2017
baseurl=https://packages.microsoft.com/rhel/7/mssql-server-2017/
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
sslverify=0
[root@SQLSERVER ~]#

#インストール
[root@SQLSERVER ~]# yum install -y mssql-server
+--------------------------------------------------------------+
'sudo /opt/mssql/bin/mssql-conf setup' を実行し、
Microsoft SQL Server のセットアップを完了してください
+--------------------------------------------------------------+

  検証中                  : gdb-7.6.1-100.el7.x86_64                                                                                                                                1/4
  検証中                  : mssql-server-14.0.3008.27-1.x86_64                                                                                                                      2/4
  検証中                  : libsss_nss_idmap-1.15.2-50.el7_4.8.x86_64                                                                                                               3/4
  検証中                  : bzip2-1.0.6-13.el7.x86_64                                                                                                                               4/4

インストール:
  mssql-server.x86_64 0:14.0.3008.27-1

依存性関連をインストールしました:
  bzip2.x86_64 0:1.0.6-13.el7                             gdb.x86_64 0:7.6.1-100.el7                             libsss_nss_idmap.x86_64 0:1.15.2-50.el7_4.8

完了しました!

#セットアップを実行
[root@SQLSERVER ~]# /opt/mssql/bin/mssql-conf setup
SQL Server のエディションを選択します:
  1) Evaluation (無料、製品使用権なし、期限 180 日間)
  2) Developer (無料、製品使用権なし)
  3) Express (無料)
  4) Web (有料)
  5) Standard (有料)
  6) Enterprise (有料)
  7) Enterprise Core (有料)
  8) 小売販売チャネルを介してライセンスを購入し、入力するプロダクト キーを持っています。

エディションの詳細については、以下を参照してください
https://go.microsoft.com/fwlink/?LinkId=852748&clcid=0x411

このソフトウェアの有料エディションを使用するには、個別のライセンスを以下から取得する必要があります
Microsoft ボリューム ライセンス プログラム。
有料エディションを選択することは、
このソフトウェアをインストールおよび実行するための適切な数のライセンスがあることを確認していることになります。

エディションを入力してください(1-8): 1  ←とりあえず評価版でいいので、「1」を選択
この製品のライセンス条項は
/usr/share/doc/mssql-server で参照できるほか、次の場所からダウンロードすることもできます:
https://go.microsoft.com/fwlink/?LinkId=855864&clcid=0x411

プライバシーに関する声明は、次の場所で確認できます:
https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x411

ライセンス条項に同意しますか? [Yes/No]:yes  ←「yes」応答


SQL Server の言語の選択:
(1) English
(2) Deutsch
(3) Espanol
(4) Francais
(5) Italiano
(6) 日本語
(7) ???
(8) Portugues
(9) Русский
(10) 中文 ? ?体
(11) 中文 (繁体)
オプション 1-11 を入力: 6  ←日本語がいいので、「6」応答
SQL Server システム管理者パスワードを入力してください:
SQL Server システム管理者パスワードを確認入力してください:
SQL Server を構成しています...

Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /usr/lib/systemd/system/mssql-server.service.
セットアップは正常に完了しました。SQL Server を起動しています。

#サービスが起動中であることを確認
[root@SQLSERVER ~]# systemctl status mssql-server
● mssql-server.service - Microsoft SQL Server Database Engine
   Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
   Active: active (running) since 木 2017-12-21 10:27:34 JST; 38s ago
     Docs: https://docs.microsoft.com/en-us/sql/linux
 Main PID: 11319 (sqlservr)
   CGroup: /system.slice/mssql-server.service
           tq11319 /opt/mssql/bin/sqlservr
           mq11340 /opt/mssql/bin/sqlservr

12月 21 10:27:42 SQLSERVER sqlservr[11319]: 2017-12-21 10:27:42.70 spid6s      2017-12-21 10:27:42.70 spid6s      Recovery is writing a checkpoint in database 'msdb' (4)...s required.
12月 21 10:27:42 SQLSERVER sqlservr[11319]: 2017-12-21 10:27:42.70 spid19s     SQL Server is now ready for client connections. This is an informational message; no user ...s required.
12月 21 10:27:42 SQLSERVER sqlservr[11319]: 2017-12-21 10:27:42.89 spid14s     Polybase 2017-12-21 10:27:42.89 spid14s     Polybase feature disabled.
12月 21 10:27:42 SQLSERVER sqlservr[11319]: 2017-12-21 10:27:42.89 spid14s     tempdb 2017-12-21 10:27:42.89 spid14s     Clearing tempdb database.
12月 21 10:27:44 SQLSERVER sqlservr[11319]: 2017-12-21 10:27:44.86 spid14s     2017-12-21 10:27:44.86 spid14s     Starting up database 'tempdb'.
12月 21 10:27:45 SQLSERVER sqlservr[11319]: 2017-12-21 10:27:45.14 spid14s     tempdb 2017-12-21 10:27:45.14 spid14s     The tempdb database has 1 data file(s).
12月 21 10:27:45 SQLSERVER sqlservr[11319]: 2017-12-21 10:27:45.15 spid22s     Service Broker 2017-12-21 10:27:45.15 spid22s     The Service Broker endpoint is in disabl...pped state.
12月 21 10:27:45 SQLSERVER sqlservr[11319]: 2017-12-21 10:27:45.15 spid22s     Database Mirroring 2017-12-21 10:27:45.15 spid22s     The Database Mirroring endpoint is i...pped state.
12月 21 10:27:45 SQLSERVER sqlservr[11319]: 2017-12-21 10:27:45.17 spid22s     Service Broker 2017-12-21 10:27:45.17 spid22s     Service Broker manager has started.
12月 21 10:27:45 SQLSERVER sqlservr[11319]: 2017-12-21 10:27:45.28 spid6s      2017-12-21 10:27:45.28 spid6s      Recovery is complete. This is an informational message ...s required.
Hint: Some lines were ellipsized, use -l to show in full.

#ファイアウォールの穴開け SQL Serverは1433/tcpを使う
[root@SQLSERVER ~]# firewall-cmd --zone=public --add-port=1433/tcp --permanent
success
[root@SQLSERVER ~]# firewall-cmd --reload
success

 

SQL Server用ツールのインストール

#SQL Server用ツールのリポジトリを登録
[root@SQLSERVER ~]# curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo -k

#古い「unixODBC-utf16 」を一旦削除 後のツールインストール時の依存関係により最新版がインストールされる
[root@SQLSERVER ~]# yum remove unixODBC-utf16 unixODBC-utf16-devel
読み込んだプラグイン:fastestmirror
引数に一致しません: unixODBC-utf16
引数に一致しません: unixODBC-utf16-devel
削除対象とマークされたパッケージはありません。

#証明書エラーが出力されてインストールできないので、「sslverify=0」を追記
[root@SQLSERVER ~]# vi /etc/yum.repos.d/msprod.repo
[packages-microsoft-com-prod]
name=packages-microsoft-com-prod
baseurl=https://packages.microsoft.com/rhel/7/prod/
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
sslverify=0
[root@SQLSERVER ~]#


#インストール インストール時にライセンスへの同意が必要
[root@SQLSERVER ~]# yum  -yinstall mssql-tools                                                                                                                      2/4
The license terms for this product can be downloaded from
https://aka.ms/odbc131eula and found in
/usr/share/doc/msodbcsql/LICENSE.TXT . By entering 'YES',
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
YES  ←「YES」応答
  インストール中          : msodbcsql-13.1.9.1-1.x86_64                                                                                                                             3/4
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746949 and found in
/usr/share/doc/mssql-tools/LICENSE.txt . By entering 'YES',
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
YES  ←「YES」応答
  インストール中          : mssql-tools-14.0.6.0-1.x86_64                                                                                                                           4/4
  検証中                  : msodbcsql-13.1.9.1-1.x86_64                                                                                                                             1/4
  検証中                  : unixODBC-2.3.1-11.el7.x86_64                                                                                                                            2/4
  検証中                  : mssql-tools-14.0.6.0-1.x86_64                                                                                                                           3/4
  検証中                  : libtool-ltdl-2.4.2-22.el7_3.x86_64                                                                                                                      4/4

インストール:
  mssql-tools.x86_64 0:14.0.6.0-1

依存性関連をインストールしました:
  libtool-ltdl.x86_64 0:2.4.2-22.el7_3                             msodbcsql.x86_64 0:13.1.9.1-1                             unixODBC.x86_64 0:2.3.1-11.el7

完了しました!

#コマンドのパス通し
[root@SQLSERVER ~]# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
[root@SQLSERVER ~]# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
[root@SQLSERVER ~]# source ~/.bashrc

 

ツールを使用し、SQLを実行してみる

#DBにログインし、基本コマンドを実行してみる
[root@SQLSERVER ~]# sqlcmd -S localhost -U SA
Password:
1> CREATE DATABASE TestDB
2> SELECT Name from sys.Databases
3> GO
Name
--------------------------------------------------------------------------------------------------------------------------------
master
tempdb
model
msdb
TestDB

(5 rows affected)
1> USE TestDB
2> CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT)
3> INSERT INTO Inventory VALUES (1, 'banana', 150); INSERT INTO Inventory VALUES (2, 'orange', 154);
4> GO
データベース コンテキストが 'TestDB' に変更されました。

(1 rows affected)

(1 rows affected)
1> SELECT * FROM Inventory WHERE quantity > 152;
2> GO
id          name                                               quantity
----------- -------------------------------------------------- -----------
          2 orange                                                     154

(1 rows affected)
1> QUIT

<スポンサーリンク>

コメントを残す

Allowed tags:  you may use these HTML tags and attributes: <a href="">, <strong>, <em>, <h1>, <h2>, <h3>
Please note:  all comments go through moderation.

*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)