Friday, July 2, 2021

Getting logs related to a specific user login in Ubuntu 20.04

I was having some trouble on Ubuntu 20.04 with figuring out why a Active Directory user couldn't log in to the server via SSH, and eventually came up with this, which was inspired by the link below it.

sudo journalctl | grep <<username>>



From here:

https://serverfault.com/questions/130482/how-to-check-sshd-log


All messages about sshd:

journalctl -t sshd

or

journalctl -u ssh 


Messages about sshd from the last boot:

journalctl -t sshd -b0


Messages about sshd from the last boot in the reverse order:

journalctl -t sshd -b0 -r

Monday, June 21, 2021

Linux Log Locations

Linux log locations

. . . because I never remember


/var/log/messages : General log messages
/var/log/boot : System boot log
/var/log/debug : Debugging log messages
/var/log/auth.log : User login and authentication logs
/var/log/daemon.log : Running services such as squid, ntpd and others log message to this file
/var/log/dmesg : Linux kernel ring buffer log
/var/log/dpkg.log : All binary package log includes package installation and other information
/var/log/faillog : User failed login log file
/var/log/kern.log : Kernel log file
/var/log/lpr.log : Printer log file
/var/log/mail.* : All mail server message log files
/var/log/mysql.* : MySQL server log file
/var/log/user.log : All userlevel logs
/var/log/xorg.0.log : X.org log file
/var/log/apache2/* : Apache web server log files directory
/var/log/lighttpd/* : Lighttpd web server log files directory
/var/log/fsck/* : fsck command log
/var/log/apport.log : Application crash report / log file


Copied from
https://ubuntuforums.org/showthread.php?t=1568706

Friday, May 14, 2021

The trust relationship between this workstation and the primary domain failed (in server core)

 I got the error 

The trust relationship between this workstation and the primary domain failed

in server core after restoring from a snapshot in VirtualBox.

On my remote management machine, I tried to connect to the machine using Computer Management, which threw this not-quite-helpful error message.

Computer X cannot be managed. Verify that the network path is correct, the computer is available on the network, and that the appropriate Windows Firewall rules are enable on the target computer.

To enable the appropriate Windows Firewall rules on the remote computer, open the Windows Firewall with Advanced Security snap-in, and enable the following Inbound rules:

COM+ Network Access (DCOM-in)
All rules in the Remote Event Log Management group

You can also enable these rules by using Group Policy settings for Windows Firewall with Advanced Security. For servers that are running the Server Core installation option, run the Netsh AdvFirewall command, or the Windows Powershell NetSecurity module.


As originally posted on this page, here's the steps to resolve.


1. Log into the server in question using the non domain admin account.

2. Open the Power Shell and run the command:

$credential = Get-Credential

3. Then run the command:

Reset-ComputerMachinePassword -Server ClosestDomainControllerNameHere


Thursday, February 18, 2021

Revised Script: Indexing and looking for a cursor in an update statement

I ran a QC script over the results of yesterday's cursor counts table, and realized I had made a logical error.


Here's the QC scripts:

select count(*) as counted, 'photos' as [Source] from dbo.photos
union all
select count(*) as counted, 'photos-null votes' as [Source] from dbo.photos where tally is null
union all
select count(*) as counted, 'votes' as [Source] from dbo.votes;

select top 10 * from dbo.photos;
select top 10 * from dbo.votes;
select sum(tally) as TotalVotesCounted from dbo.photos;
select top 10 * from dbo.votes as v left join dbo.photos as p on p.id = v.photoID where p.tally is null





And here's the revised creation script:

set nocount on;
use enron;
go

if object_id('dbo.photos') is null
create table photos (id INT identity(1,1) primary key, photo varbinary(max), tally INT);
else
truncate table dbo.photos;
go

if object_id('dbo.votes') is null
create table votes(id INT identity(1,1) primary key, userID INT, photoID INT);
else
truncate table dbo.votes;
go

DECLARE @counter INT;  
SET @counter = 1;  
WHILE @counter < 500
   BEGIN  
      insert into dbo.photos(photo) values(rand() * 1000)
      SET @counter = @counter + 1  
   END;  
GO  

DECLARE @counter INT, @userid int, @photoid int, @msg varchar(256);  
SET @counter = 1;  
WHILE @counter < 50000
	BEGIN  
		SELECT @userid = rand() * 100;
		select @photoid = rand() * 1000;
		if (@photoid between 1 and 499)
		insert into votes(userid, photoid) values (@userid, @photoid)
		SET @counter = @counter + 1;
	END;  
GO  


 



Wednesday, February 17, 2021

Indexing and looking for a cursor in an update statement

 From this page:


http://www.artfulsoftware.com/infotree/qrytip.php?id=531&m=0


I wanted to see if, in SQL Server, this same mySQL query 

  1. Could be reproduced
  2. Could be sped up with an index
  3. Would show up as a cursor in the estimated execution plan for the update statement 


1. Reproduction

So, yes, this is a fairly simple script to reproduce.



set nocount on;
use enron;
go

if object_id('dbo.photos') is null
create table photos (id INT identity(1,1) primary key, photo varbinary(max), tally INT);
else
truncate table dbo.photos;
go

if object_id('dbo.votes') is null
create table votes(id INT identity(1,1) primary key, userID INT, photoID INT);
else
truncate table dbo.votes;
go

DECLARE @counter INT;  
SET @counter = 1;  
WHILE @counter < 500
   BEGIN  
      insert into dbo.photos(photo) values(rand() * 1000)
      SET @counter = @counter + 1  
   END;  
GO  

DECLARE @counter INT, @userid int, @photoid int, @msg varchar(256);  
SET @counter = 1;  
WHILE @counter < 50000
	BEGIN  
		SELECT @userid = rand() * 100;
		select @photoid = rand() * 1000;
		if (@photoid between 0 and 500)
		insert into votes(userid, photoid) values (@userid, @photoid)
		SET @counter = @counter + 1;
	END;  
GO  


However, in my version, I loaded a larger data set into the tables, as I wanted to have enough data to get a measureable difference when applying the index in step two.

Note also, that in my version, the values are randomly generated, but controlled, so they can only be inserted if they match a photo that we expect to actually have.


2. Indexing


Yes, the statement can be sped up with an index.


Here's the properties of the script, before index application:




Here's after applying the index:




It's a third of the cost. Win!


3. Cursor


There are loops - which is expected - but SQL Server doesn't dissolve into an explicit cursor to handle the update.




Friday, February 5, 2021

Installing SQL Server Configuration Manager when missing for remote management

Following up from the previous post, installing Client Tools Connectivity from the SQL Server 2019 DVD/ISO installed the SQL Server Configuration Manager feature into Server Manager & Computer Management within my management VM.






Thursday, February 4, 2021

There is insufficient system memory in resource pool 'default' to run this query

So while running a really generic restore to the SQL Server cluster instance sql1:

USE [master]

RESTORE DATABASE [enron] 
FROM  DISK = N'\\ServerE\iso\enron.bak'
WITH  FILE = 1, 
MOVE N'enron_Data' TO N'C:\Data\enron_Data.mdf', 
MOVE N'enron_Log' TO N'C:\Data\enron_Log.ldf', 
NOUNLOAD,  REPLACE,  STATS = 5

GO


The error, while descriptive, was interesting because it was "terse" :)

Msg 3224, Level 16, State 2, Line 2

Error: 3224, Severity: 16, State: 2. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.

Msg 3013, Level 16, State 1, Line 2

RESTORE DATABASE is terminating abnormally.

Msg 701, Level 17, State 123, Line 2

There is insufficient system memory in resource pool 'default' to run this query.


Completion time: 2021-02-04T03:18:26.1654581-08:00



Turns out, the RAM for the server was still set at it's installation default of 128 MB.




Once that was increased to 1024 MB, the problem magically went away.