Microsoft SQL Server ?? ???? ??? ?????? ????? ???????? ????????? (RDBMS) ??? ???????? ??????? ????? Windows. ??? ???? ???? Microsoft ?????? ????? ????? Linux? ??? ???? ?????????? ?????? SQL Server ??? ????? ??????. ?????? ??? ?????? ???? ????? ????? Microsoft SQL Server ??? Linux? ?????? ????? ??????? ???? ??????? ????????? ???????? ?????? ????? ??????????? ?????? ???? ?????? ?????? ??????.

?????? 1: ????? Microsoft SQL Server ??? Linux

?????? Microsoft SQL Server ??? ???? Linux? ???? ??????? ???????:

  1. ?? ?????? ??????:
    sudo apt-get update
  2. ?? ?????? ???? SQL Server:
    sudo apt-get install -y mssql-server
  3. ?? ?????? ???????:
    sudo /opt/mssql/bin/mssql-conf setup

    ???? ???????? ?????? ??? ???? ???? ??????? ?????? ???? ???? ??????? ??????? (SA).

  4. ???? ?? ???????:
    systemctl status mssql-server

    ????? ??? ????? ???? ???? SQL Server. ???? ?? ???? ????.

?????? 2: ????? ????? ??????

??? ????? SQL Server? ????? ????? ????? ?????? ???????? ??????? ???????:

  1. ??????? ?? SQL Server:
    sqlcmd -S localhost -U SA -P 'YourPassword'
  2. ????? ????? ?????? ?????:
    CREATE DATABASE TestDB;
  3. ?????? ?? ????? ????? ????????:
    SELECT Name FROM sys.databases;

?????? 3: ??? ??????? ????????? ???????

?????? ?????????? ??????? ??? ???? SQL Server ????? ??? ????? ??? ??? ?????? ??????? (????????? ?? 1433) ??? ???? ??????? ?? Linux.

  1. ??? ??????:
    sudo ufw allow 1433/tcp
  2. ????? ???? ???????:
    sudo ufw enable
  3. ?????? ?? ???? ???? ???????:
    sudo ufw status

?????? 4: ????? ????? ??????????

????? ????????? ??????? ????? ?????? ????????. ???? ????? ????? ????? ????????? ????????:

  1. ????? ???? ????? ?????????:
    sudo mkdir /var/opt/mssql/backup
  2. ????? ????????:
    sudo chown mssql:mssql /var/opt/mssql/backup
  3. ????? ?? ????? ????? ?????????:
    sudo nano /usr/local/bin/backup_db.sh

    ??? ??????? ?????? ??? ???? ???????:

    #!/bin/bash
    sqlcmd -S localhost -U SA -P 'YourPassword' -Q "BACKUP DATABASE TestDB TO DISK = '/var/opt/mssql/backup/TestDB.bak'"
                
  4. ??? ???? ??????? ???? ???????:
    sudo chmod +x /usr/local/bin/backup_db.sh
  5. ????? ????? ????????? ???????? cron:
    crontab -e

    ??? ????? ?????? ?????? ??? ??????? ???? ?? ?????? 2 ??????:

    0 2 * * * /usr/local/bin/backup_db.sh

?????? 5: ????? ?????? ???????? ?????? ????????

????? ????? ?????? ???????? ???????? ?????? ????????. ??? ???? ??????? ?????? ???? ????? ????? ????????? ????? ????? ?? ????? ??????? ???????? cron.

  1. ????? ?? ????? ???????:
    sudo nano /usr/local/bin/db_maintenance.sh

    ??? ??????? ?????? ??? ???? ???????:

    #!/bin/bash
    sqlcmd -S localhost -U SA -P 'YourPassword' -Q "DBCC CHECKDB('TestDB') WITH NO_INFOMSGS, ALL_ERRORMSGS"
                
  2. ??? ???? ??????? ???? ???????:
    sudo chmod +x /usr/local/bin/db_maintenance.sh
  3. ????? ???? ??????? ???????? cron:
    crontab -e

    ??? ????? ?????? ?????? ???? ??????? ??????? ????????:

    0 3 * * 1 /usr/local/bin/db_maintenance.sh

???????

?????? ??? ??????? ???? ?? ???? ?? ????? Microsoft SQL Server ??? ???? Linux? ?????? ????? ??????? ???? ??????? ????????? ???????? ?????? ????? ?????????? ?????????? ?????? ???? ?????? ?????? ??????. ??????? ??? ??????? ?? ????? ???? SQL Server ????? ?? ?????? ????? ???? ????? ???????.

?????? ?? ????????? ???????? ??????????? ????? ?????? ??? ??????? ??????? ?? Microsoft SQL Server ??? Linux.