Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Latest commit

 

History

History
265 lines (184 loc) · 8.39 KB

File metadata and controls

265 lines (184 loc) · 8.39 KB
title Install SQL Server Machine Learning Services (R and Python) on Linux | Microsoft Docs
description This article describes how to install SQL Server Machine Learning Services (R and Python) on Red Hat and Ubuntu.
author HeidiSteen
ms.author heidist
manager cgronlun
ms.date 08/09/2018
ms.topic conceptual
ms.prod sql
ms.component
ms.suite sql
ms.custom sql-linux
ms.technology machine-learning
monikerRange >=sql-server-ver15||>=sql-server-linux-ver15||=sqlallproducts-allversions

Install SQL Server vNext Machine Learning Services R and Python support on Linux

SQL Server Machine Learning Services (R and Python) runs on Linux operating systems starting in this CTP 2.0 release of SQL Server vNext. Follow these steps to install in-database analytics on either of these Linux operating systems:

Note

SUSE (SLES) is not a supported operating system in this release.

Prerequisites

First install SQL Server vNext. This configures the keys and repositories used when installing the R and Python packages.

Hardware requirements include:

  • Minimum of 2 GB of RAM, maximum 256 GB of RAM
  • Minimum of 4 GB of disk space
  • XFS (default on RHEL) or EXT4 file system
  • Network connectivity to the Internet to download the package
  • A hostname with a maximum of 15 characters
  • wget is a required package to run the configuration script
  • Python3 is required to run the configuration script

Install on RHEL

Download the Microsoft SQL Server Red Hat repository configuration file:

sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo 

Run the following commands to install SQL Server.

sudo yum install -y mssql-server 

Add both R and Python support

Run the following commands to install SQL Server with Machine Learning Services with both R and Python.

# sudo yum install mssql-mlservices-all-9.4.1   

Add R only

Run the following commands to install SQL Server with Machine Learning Services with only R.

# sudo yum install mssql-mlservices-R-9.4.1   

Add Python only

Run the following commands to install SQL Server with Machine Learning Services with only Python.

# sudo yum install mssql-mlservices-python-9.4.1   

Install on Ubuntu

Import the public repository GPG keys:

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - 

Register the Microsoft SQL Server Ubuntu repository:

sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)" 

Run the following commands to install SQL Server vNext.

sudo apt-get update 
sudo apt-get install -y mssql-server 

Add both R and Python support

Run the following commands to install SQL Server with Machine Learning Services with both R and Python:

# sudo apt-get install mssql-mlservices-all-9.4.1   

Add R only

Run the following commands to install SQL Server with Machine Learning Services with only R:

# sudo apt-get install mssql-mlservices-R-9.4.1   

Add Python only

Run the following commands to install SQL Server with Machine Learning Services with only Python:

# sudo apt-get install mssql-mlservices-python-9.4.1   

Unattended installation

For Machine Learning Services, we have added a new environment variable (ACCEPT_ML_EULA) that you can use to accept the ML Services EULA supplement for unattended installations. This is a supplement to the SQL Server EULA.

The following example configures the Developer edition of SQL Server with SQL Server Machine Learning Services. The -n parameter performs an unprompted installation where the configuration values are pulled from the environment variables.

sudo MSSQL_PID=Developer ACCEPT_EULA=Y ACCEPT_ML_EULA=Y SSQL_SA_PASSWORD='<YourStrong!Passw0rd>' /opt/mssql/bin/mssql-conf -n setup 

For more information, see Unattended install.

Offline installation

  1. Locate the MLS-specific package downloads in the Release notes.

  2. Continue with Offline installation instructions for your next step.

Post-install configuration

After the database engine and Machine Learning Services packages are installed, configure the server for operations. This task includes acceptance of SQL Server, R, and Python license agreements and provision of the system administrator (SA) password.

Run the configuration script to accept the license agreement and provide the System Administrator (SA) password:

$ sudo /opt/mssql/bin/mssql-conf setup 

If you already have a SQL Server installation and just want to add the feature machine learning services, then you can install mlservices packages and run the following to accept the mlservices EULA:

$ sudo /opt/mssql/bin/mssql-conf set accept-eula ml 

Configure external script execution

Before running R and Python scripts in SQL Server, enable external script execution:

EXEC sp_configure 'external scripts enabled', 1 
RECONFIGURE WITH OVERRIDE 

Restart SQL Server for the changes to take effect:

# sudo systemctl restart mssql-server 

Verify external script execution

  Execute the following SQL command to test R execution in SQL Server:

EXEC sp_execute_external_script   
@language =N'R', 
@script=N' 
OutputDataSet <- InputDataSet', 
@input_data_1 =N'SELECT 1 AS hello' 
WITH RESULT SETS (([hello] int not null)); 
GO 

Execute the following SQL command to test Python execution in SQL Server:

EXEC sp_execute_external_script  
@language =N'Python', 
@script=N' 
OutputDataSet = InputDataSet; 
', 
@input_data_1 =N'SELECT 1 AS hello' 
WITH RESULT SETS (([hello] int not null)); 
GO 

Add other R and Python packages

You can install other R and Python packages and use them in script that executes on SQL Server vNext.

R packages

  1. Start an R session.

    # sudo /opt/mssql/mlservices/bin/R/R 
  2. Install an R package called “glue” to test package installation.

    # install.packages("glue",lib="/opt/mssql/mlservices/libraries/RServer") 

    Alternatively, you can install an R package from the command line

    # sudo /opt/mssql/mlservices/bin/R/R CMD INSTALL -l /opt/mssql/mlservices/libraries/RServer glue_1.1.1.tar.gz 

  3. Import the R package in sp_execute_external_script

EXEC sp_execute_external_script  
@language = N'R', 
@script = N'library(glue)' 

Python packages

  1. Install a Python package called “httpie” using pip.

    # sudo /opt/mssql/mlservices/bin/python/python -m pip install httpie 

   
2. Import the Python package in sp_execute_external_script

EXEC sp_execute_external_script  
@language = N'Python',  
@script = N'import httpie' 

Limitations in CTP 2.0

The following limitations exist in this CTP release.

  • Implied authentication currently not available in Machine Learning Services on Linux, which means connecting back to the server from within an R or Python script is not supported on Linux at this time.

Next steps

R developers can get started with some simple examples, and learn the basics of how R works with SQL Server. For your next step, see the following links:

Python developers can learn how to use Python with SQL Server by following these tutorials:

To view examples of machine learning that are based on real-world scenarios, see Machine learning tutorials.