Instruktaż/Tutorial MSSQL w dokerze

jerry1333

void *ptr
Contributor
9 Październik 2019
626
3
317
63
Tomaszów Mazowiecki
github.com
QNAP
TS-x53Be
Ethernet
1 GbE
W tym krótkim poradniku chciałbym opisać jak zainstalować serwer MS SQL, jak przywrócić bazę z kopii oraz w jaki sposób można wykonać kopię bazy. Całość będzie działać na serwerze QNAP z procesorem x86 a do instalacji wykorzystamy kontenery dockera od Microsoftu. Postaram się pokazać jak zrobić wszystko z linii komend oraz w skróconej formie jak wyklikać to w interfejsie Portainer.

Czego będziemy potrzebować?
Instalacja z linii komend
  1. Łączymy się z serwerem QNAP przez SSH
  2. Tworzymy trzy woluminy np. o nazwach mssql-data, mssql-log oraz mssql-backup - jeden będzie przechowywał bazy danych, drugi wykorzystamy do sprawdzania logów serwera a trzeci na kopie zapasowe i do odtwarzania danych w przypadku awarii / migracji itp.
    Bash:
    docker volume create mssql-data
    docker volume create mssql-log
    docker volume create mssql-backup
    ALTERNATYWNIE:
    Możemy pominąć tworzenie woluminu mssql-backup a zamiast tego wskazać dowolny katalog na Qnapie (patrz kolejny krok).
  3. Następnie tworzymy kontener MS SQL Server (tutaj w ostatniej wersji 2017)
    Bash:
    docker run \
    --name 'mssql' \
    -e 'ACCEPT_EULA=Y' \
    -e 'MSSQL_PID=Express' \
    -e 'SA_PASSWORD=yourStrong(!)Password' \
    -v mssql-data:'/var/opt/mssql/data/' \
    -v mssql-log:'/var/opt/mssql/log' \
    -v mssql-backup:'/var/backups/' \
    -p 1433:1433 \
    -e 'MSSQL_MEMORY_LIMIT_MB=4096' \
    --memory="4096m" \
    --restart=unless-stopped \
    -d mcr.microsoft.com/mssql/server:2017-latest
    ALTERNATYWNIE:
    Mapujemy katalog /share/Public do katalogu /var/backups/ w kontenerze. Tym sposobem kopie zapasowe stworzone w katalogu /var/backups/ będą widoczne w katalogu /share/Public na Qnapie.
    Bash:
    docker run \
    --name 'mssql' \
    -e 'ACCEPT_EULA=Y' \
    -e 'MSSQL_PID=Express' \
    -e 'SA_PASSWORD=yourStrong(!)Password' \
    -v mssql-data:'/var/opt/mssql/data/' \
    -v mssql-log:'/var/opt/mssql/log' \
    -v /share/Public:'/var/backups/' \
    -p 1433:1433 \
    -e 'MSSQL_MEMORY_LIMIT_MB=4096' \
    --memory="4096m" \
    --restart=unless-stopped \
    -d mcr.microsoft.com/mssql/server:2017-latest

Opis istotnych części polecenia:
  • -e 'MSSQL_PID=Express' – jakiej edycji serwera SQL użyć - w tym przypadku Express, można podać swój klucz produktu. Domyślnie uruchamiany jest SQL Server Developer
  • -e 'SA_PASSWORD=yourStrong(!)Password' – po znaku = podajemy hasło do serwera SQL, tym hasłem będziemy się posługiwali w aplikacjach itd. Hasło powinno być trudne do odgadnięcia oraz wystarczająco długie / skomplikowane aby nie dało się go złamać metodą siłową.
  • -p 1433:1433 – port serwera (domyślny 1433), w większości aplikacji nie musimy podawać domyślnego portu połączenia.
  • -e 'MSSQL_MEMORY_LIMIT_MB=4096' --memory="4096m" – ustawiamy limit pamięci na 4096 MB - dopasowujemy tą wartość w zależności od przewidywanego obciążenia serwera (+20%) oraz możliwości QNAP-a.
Kompletny opis wszystkich zmiennych: Configure environment variables for SQL Server on Linux - SQL Server
Zmienne dockera: Docker run reference

Instalacja przez Portainer
  1. Tworzymy woluminy
    portainer-volume-create.png portainer-volume-list.png
  2. Tworzymy kontener podając te same wartości w odpowiednich polach
    portainer-create-container-1.png portainer-create-container-2.png portainer-create-container-3.png portainer-create-container-4.png portainer-create-container-5.png portainer-create-container-6.png

JAK PODŁĄCZYĆ SIĘ DO SERWERA?
W aplikacji klienckiej podajemy następujące informacje:
  • Nazwa serwera / host / adres serwera: ADRES IP QNAPA
  • Port (jeśli takie pole występuje): 1433 (lub ten który podaliśmy przy -p)
  • Użytkownik: sa
  • Hasło: hasło podane przy tworzeniu kontenera po SA_PASSWORD=
Czasami aplikacja nie ma pola na port możemy spróbować podać adres w formacie ADRES_IP:pORT np. 192.168.0.1:21433

IMPORTOWANIE / PRZYWRACANIE BAZY DANYCH
Jeśli posiadamy pliki .MDF oraz .LDF możemy spróbować podłączyć taką bazę do serwera SQL. Nie ma żadnej gwarancji, że to zadziała bo przyczyn może być wiele (niezgodne architektury serwera, nieobsługiwana wersja bazy / serwera itd.) ale jeśli nie mamy innej opcji to próbujemy :!
  1. Kopiujemy pliki bazy na wolumin mssql-data (zarówno plik MDF jak i LDF)
    db-attach-1.png
  2. Uruchamiamy SSMS i logujemy się do serwera
  3. Klikamy prawym przyciskiem na Databases i wybieramy Attach...
  4. Dodajemy plik i wskazujemy nasz plik MDF (LDF podłączy się automatycznie)
    db-attach-2.png
  5. Klikamy OK i czekamy
    db-attach-3.png
  6. Jeśli nie wystąpią błędy baza powinna pojawić się na liście i w aplikacji która ma jej używać - weryfikujemy czy zawiera dane których potrzebujemy.

Jeśli posiadamy plik .BAK/.BAC lub ogólnie plik z kopią bazy wykonaną z serwera SQL jest większa szansa na odzyskanie bazy.
  1. Kopiujemy plik kopii na wolumin mssql-backup (lub do katalogu który wskazaliśmy podczas tworzenia kontenera)
  2. Uruchamiamy SSMS i logujemy się do serwera
  3. Klikamy prawym przyciskiem na Databases i wybieramy Restore Database...
  4. Source zmieniamy na Device
    db-restore-1.png
  5. Klikamy na ... i dodajemy nasz plik .BAK/.BAC z lokalizacji /var/backups (jeśli go nie widać zmieniamy filtr na All Files (**)) i klikamy OK
    db-restore-2.png
  6. Klikamy OK i czekamy, pojawi się komunikat o zakończeniu operacji.
    db-restore-3.png
  7. Jeśli nie wystąpią błędy baza powinna pojawić się na liście i w aplikacji która ma jej używać - weryfikujemy czy zawiera dane których potrzebujemy
Linia komend:
  1. Kopiujemy plik kopii zapasowej do woluminu mssql-backup (lub do katalogu który wskazaliśmy podczas tworzenia kontenera)
  2. Logujemy się do serwera QNAP przez SSH
  3. Dostajemy się do kontenera przez polecenie:
    Bash:
    docker exec -i mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'yourStrong(!)Password'
  4. Wpisujemy polecenie odtworzenia kopii (zmieniamy nazwę bazy oraz nazwę pliku na własną)
    SQL:
    RESTORE DATABASE NAZWA_BAZY FROM DISK = '/var/backups/PLIK-KOPII.BAK'
    GO
    np.:
    SQL:
    RESTORE DATABASE CDN_FIRMA_DEMO FROM DISK = '/var/backups/CDN_FIRMA_DEMO-210101.BAK'
    GO
Dokumentacja polecenia RESTORE: RESTORE (Transact-SQL) - SQL Server

KOPIA ZAPASOWA BAZY DANYCH
Wykonać kopię bazy danych możemy na kilka sposobów. Podstawowym (ale nie zawsze bezpiecznym) będzie kopia samych plików MDF/LDF - zatrzymujemy kontener z serwerem, robimy kopię plików z woluminu mssql-data i uruchamiamy na nowo kontener.
Jednak lepszą metodą będzie zrobienie kopii bezpośrednio przez serwer bazy danych.
  1. Logujemy się do serwera QNAP przez SSH
  2. Dostajemy się do kontenera przez polecenie:
    Bash:
    docker exec -i mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'yourStrong(!)Password'
  3. Wpisujemy polecenie wykonania kopii (zmieniamy nazwę bazy na własną)
    SQL:
    BACKUP DATABASE NAZWA_BAZY TO DISK = '/var/backups/PLIK-KOPII.BAK'
    GO
    np.:
    SQL:
    BACKUP DATABASE CDN_FIRMA_DEMO TO DISK = '/var/backups/CDN_FIRMA_DEMO-210101.BAK'
    GO
  4. Tak stworzona kopia pojawi się w woluminie mssql-backup (lub w katalogu który wskazaliśmy przy tworzeniu kontenera) skąd możemy go skopiować w dowolne miejsce.
Aby zautomatyzować tworzenie kopii możemy wywoływać polecenie z crona:
Bash:
docker exec -i mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'yourStrong(!)Password' -Q "BACKUP DATABASE CDN_FIRMA_DEMO TO DISK = '/var/backups/CDN_FIRMA_DEMO.BAK'"
To polecenie wrzucamy tyle razy ile baz danych posiadamy (zmieniając nazwę bazy i pliku) lub tworzymy skrypt SQL np: Simple script to backup all SQL Server databases umieszczamy w woluminie mssql-backup i wywołujemy poleceniem:
Bash:
docker exec -i mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'yourStrong(!)Password' -i '/var/backups/backup-all.sql'

Dokumentacja polecenia BACKUP: BACKUP (Transact-SQL) - SQL Server

FAQ

P: Gdzie znajdę kopie zapasowe utworzone w Management Studio (lub z konsoli)? Na Qnapie nie mam folderu /var/backups/?!
O: Domyślnie przykład tworzy odrębny wolumin na kopie zapasowe. Aby odnaleźć ścieżkę do tego katalogu trzeba przez SSH wykonać polecenie:
Bash:
docker volume inspect mssql-backup | jq .[0].Mountpoint
W tej ścieżce znajdziesz swoje kopie.

Alternatywnym rozwiązaniem może być bezpośrednie podłączenie katalogu /var/backups/ kontenera do katalogu na Qnapie.
Podczas tworzenia kontenera należy zamienić jedną linię z
-v mssql-backup:'/var/backups/' \
na
-v /share/Public:'/var/backups/' \
Tym sposobem kopie wykonane do katalogu /var/backups/ wylądują w /share/Public na Qnapie.

P: Problemy z uruchomieniem wersji 2019 - brak możliwości połączenia z serwerem, serwer wali błędy w konsoli!
O: Najprawdopodobniej problem z prawami dostępu do katalogów. Rozwiazaniem jest dodanie praw 777 do katalogów zawierających twoje woluminy. np.:
Bash:
chmod -R 777 /share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/volumes/mssql-data
chmod -R 777 /share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/volumes/mssql-logs
chmod -R 777 /share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/volumes/mssql-backups
Dokładne ścieżki do woluminu można uzyskać poleceniem:
Bash:
docker volume inspect NAZWA_WOLUMINU | jq .[0].Mountpoint
https://forum.qnap.net.pl/threads/ts-x31k-i-docker-mssql.39858/post-177066


Jeśli macie jakieś uwagi, konstruktywną krytykę lub dodatkowe informacje warte umieszczenia piszcie, post będzie uzupełniany.
 
Strasznie kombinujesz moja uwaga odnośnie wersji miała na celu ustrzec Cię przed samoczynny aktualizacjami baz danych wystarczyło ustawić jedynie wersję po co dodajesz pozostałe parametry nie wiem.
bez najmniejszego problemu działa
Bash:
docker run \
>  --name "mssql" \
>  -e ACCEPT_EULA="Y" \
>  -e MSSQL_PID="Express" \
>  -e SA_PASSWORD="DUPA_CYCE_8" \
>  -e MSSQL_MEMORY_LIMIT_MB=4096 \
>  --memory="4096m" \
>  -v "/share/Container/MSSQL/data:/var/opt/mssql/data/" \
>  -v "/share/Container/MSSQL/log:/var/opt/mssql/log/" \
>  -v "/share/Container/MSSQL/_backup:/var/opt/mssql/_backup/" \
>  -p 1433:1433 \
>  --restart=unless-stopped \
>  mcr.microsoft.com/mssql/server:2022-latest
SQL Server 2022 will run as non-root by default.
This container is running as user mssql.
Your master database file is owned by mssql.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
2023-04-24 20:57:51.04 Server      The licensing PID was successfully processed. The new edition is [Express Edition].
2023-04-24 20:57:51.44 Server      Microsoft SQL Server 2022 (RTM-CU3) (KB5024396) - 16.0.4025.1 (X64)
        Mar 13 2023 19:10:08
        Copyright (C) 2022 Microsoft Corporation
        Express Edition (64-bit) on Linux (Ubuntu 20.04.6 LTS) <X64>
2023-04-24 20:57:51.45 Server      UTC adjustment: 0:00
2023-04-24 20:57:51.45 Server      (c) Microsoft Corporation.
2023-04-24 20:57:51.45 Server      All rights reserved.
2023-04-24 20:57:51.45 Server      Server process ID is 468.
2023-04-24 20:57:51.45 Server      Logging SQL Server messages in file '/var/opt/mssql/log/errorlog'.
2023-04-24 20:57:51.45 Server      Registry startup parameters:
         -d /var/opt/mssql/data/master.mdf
         -l /var/opt/mssql/data/mastlog.ldf
         -e /var/opt/mssql/log/errorlog
2023-04-24 20:57:51.46 Server      SQL Server detected 1 sockets with 4 cores per socket and 8 logical processors per socket, 8 total logical processors; using 8 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
2023-04-24 20:57:51.46 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2023-04-24 20:57:51.46 Server      Detected 4096 MB of RAM. This is an informational message; no user action is required.
2023-04-24 20:57:51.47 Server      Using conventional memory in the memory manager.
2023-04-24 20:57:51.47 Server      Detected pause instruction latency: 22 cycles.
2023-04-24 20:57:51.47 Server      Page exclusion bitmap is enabled.
2023-04-24 20:57:51.50 Server      Buffer pool extension is not supported on Linux platform.
2023-04-24 20:57:51.50 Server      Buffer Pool: Allocating 1048576 bytes for 562186 hashPages.
2023-04-24 20:57:51.84 Server      Buffer pool extension is already disabled. No action is necessary.
2023-04-24 20:57:52.70 Server      Installing Client TLS certificates to the store.
2023-04-24 20:57:52.71 Server      Error searching first file in /var/opt/mssql/security/ca-certificates: 3(The system cannot find the path specified.)
2023-04-24 20:57:52.72 Server      CPU vectorization level(s) detected:  SSE SSE2 SSE3 SSSE3 SSE41 SSE42 AVX AVX2 POPCNT BMI1 BMI2
2023-04-24 20:57:52.76 Server      Successfully initialized the TLS configuration. Allowed TLS protocol versions are ['1.0 1.1 1.2']. Allowed TLS ciphers are ['ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:!DHE-RSA-AES256-GCM-SHA384:!DHE-RSA-AES128-GCM-SHA256:!DHE-RSA-AES256-SHA:!DHE-RSA-AES128-SHA'].
2023-04-24 20:57:52.80 Server      Query Store settings initialized with enabled = 1,
2023-04-24 20:57:52.81 Server      The maximum number of dedicated administrator connections for this instance is '1'
2023-04-24 20:57:52.82 Server      Node configuration: node 0: CPU mask: 0x00000000000000ff:0 Active CPU mask: 0x00000000000000ff:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2023-04-24 20:57:52.83 Server      Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
2023-04-24 20:57:52.86 Server      In-Memory OLTP initialized on lowend machine.
2023-04-24 20:57:52.90 Server      [INFO] Created Extended Events session 'hkenginexesession'
2023-04-24 20:57:52.90 Server      Database Instant File Initialization: enabled. For security and performance considerations see the topic 'Database Instant File Initialization' in SQL Server Books Online. This is an informational message only. No user action is required.
ForceFlush is enabled for this instance.
2023-04-24 20:57:52.91 Server      Total Log Writer threads: 2, Node CPUs: 4, Nodes: 1, Log Writer threads per CPU: 1, Log Writer threads per Node: 2
2023-04-24 20:57:52.92 Server      clflushopt is selected for pmem flush operation.
2023-04-24 20:57:52.92 Server      Software Usage Metrics is disabled.
2023-04-24 20:57:52.93 spid26s     [1]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1. ConcurrentGAMUpdate: 1. ConcurrentSGAMUpdate: 1, CleanupUnderUserTransaction: 0. TranLevelPVS: 0
2023-04-24 20:57:52.94 spid26s     Starting up database 'master'.
2023-04-24 20:57:52.97 Server      CLR version v4.0.30319 loaded.
ForceFlush feature is enabled for log durability.
2023-04-24 20:57:53.01 spid26s     4 transactions rolled forward in database 'master' (1:0). This is an informational message only. No user action is required.
2023-04-24 20:57:53.02 spid26s     0 transactions rolled back in database 'master' (1:0). This is an informational message only. No user action is required.
2023-04-24 20:57:53.04 spid26s     Recovery is writing a checkpoint in database 'master' (1). This is an informational message only. No user action is required.
2023-04-24 20:57:53.18 spid26s     Service Master Key could not be decrypted using one of its encryptions. See sys.key_encryptions for details.
2023-04-24 20:57:53.18 spid26s     An error occurred during Service Master Key initialization. SQLErrorCode=33095, State=14, LastOsError=2.
2023-04-24 20:57:53.20 spid26s     SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2023-04-24 20:57:53.20 spid34s     External governance manager initialized
2023-04-24 20:57:53.21 spid26s     SQL Server Audit has started the audits. This is an informational message. No user action is required.
2023-04-24 20:57:53.21 spid34s     Attribute synchronization manager initialized
2023-04-24 20:57:53.22 spid26s     XE session 'system_health' started.
2023-04-24 20:57:53.27 spid26s     SQL Trace ID 1 was started by login "sa".
2023-04-24 20:57:53.28 spid26s     Server name is '3ffbb6708653'. This is an informational message only. No user action is required.
2023-04-24 20:57:53.33 spid41s     Always On: The availability replica manager is starting. This is an informational message only. No user action is required.
2023-04-24 20:57:53.34 spid26s     [4]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1. ConcurrentGAMUpdate: 1. ConcurrentSGAMUpdate: 1, CleanupUnderUserTransaction: 0. TranLevelPVS: 0
2023-04-24 20:57:53.34 spid41s     Always On: The availability replica manager is waiting for the instance of SQL Server to allow client connections. This is an informational message only. No user action is required.
2023-04-24 20:57:53.35 spid29s     [32767]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1. ConcurrentGAMUpdate: 1. ConcurrentSGAMUpdate: 1, CleanupUnderUserTransaction: 0. TranLevelPVS: 0
2023-04-24 20:57:53.37 spid26s     Starting up database 'msdb'.
2023-04-24 20:57:53.39 spid29s     Starting up database 'mssqlsystemresource'.
2023-04-24 20:57:53.40 spid29s     The resource database build version is 16.00.4025. This is an informational message only. No user action is required.
2023-04-24 20:57:53.45 spid29s     [3]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1. ConcurrentGAMUpdate: 1. ConcurrentSGAMUpdate: 1, CleanupUnderUserTransaction: 0. TranLevelPVS: 0
2023-04-24 20:57:53.47 spid29s     Starting up database 'model'.
2023-04-24 20:57:53.47 spid26s     1 transactions rolled forward in database 'msdb' (4:0). This is an informational message only. No user action is required.
2023-04-24 20:57:53.49 spid26s     0 transactions rolled back in database 'msdb' (4:0). This is an informational message only. No user action is required.
2023-04-24 20:57:53.62 spid29s     Clearing tempdb database.
2023-04-24 20:57:53.72 Server      Common language runtime (CLR) functionality initialized.
2023-04-24 20:57:53.80 spid29s     [2]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1. ConcurrentGAMUpdate: 1. ConcurrentSGAMUpdate: 1, CleanupUnderUserTransaction: 0. TranLevelPVS: 0
2023-04-24 20:57:53.81 spid29s     Starting up database 'tempdb'.
2023-04-24 20:57:53.90 spid45s     The Service Broker endpoint is in disabled or stopped state.
2023-04-24 20:57:53.90 spid45s     The Database Mirroring endpoint is in disabled or stopped state.
2023-04-24 20:57:53.91 spid45s     Service Broker manager has started.
2023-04-24 20:57:53.98 spid40s     A self-generated certificate was successfully loaded for encryption.
2023-04-24 20:57:53.98 spid40s     Server is listening on [ 'any' <ipv6> 1433] accept sockets 1.
2023-04-24 20:57:53.99 spid40s     Server is listening on [ 'any' <ipv4> 1433] accept sockets 1.
2023-04-24 20:57:54.00 spid40s     Dedicated administrator connection support was not started because it is disabled on this edition of SQL Server. If you want to use a dedicated administrator connection, restart SQL Server using the trace flag 7806. This is an informational message only. No user action is required.
2023-04-24 20:57:54.01 spid40s     Server is listening on [ ::1 <ipv6> 1431] accept sockets 1.
2023-04-24 20:57:54.01 spid40s     Server is listening on [ 127.0.0.1 <ipv4> 1431] accept sockets 1.
2023-04-24 20:57:54.01 spid40s     Recovery is complete. This is an informational message only. No user action is required.
2023-04-24 20:57:54.02 spid40s     SQL Server is now ready for client connections. This is an informational message; no user action is required.



Kod:
docker run \
 --name "mssql" \
 -e ACCEPT_EULA="Y" \
 -e MSSQL_PID="Express" \
 -e SA_PASSWORD="DUPA.8_DUPA.9" \
 -e MSSQL_MEMORY_LIMIT_MB=4096 \
 --memory="4096m" \
 -v "/share/Container/MSSQL/data:/var/opt/mssql/data/" \
 -v "/share/Container/MSSQL/log:/var/opt/mssql/log/" \
 -v "/share/Container/MSSQL/_backup:/var/opt/mssql/_backup/" \
 -p 1433:1433 \
 --restart=unless-stopped \
 mcr.microsoft.com/mssql/server:2022-latest
Interesuje cię tylko ścieżka /share/Container/MSSQL/ powinieneś swtorzyć to według własnego uznania na nasie oraz ustawić hasło wsio.
 
Strasznie kombinujesz moja uwaga odnośnie wersji miała na celu ustrzec Cię przed samoczynny aktualizacjami baz danych wystarczyło ustawić jedynie wersję po co dodajesz pozostałe parametry nie wiem.
bez najmniejszego problemu działa
Bash:
docker run \
>  --name "mssql" \
>  -e ACCEPT_EULA="Y" \
>  -e MSSQL_PID="Express" \
>  -e SA_PASSWORD="DUPA_CYCE_8" \
>  -e MSSQL_MEMORY_LIMIT_MB=4096 \
>  --memory="4096m" \
>  -v "/share/Container/MSSQL/data:/var/opt/mssql/data/" \
>  -v "/share/Container/MSSQL/log:/var/opt/mssql/log/" \
>  -v "/share/Container/MSSQL/_backup:/var/opt/mssql/_backup/" \
>  -p 1433:1433 \
>  --restart=unless-stopped \
>  mcr.microsoft.com/mssql/server:2022-latest
SQL Server 2022 will run as non-root by default.
This container is running as user mssql.
Your master database file is owned by mssql.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
2023-04-24 20:57:51.04 Server      The licensing PID was successfully processed. The new edition is [Express Edition].
2023-04-24 20:57:51.44 Server      Microsoft SQL Server 2022 (RTM-CU3) (KB5024396) - 16.0.4025.1 (X64)
        Mar 13 2023 19:10:08
        Copyright (C) 2022 Microsoft Corporation
        Express Edition (64-bit) on Linux (Ubuntu 20.04.6 LTS) <X64>
2023-04-24 20:57:51.45 Server      UTC adjustment: 0:00
2023-04-24 20:57:51.45 Server      (c) Microsoft Corporation.
2023-04-24 20:57:51.45 Server      All rights reserved.
2023-04-24 20:57:51.45 Server      Server process ID is 468.
2023-04-24 20:57:51.45 Server      Logging SQL Server messages in file '/var/opt/mssql/log/errorlog'.
2023-04-24 20:57:51.45 Server      Registry startup parameters:
         -d /var/opt/mssql/data/master.mdf
         -l /var/opt/mssql/data/mastlog.ldf
         -e /var/opt/mssql/log/errorlog
2023-04-24 20:57:51.46 Server      SQL Server detected 1 sockets with 4 cores per socket and 8 logical processors per socket, 8 total logical processors; using 8 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
2023-04-24 20:57:51.46 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2023-04-24 20:57:51.46 Server      Detected 4096 MB of RAM. This is an informational message; no user action is required.
2023-04-24 20:57:51.47 Server      Using conventional memory in the memory manager.
2023-04-24 20:57:51.47 Server      Detected pause instruction latency: 22 cycles.
2023-04-24 20:57:51.47 Server      Page exclusion bitmap is enabled.
2023-04-24 20:57:51.50 Server      Buffer pool extension is not supported on Linux platform.
2023-04-24 20:57:51.50 Server      Buffer Pool: Allocating 1048576 bytes for 562186 hashPages.
2023-04-24 20:57:51.84 Server      Buffer pool extension is already disabled. No action is necessary.
2023-04-24 20:57:52.70 Server      Installing Client TLS certificates to the store.
2023-04-24 20:57:52.71 Server      Error searching first file in /var/opt/mssql/security/ca-certificates: 3(The system cannot find the path specified.)
2023-04-24 20:57:52.72 Server      CPU vectorization level(s) detected:  SSE SSE2 SSE3 SSSE3 SSE41 SSE42 AVX AVX2 POPCNT BMI1 BMI2
2023-04-24 20:57:52.76 Server      Successfully initialized the TLS configuration. Allowed TLS protocol versions are ['1.0 1.1 1.2']. Allowed TLS ciphers are ['ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:!DHE-RSA-AES256-GCM-SHA384:!DHE-RSA-AES128-GCM-SHA256:!DHE-RSA-AES256-SHA:!DHE-RSA-AES128-SHA'].
2023-04-24 20:57:52.80 Server      Query Store settings initialized with enabled = 1,
2023-04-24 20:57:52.81 Server      The maximum number of dedicated administrator connections for this instance is '1'
2023-04-24 20:57:52.82 Server      Node configuration: node 0: CPU mask: 0x00000000000000ff:0 Active CPU mask: 0x00000000000000ff:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2023-04-24 20:57:52.83 Server      Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
2023-04-24 20:57:52.86 Server      In-Memory OLTP initialized on lowend machine.
2023-04-24 20:57:52.90 Server      [INFO] Created Extended Events session 'hkenginexesession'
2023-04-24 20:57:52.90 Server      Database Instant File Initialization: enabled. For security and performance considerations see the topic 'Database Instant File Initialization' in SQL Server Books Online. This is an informational message only. No user action is required.
ForceFlush is enabled for this instance.
2023-04-24 20:57:52.91 Server      Total Log Writer threads: 2, Node CPUs: 4, Nodes: 1, Log Writer threads per CPU: 1, Log Writer threads per Node: 2
2023-04-24 20:57:52.92 Server      clflushopt is selected for pmem flush operation.
2023-04-24 20:57:52.92 Server      Software Usage Metrics is disabled.
2023-04-24 20:57:52.93 spid26s     [1]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1. ConcurrentGAMUpdate: 1. ConcurrentSGAMUpdate: 1, CleanupUnderUserTransaction: 0. TranLevelPVS: 0
2023-04-24 20:57:52.94 spid26s     Starting up database 'master'.
2023-04-24 20:57:52.97 Server      CLR version v4.0.30319 loaded.
ForceFlush feature is enabled for log durability.
2023-04-24 20:57:53.01 spid26s     4 transactions rolled forward in database 'master' (1:0). This is an informational message only. No user action is required.
2023-04-24 20:57:53.02 spid26s     0 transactions rolled back in database 'master' (1:0). This is an informational message only. No user action is required.
2023-04-24 20:57:53.04 spid26s     Recovery is writing a checkpoint in database 'master' (1). This is an informational message only. No user action is required.
2023-04-24 20:57:53.18 spid26s     Service Master Key could not be decrypted using one of its encryptions. See sys.key_encryptions for details.
2023-04-24 20:57:53.18 spid26s     An error occurred during Service Master Key initialization. SQLErrorCode=33095, State=14, LastOsError=2.
2023-04-24 20:57:53.20 spid26s     SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2023-04-24 20:57:53.20 spid34s     External governance manager initialized
2023-04-24 20:57:53.21 spid26s     SQL Server Audit has started the audits. This is an informational message. No user action is required.
2023-04-24 20:57:53.21 spid34s     Attribute synchronization manager initialized
2023-04-24 20:57:53.22 spid26s     XE session 'system_health' started.
2023-04-24 20:57:53.27 spid26s     SQL Trace ID 1 was started by login "sa".
2023-04-24 20:57:53.28 spid26s     Server name is '3ffbb6708653'. This is an informational message only. No user action is required.
2023-04-24 20:57:53.33 spid41s     Always On: The availability replica manager is starting. This is an informational message only. No user action is required.
2023-04-24 20:57:53.34 spid26s     [4]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1. ConcurrentGAMUpdate: 1. ConcurrentSGAMUpdate: 1, CleanupUnderUserTransaction: 0. TranLevelPVS: 0
2023-04-24 20:57:53.34 spid41s     Always On: The availability replica manager is waiting for the instance of SQL Server to allow client connections. This is an informational message only. No user action is required.
2023-04-24 20:57:53.35 spid29s     [32767]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1. ConcurrentGAMUpdate: 1. ConcurrentSGAMUpdate: 1, CleanupUnderUserTransaction: 0. TranLevelPVS: 0
2023-04-24 20:57:53.37 spid26s     Starting up database 'msdb'.
2023-04-24 20:57:53.39 spid29s     Starting up database 'mssqlsystemresource'.
2023-04-24 20:57:53.40 spid29s     The resource database build version is 16.00.4025. This is an informational message only. No user action is required.
2023-04-24 20:57:53.45 spid29s     [3]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1. ConcurrentGAMUpdate: 1. ConcurrentSGAMUpdate: 1, CleanupUnderUserTransaction: 0. TranLevelPVS: 0
2023-04-24 20:57:53.47 spid29s     Starting up database 'model'.
2023-04-24 20:57:53.47 spid26s     1 transactions rolled forward in database 'msdb' (4:0). This is an informational message only. No user action is required.
2023-04-24 20:57:53.49 spid26s     0 transactions rolled back in database 'msdb' (4:0). This is an informational message only. No user action is required.
2023-04-24 20:57:53.62 spid29s     Clearing tempdb database.
2023-04-24 20:57:53.72 Server      Common language runtime (CLR) functionality initialized.
2023-04-24 20:57:53.80 spid29s     [2]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1. ConcurrentGAMUpdate: 1. ConcurrentSGAMUpdate: 1, CleanupUnderUserTransaction: 0. TranLevelPVS: 0
2023-04-24 20:57:53.81 spid29s     Starting up database 'tempdb'.
2023-04-24 20:57:53.90 spid45s     The Service Broker endpoint is in disabled or stopped state.
2023-04-24 20:57:53.90 spid45s     The Database Mirroring endpoint is in disabled or stopped state.
2023-04-24 20:57:53.91 spid45s     Service Broker manager has started.
2023-04-24 20:57:53.98 spid40s     A self-generated certificate was successfully loaded for encryption.
2023-04-24 20:57:53.98 spid40s     Server is listening on [ 'any' <ipv6> 1433] accept sockets 1.
2023-04-24 20:57:53.99 spid40s     Server is listening on [ 'any' <ipv4> 1433] accept sockets 1.
2023-04-24 20:57:54.00 spid40s     Dedicated administrator connection support was not started because it is disabled on this edition of SQL Server. If you want to use a dedicated administrator connection, restart SQL Server using the trace flag 7806. This is an informational message only. No user action is required.
2023-04-24 20:57:54.01 spid40s     Server is listening on [ ::1 <ipv6> 1431] accept sockets 1.
2023-04-24 20:57:54.01 spid40s     Server is listening on [ 127.0.0.1 <ipv4> 1431] accept sockets 1.
2023-04-24 20:57:54.01 spid40s     Recovery is complete. This is an informational message only. No user action is required.
2023-04-24 20:57:54.02 spid40s     SQL Server is now ready for client connections. This is an informational message; no user action is required.



Kod:
docker run \
 --name "mssql" \
 -e ACCEPT_EULA="Y" \
 -e MSSQL_PID="Express" \
 -e SA_PASSWORD="DUPA.8_DUPA.9" \
 -e MSSQL_MEMORY_LIMIT_MB=4096 \
 --memory="4096m" \
 -v "/share/Container/MSSQL/data:/var/opt/mssql/data/" \
 -v "/share/Container/MSSQL/log:/var/opt/mssql/log/" \
 -v "/share/Container/MSSQL/_backup:/var/opt/mssql/_backup/" \
 -p 1433:1433 \
 --restart=unless-stopped \
 mcr.microsoft.com/mssql/server:2022-latest
Interesuje cię tylko ścieżka /share/Container/MSSQL/ powinieneś swtorzyć to według własnego uznania na nasie oraz ustawić hasło wsio.
Nie kombinuje, tylko Kopia 1 do 1 skrypu wyżej, u mnie wygląda tak:
Bash:
docker run \
> --name "mssql" \
> -e ACCEPT_EULA="Y" \
> -e MSSQL_PID="Express" \mssql/server:2022-memory="4096m" > --restart=unless-stolly
> -e SA_PASSWORD="DUPA_CYCE_8" \
> -e MSSQL_MEMORY_LIMIT_MB=4096 \ manifest unknown: manifest tagged by "2022" is
> --memory="4096m" \
> -v "/share/Container/MSSQL/data:/var/opt/mssql/data/" \
> -v "/share/Container/MSSQL/log:/var/opt/mssql/log/" \
> -v "/share/Container/MSSQL/_backup:/var/opt/mssql/_backup/" \
> -p 1433:1433 \
> --restart=unless-stopped \
> mcr.microsoft.com/mssql/server:2022-latest
Unable to find image 'mcr.microsoft.com/mssql/server:2022-latest' locally
2022-latest: Pulling from mssql/server
6e66059d3f09: Pull complete
72f7cb869583: Pull complete
7947fa790a24: Pull complete
Digest: sha256:4f81d897a7373459d694c44fdd43f18ab30b762b177a4b9e6a2ca0e7406ca342
Status: Downloaded newer image for mcr.microsoft.com/mssql/server:2022-latest
SQL Server 2022 will run as non-root by default.
This container is running as user mssql.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
2023-04-24 21:08:09.76 Server      The licensing PID was successfully processed. The new edition is [Express Edition].
2023-04-24 21:08:10.02 Server      Setup step is copying system data file 'C:\templatedata\master.mdf' to '/var/opt/mssql/data/master.mdf'.
2023-04-24 21:08:10.03 Server      ERROR: Setup FAIELED copying system data file 'C:\templatedata\master.mdf' to '/var/opt/mssql/data/master.mdf':  5(Access is denied.)
RROR: BootstrapSystemDataDirectories() failure (HRESULT 0x80070005)
 
Nie kombinuje, tylko Kopia 1 do 1 skrypu wyżej, u mnie wygląda tak:
Bash:
docker run \
> --name "mssql" \
> -e ACCEPT_EULA="Y" \
> -e MSSQL_PID="Express" \mssql/server:2022-memory="4096m" > --restart=unless-stolly
> -e SA_PASSWORD="DUPA_CYCE_8" \
> -e MSSQL_MEMORY_LIMIT_MB=4096 \ manifest unknown: manifest tagged by "2022" is
> --memory="4096m" \
> -v "/share/Container/MSSQL/data:/var/opt/mssql/data/" \
> -v "/share/Container/MSSQL/log:/var/opt/mssql/log/" \
> -v "/share/Container/MSSQL/_backup:/var/opt/mssql/_backup/" \
> -p 1433:1433 \
> --restart=unless-stopped \
> mcr.microsoft.com/mssql/server:2022-latest
Unable to find image 'mcr.microsoft.com/mssql/server:2022-latest' locally
2022-latest: Pulling from mssql/server
6e66059d3f09: Pull complete
72f7cb869583: Pull complete
7947fa790a24: Pull complete
Digest: sha256:4f81d897a7373459d694c44fdd43f18ab30b762b177a4b9e6a2ca0e7406ca342
Status: Downloaded newer image for mcr.microsoft.com/mssql/server:2022-latest
SQL Server 2022 will run as non-root by default.
This container is running as user mssql.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
2023-04-24 21:08:09.76 Server      The licensing PID was successfully processed. The new edition is [Express Edition].
2023-04-24 21:08:10.02 Server      Setup step is copying system data file 'C:\templatedata\master.mdf' to '/var/opt/mssql/data/master.mdf'.
2023-04-24 21:08:10.03 Server      ERROR: Setup FAIELED copying system data file 'C:\templatedata\master.mdf' to '/var/opt/mssql/data/master.mdf':  5(Access is denied.)
RROR: BootstrapSystemDataDirectories() failure (HRESULT 0x80070005)

Dobra pytanie z innej beczki? Do czego potrzebujesz tej bazy danych?

/share/Container/MSSQL/

To jest ścieżka katalogów którą ja u siebie na nasie stworzyłem tam będą zapisywane pliki bazy danych. To powinieneś zmienić na swoje ścieżki na swoim nasie katalogi stworzyć przed uruchomieniem czyli tworzy gdzies katalog MSSQL i wnim następujęce data log i backup.
 
Hi. Mały program księgowy. Ogólnie wszystko już ok, i bardzo dziękuję za dotychczasową pomoc, ale mam problem. Nie wiem czy to nie temat na kolejny wątek. ten program księgowy jest o tyle dziwny że tworzy dla każdego klienta osobną baze danych i do tego z każdego roku, więc jest z 120 .MDF, tudzież .bak-ów. Sprawdzałem z 20 skryptów na SMSS aby przywrócić te pliki do instancji, ale żadne nie działa. Z poziomu programu muszę podać ścieżkę względna, co stanowi problem przywróceniem. Macie jakiś pomysł, nie za bardzo chcę przewracać każdą bazę po kolei . 😞
 
Sprawdzałem z 20 skryptów na SMSS aby przywrócić te pliki do instancji
ale czemu to jest problemem ?
wrzucasz BAKi do folderu dla kopii zapasowej i każesz SQLowi przywrócić bazy.

Konfigurujesz jedno przywrócenie i pobierasz skrypt do tego (obok guzika HELP masz SCRIPT)

1682424890082.png


Oglądasz sobie ten skrypt i patrzysz co się zmieni , nazwa pliku BAK, nazwa bazy danych etc.
potem powielasz to dla plików i tyle w temacie .. na pewno jest do tego schemat!
 
No własnie, tym sposobem ok, ale tych plików jest 120 🥲 różnią sie w sumie tylko nr ewidencji, i rokiem np:
PVKsiegi_EWIDENCJA001_2016_20230424.bak
PVKsiegi_EWIDENCJA001_2017_20230424.bak
PVKsiegi_EWIDENCJA001_2018_20230424.bak
PVKsiegi_EWIDENCJA001_2019_20230424.bak
PVKsiegi_EWIDENCJA002_2013_20230424.bak

próbowałem
Kod:
USE master
GO
 
CREATE PROCEDURE [dbo].[usp_MultiAttachSingleMDFFiles] ( @mdfTempDir nvarchar(500) )
AS
BEGIN 
   DECLARE @dirstmt       nvarchar(1000)
   DECLARE @currFile      nvarchar(160)
   DECLARE @db_name       nvarchar(256)
   DECLARE @phys_name     nvarchar(520)
   DECLARE @dbccstmt      nvarchar(1000)
   DECLARE @db2attch_ver  INT
   DECLARE @curr_srv_ver  INT 
   DECLARE @mdfFileNames  TABLE (mdfFile nvarchar(260))
   DECLARE @mdfFileATTR   TABLE (attrName sql_variant, attrValue sql_variant)
  
   DECLARE cf CURSOR FOR SELECT mdfFile FROM @mdfFileNames

   SET NOCOUNT ON

   -- get all mdf file names only , in bare format.
   SET @dirstmt = 'dir /b "' + @mdfTempDir + '"\*.mdf'

   INSERT into @mdfFileNames
   EXEC xp_cmdshell @dirstmt
  
   DELETE from @mdfFileNames where mdfFile IS NULL or mdfFile = 'File Not Found'

   -- if file is already attached skip it
   DELETE FROM @mdfFileNames
   WHERE mdfFile IN (SELECT mdfFile FROM @mdfFileNames a INNER JOIN sys.master_files b ON lower(@mdfTempDir + '\' + a.mdfFile) = lower(b.physical_name) )

   -- if no files exist then exit process
   IF not exists (SELECT TOP 1 * FROM @mdfFileNames)
   BEGIN
      PRINT 'No files found to process'
      RETURN
   END

   -- get the current server database version
   SELECT  @curr_srv_ver = CONVERT (int,DATABASEPROPERTYEX('master', 'version'))

   BEGIN TRY

      OPEN cf

      FETCH NEXT FROM cf INTO @currFile

      WHILE @@FETCH_STATUS = 0
      BEGIN
 
         SET @phys_name =  @mdfTempDir + '\' + @currFile
         SET @dbccstmt = 'DBCC checkprimaryfile (' + '"' + @phys_name + '"' + ',2)'

         INSERT INTO @mdfFileATTR
         EXEC (@dbccstmt)
        
         SELECT @db_name = convert (nvarchar(256), attrValue)
         FROM @mdfFileATTR
         WHERE attrName = 'Database name'
      
         -- get the candidate to be attached db version
         SELECT @db2attch_ver = convert (int, attrValue)
         FROM @mdfFileATTR
         WHERE attrName = 'Database version'

         -- if the current server database version is less that the attached db version
         -- OR
         -- if the database already exists then skip the attach
         -- print an appropriate message message
         IF (@db2attch_ver > @curr_srv_ver)
            OR
            (exists (SELECT 1
                     FROM sys.databases d
                     WHERE RTRIM(LTRIM(lower(d.name))) = RTRIM(LTRIM(lower(@db_name)))))
         BEGIN
            PRINT ''
            PRINT ' Attach for database ' + @db_name + ' was not performed! '
            PRINT ' Possible reasons : '
            PRINT '1. ' +  @db_name + ' DB version is higher that the currnet server version.'
            PRINT '2. ' +  @db_name + ' DB already exists on server.'
            PRINT ''
         END
         ELSE
         BEGIN
            EXEC sp_attach_single_file_db @dbname= @db_name , @physname = @phys_name
            PRINT ''
            PRINT 'Database "' + @db_name + '" attached to server OK using file ' + @currFile + '".'
            PRINT ''
            DELETE FROM @mdfFileATTR
         END

         FETCH NEXT FROM cf INTO @currFile

      END
    
      CLOSE cf
      DEALLOCATE cf
   END TRY
   BEGIN CATCH
      PRINT 'Error while attaching FILE ' + @phys_name + ',...Exiting procedure'
      CLOSE cf
      DEALLOCATE cf
   END CATCH

   SET NOCOUNT OFF
END
GO

znalezione na
Script to attach multiple SQL Server MDF files
 
Oglądasz sobie ten skrypt i patrzysz co się zmieni , nazwa pliku BAK, nazwa bazy danych etc.
potem powielasz to dla plików i tyle w temacie .. na pewno jest do tego schemat!
pliki BAK to KOPIA bazy danych - nie goła baza
podałem ci sposób , popatrz na to .. to nie BOLI !
"Powielasz" 120 razy (y) Spoko. Jeśli "BOLI" Cie odpisywanie, to po co to robisz? Dzięki za pomoc i doceniam Twoją wiedzę, ale sądzę że mozna inaczej.
Forum jest po to aby zadawać pytania, i dzielić sie właśnie tę wiedzą.
 
@DeNiro "Forum jest po to aby zadawać pytania, i dzielić się właśnie tę wiedzą."

Ja inaczej to widzę i zwykle stosuję to również w życiu zawodowym nawet szkoląc nowych pracowników pierwszy raz wskaże kierunek w który powinien podążać potem pomogę... ale jak za często albo w kółko to samo to ja to pie***le mamy internet nawet książki nie trzeba wertować aby rozwiązanie wygooglować ;)
 
  • Lubię to
Reakcje: DeNiro
Hi. Bazy chodzą bez problemy, niestety pojawia się problem z wydajnością, i to chyba od niedawana (wcześniej nie zgłaszali). W logach znalazłem cos takiego:

Starting up database 'PPPRRS_2024'.
2024-02-01 23:29:33.18 spid56 RemoveStaleDbEntries: Cleanup of stale DB entries called for database ID: [265]
2024-02-01 23:29:33.18 spid56 RemoveStaleDbEntries: Cleanup of stale DB entries skipped because master db is not memory optimized. DbId: 265.
2024-02-01 23:29:33.24 spid56 Parallel redo is started for database 'PPPRRS_2024' with worker pool size [2].
2024-02-01 23:29:33.28 spid56 Parallel redo is shutdown for database 'PPPRRS_2024' with worker pool size [2].
RecoveryUnit::Shutdown. IsOnline: 02024-02-01 23:29:33.95 spid29s RBPEX::NotifyFileShutdown: Called for database ID: [265], file Id [0]
2024-02-01 23:29:34.28 spid56 [265]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1. ConcurrentGAMUpdate: 1. ConcurrentSGAMUpdate: 1, CleanupUnderUserTransaction: 0. TranLevelPVS: 0

a podczas wykonywania na nich najbardziej wymagających operacji, obciążenie nie jest nawet na średnim poziomie.

Czy ktoś może coś podpowiedzieć, wygląda na to że serwer nawet w połowie nie wykorzystuje swoich zasobów (załacznik).
 

Załączniki

  • Zrzut ekranu 2024-02-02 012919.png
    Zrzut ekranu 2024-02-02 012919.png
    533,7 KB · Wyświetleń: 14
a podczas wykonywania na nich najbardziej wymagających operacji, obciążenie nie jest nawet na średnim poziomie.

Nie jestem pewien czy Ty pytasz czy stwierdzasz, jak duża jest ta baza danych i co to za wymagające operacje może.
- wielokrotnie zagnieżdżone "JOIN"y bywają wolne -> zoptymalizuje te zapytania
- bazy SQL nie są dobre jako "storage" dla palików binarnych -> zmień repozytorium
- ilu użytkowników jest podłączonych -> zwiększyć pulę "connect"ionów
 
Hi. Dzięki za zainteresowanie.
Tutaj tez jest kilka baz, z 40, ale używane są może ze 3 równocześnie. Średnia ich wielkość to ok 70 MB ale a dwie największe to ok 150--200 MB.
- operacje nie są jakieś wymagające (podliczenie roku - ewidencja), bardziej chodzi o to że tutaj najdłużej widać równice z przed przesiadki
- ok spróbuję
- maks. 3 w jednym czasie
 
Wiem, znajdź sobie klienta który pozwala profilować zapytania albo sprawdź jak się benchmarkuje zapytania w samym Ms Sql serwerze bo i takie metody są.
Masz wersje express/developer sprawdź jak wygląda optymalna konfiguracja dla nich. Wystarczy w googlu wpisać komunikat które tu wkleiłeś aby w pierwszych 3 zwracanych krotkach sprawdzić co oznaczają i co zrobić.

Bynajmniej nie jest to problem qnapa tylko twojej architektury i raczej bym szukał odpowiedzi na forach baz danych powodzenia w optymalizacji czegoś tam. A to wszystko w kontekście kolegi który kilka postów wcześniej już wywróżył jak to się potoczy.
 
  • Flexed Biceps
Reakcje: SiewcaRyżu

Mogą Cię zainteresować

Użytkownicy znaleźli tą stronę używając tych słów:

  1. mssql
  2. non-root
  3. MSSQL_PID="Express" \
  4. mssql w dokerze\
  5. brak dostępu do qnapa
  6. portainer instalacja
  7. MSSQL W DOKERZE
  8. error 102
  9. sql server
  10. *
  11. jak zainstalować PDO mssql
  12. Failed to access the file.
  13. repozytorium
  14. docker status
  15. NAS instalacja Kontenera MSSQL