Host SQL Server

SQL Server è un sistema di gestione dei database relazionali sviluppato da Microsoft. È un database potente, ampiamente utilizzato nell'industria.

ℹ️ Software non libero

SQL Server is not open source and may have licensing restrictions. Please make sure you have the right to use SQL Server before hosting it on AnduinOS.

Installing SQL Server on AnduinOS does not provide you with a license to use SQL Server. You must obtain a license from Microsoft to use SQL Server.

Please read the Microsoft SQL Server End-User Licensing Agreement⁠ before using SQL Server.

Per ospitare SQL Server su AnduinOS, esegui i seguenti comandi.

Innanzitutto, assicurati che Docker sia installato sulla tua macchina. In caso contrario, puoi installare Docker eseguendo i seguenti comandi:

sudo apt install -y docker.io

Crea una nuova cartella per salvare i file di configurazione del servizio:

# Please install Docker first
mkdir -p ~/Source/ServiceConfigs/SQLServer
cd ~/Source/ServiceConfigs/SQLServer

Assicurati che nessun altro processo stia utilizzando la porta 1433 sulla tua macchina.

function port_exist_check() {
  if [[ 0 -eq $(sudo lsof -i:"$1" | grep -i -c "listen") ]]; then
    echo "$1 is not in use"
    sleep 1
  else
    echo "Warning: $1 is occupied"
    sudo lsof -i:"$1"
    echo "Will kill the occupied process in 5s"
    sleep 5
    sudo lsof -i:"$1" | awk '{print $2}' | grep -v "PID" | sudo xargs kill -9
    echo "Killed the occupied process"
    sleep 1
  fi
}

port_exist_check 1433

Quindi, crea un file docker-compose.yml con il seguente contenuto:

cat << EOF > ./docker-compose.yml
version: '3.3' 

services:
  sqlserver:
    image: mcr.microsoft.com/mssql/server:2019-latest
    ports:
      - target: 1433
        published: 1433
        protocol: tcp
        mode: host
    environment:
      SA_PASSWORD: "YourStrong!Passw0rd"
      ACCEPT_EULA: "Y"
    volumes:
      - sqlserver-data:/var/opt/mssql

volumes:
  sqlserver-data:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: /swarm-vol/sqlserver/data
EOF
sudo mkdir -p /swarm-vol/sqlserver/data

Quindi, distribuisci il servizio:

sudo docker swarm init  --advertise-addr $(hostname -I | awk '{print $1}')
sudo docker stack deploy -c docker-compose.yml sqlserver --detach

Tutto fatto! Hai eseguito con successo l'hosting di SQL Server su AnduinOS.

L'utente predefinito è sa e la password è YourStrong!Passw0rd.

Per gestire il tuo SQL Server, si consiglia di installare Azure Data Studio. Puoi seguire le istruzioni qui.

Disinstalla

Per disinstallare SQL Server, esegui i seguenti comandi:

sudo docker stack rm sqlserver
sleep 20 # Wait for the stack to be removed
sudo docker system prune -a --volumes -f # Clean up used volumes and images

Per rimuovere anche i file di dati, log e configurazione, esegui i seguenti comandi:

sudo rm /swarm-vol/sqlserver -rf

Ecco fatto! Hai disinstallato con successo SQL Server da AnduinOS.

Commenti (0)

Nessun commento. Sii il primo a lasciarne uno!