четверг, 26 сентября 2024 г.

Clearing NPS-LOG database

 use [NPS-LOG]

go

 

----------------------------------------------

declare @logs_period int = 31

-- how many days should be saved in database

----------------------------------------------

 

declare @mindate datetime

declare @period_to_delete int

DECLARE @i int = 0

declare @deletion_point date

 

set @mindate = (SELECT TOP (1) timestamp FROM [NPS-LOG].[dbo].[accounting_data] order by timestamp asc)

print cast(@mindate as date)

 

set @period_to_delete =  datediff(d, @mindate,  GETDATE()) - @logs_period

print @period_to_delete

 

WHILE @i < @period_to_delete

BEGIN

    set @deletion_point = dateadd(d, @i, @mindate)

    print @deletion_point

    delete from [NPS-LOG].[dbo].[accounting_data] where  [timestamp] < @deletion_point

    checkpoint

    dbcc shrinkfile('NPS-LOG_log')

    SET @i = @i + 1

END

checkpoint

dbcc shrinkfile ('NPS-LOG', 16, NOTRUNCATE)

checkpoint

dbcc shrinkfile ('NPS-LOG', TRUNCATEONLY)

понедельник, 24 июня 2024 г.

SQL memory usage

 SELECT object_name, counter_name, cntr_value/1024/1024 AS 'Total Server Memory (KB)'

FROM sys.dm_os_performance_counters

WHERE counter_name = 'Total Server Memory (KB)'


SELECT (physical_memory_in_use_kb / 1024) AS CurrentlyUsedMemorybySQLServer

    ,(locked_page_allocations_kb / 1024) AS Locked_pages_used_Sqlserver_MB

    ,(total_virtual_address_space_kb / 1024) AS Total_VAS_in_MB

    ,process_physical_memory_low

    ,process_virtual_memory_low

FROM sys.dm_os_process_memory;

понедельник, 15 апреля 2024 г.

Shrink Log files

 declare @dbn varchar(max), @dbf varchar(max), @cmd varchar(max)

declare  CURS cursor for

SELECT 

    db.name AS [Database Name], 

    mf.name AS [Logical Name] 

FROM 

     sys.master_files AS mf

     INNER JOIN sys.databases AS db ON

            db.database_id = mf.database_id

where mf.type_desc = 'LOG' and db.database_id > 4;


open CURS;

FETCH NEXT FROM curs INTO @dbn, @dbf


WHILE @@FETCH_STATUS = 0

BEGIN

--print @dbn; print @dbf

select @cmd=''

select @cmd = 'use ['+@dbn+']; ALTER DATABASE ['+@dbn+'] MODIFY FILE (NAME = '''+@dbf+''', SIZE = 64, FILEGROWTH = 16MB); DBCC SHRINKFILE('''+@dbf+''',64);';

--print @cmd;

exec (@cmd);

FETCH NEXT FROM curs INTO @dbn, @dbf

end 

close CURS;

deallocate CURS;

SQL replication monitoring

 --SELECT * FROM [distribution].dbo.MSReplication_monitordata WHERE status not in(1,2,3,4)


SELECT * FROM [distribution].dbo.MSReplication_monitordata 

where not( agent_type=1 and status=2)

and not(agent_type = 2 and status=3)


3--2 - error



/*

agent_type

1 = Snapshot Agent

2 = Log Reader Agent

3 = Distribution Agent

4 = Merge Agent

9 = Queue Reader Agent


status

1 = Started

2 = Succeeded

3 = In progress

4 = Idle

5 = Retrying

6 = Failed

*/

-- 1 = Snapshot Agent / 2 = Succeeded

SELECT * FROM [distribution].dbo.MSReplication_monitordata where agent_type=1 and status<>2 

-- 2 = Log Reader Agent / 3 = In progress

SELECT * FROM [distribution].dbo.MSReplication_monitordata where agent_type=2 and status <>3

-- 3 = Distribution Agent / 3 = In progress, 4 = Idle 

SELECT * FROM [distribution].dbo.MSReplication_monitordata where agent_type=3 and (status <>3 or status <>4)



SELECT count(1) FROM [distribution].dbo.MSReplication_monitordata 

where 

(agent_type=1 and status<>2)

or (agent_type=2 and status <>3)

or (agent_type=3 and (status <>3 and status <>4) )


SELECT * FROM [distribution].dbo.MSReplication_monitordata 

понедельник, 12 февраля 2024 г.

Re-register VSS Writers for Server 2012-2016

 

  1. Create a batch file by:
    1. Copy the following list:
      • net stop vss
      • net stop swprv
      • regsvr32 /s ole32.dll
      • regsvr32 /s oleaut32.dll
      • regsvr32 /s vss_ps.dll
      • vssvc /register
      • regsvr32 /s /i swprv.dll
      • regsvr32 /s /i eventcls.dll
      • regsvr32 /s es.dll
      • regsvr32 /s stdprov.dll
      • regsvr32 /s vssui.dll
      • regsvr32 /s msxml.dll
      • regsvr32 /s msxml3.dll
      • regsvr32 /s msxml4.dll
      • vssvc /register
      • net start swprv
      • net start vss
    2. Open a blank text file
    3. Paste the copied list
    4. Save As fixvss.bat to an easily accessible location like the desktop of the workstation
  2. Right-click batch file > Run as administrator
  3. Immediately reboot device

пятница, 26 января 2024 г.

SureBackup NAS mounts

 восстановление работы SureBackup Testlab

  An error occurred during host configuration. 192.168.88.6: Fault "PlatformConfigFaultFault", detail "Operation failed, diagnostics report: Unable to get console path for volume, VeeamBackup_TS-FS01"  
[24.08.2023 12:38:19] <10> Error         An error occurred during host configuration. . Failed to mount NFS volume (192.168.88.6:/VeeamBackup_TS-FS01). 192.168.88.6: Fault "PlatformConfigFaultFault", detail "Operation failed, diagnostics report: Unable to get console path for volume, VeeamBackup_TS-FS01"  

  An error occurred during host configuration. 192.168.88.6: Fault "PlatformConfigFaultFault", detail "Operation failed, diagnostics report: Unable to get console path for volume, VeeamBackup_TS-FS01"  
[24.08.2023 12:38:19] <10> Error         An error occurred during host configuration. . Failed to mount NFS volume (192.168.88.6:/VeeamBackup_TS-FS01). 192.168.88.6: Fault "PlatformConfigFaultFault", detail "Operation failed, diagnostics report: Unable to get console path for volume, VeeamBackup_TS-FS01"  



Fault "DuplicateNameFault", detail "<DuplicateNameFault xmlns="urn:vim25" xsi:type="DuplicateName" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><name>VeeamBackup_srv-bkp2


 Лечение такое:  
1. Заходим в консоль ESXi и смотрим список подключений
[root@esxi:~] esxcfg-nas -l
в моем случае пусто
2. Отключаем VeeamBackup_TS-FS01, где TS-FS01 имя сервера
[root@esxi:~] esxcfg-nas -d VeeamBackup_TS-FS01
IORM: failed to disable IORM: Unable to get console path for volume, VeeamBackup_TS-FS01
NAS volume VeeamBackup_TS-FS01 deleted.
3. Все работает. Повторное монтирование образа виртуальной машины проходит успешно

пятница, 15 декабря 2023 г.

MSDistribution cleanup

 EXEC dbo.sp_MSdistribution_cleanup @min_distretention = 0, @max_distretention = 24


select count(*) from distribution..msrepl_commands

select count(*) from distribution..msrepl_transactions


go

DECLARE @rowcountCom int = 5000000

DELETE TOP(@rowcountCom) MSrepl_commands WITH (PAGLOCK) 

FROM MSrepl_commands 

WITH (INDEX(ucMSrepl_commands)) 



DELETE TOP(@rowcountCom) MSrepl_commands WITH (PAGLOCK) 

FROM MSrepl_commands 

WITH (INDEX(ucMSrepl_commands)) 



DELETE TOP(@rowcountCom) MSrepl_commands WITH (PAGLOCK) 

FROM MSrepl_commands 

WITH (INDEX(ucMSrepl_commands)) 


go

DELETE TOP(@rowcountCom) MSrepl_commands WITH (PAGLOCK) 

FROM MSrepl_commands 

WITH (INDEX(ucMSrepl_commands))