Setup Fleet Manager

How to Enable GUI Access via Fleet Manager Ensure SSM Agent is Installed and Running Windows EC2 instances must have the “SSM Agent” installed and running. Check the status by the powershell command Get-Service AmazonSSMAgent Attach a Role with the following policies AmazonSSMManagedInstanceCore AmazonSSMFullAccess (This is required for GUI access via Fleet Manager) How to access to EC2 via Fleet Manager Go to “Systems Manager” → “Fleet Manager” ...

February 9, 2025

Download From CloudShell

Copy certificate CloudShell Copy directory cp -r wildcard-v6 wildcard-v7 ZIP the directory zip -r wildcard-v7.zip wildcard-v7 Download from CloudShell See also: OpenSSL (3) - Server Certificate OpenSSL (4) - Client Certificate

February 9, 2025

OpenSSL (3) - Server Certificate

Create a Server Certificate 1. Generate a key file (It can be one-off operation) openssl genrsa -out server/private/server.key 2048 2. Generate a Certificate Signing Request (CSR) openssl req -config mid-ca/mid-ca.conf -key server/private/server.key -new -sha256 -out server/csr/server.csr e.g., CN=GCS-Server-Certificate-v0x 3. Sign the request (CSR) by Sub-CA openssl ca -config mid-ca/mid-ca.conf -extensions server_cert -days 3650 -notext -in server/csr/server.csr -out server/certs/server.crt 4. Generate PFX with NO password openssl pkcs12 -inkey server/private/server.key -in server/certs/server.crt -export -out server/certs/server.pfx -passout pass: 5. Result ...

February 9, 2025

OpenSSL (2) - Intermediate CA

Create a “Intermediate CA” certificate 1. Generate a key file for “Intermediate CA” openssl genrsa -aes256 -out mid-ca/private/mid-ca.key 4096 2. Change the permission of mid-ca.key chmod 400 mid-ca/private/mid-ca.key 3. Generate a Certificate Signing Request (CSR) openssl req -config ca/ca.conf -new -key mid-ca/private/mid-ca.key -sha256 -out mid-ca/csr/mid-ca.csr 4. Sign the request file by Root-CA openssl ca -config ca/ca.conf -extensions v3_mid_ca -days 3650 -notext -in mid-ca/csr/mid-ca.csr -out mid-ca/certs/mid-ca.crt 5. Change the permission of mid-ca.crt chmod 444 mid-ca/certs/mid-ca.crt 6. Check a backup file created in newcerts dirctory ...

February 9, 2025

OpenSSL (1) - Root CA

Create a “Root CA” certificate 1. Generate a key file for “Root CA” openssl genrsa –aes256 -out ca/private/ca.key 4096 2. Change the permission of ca.key chmod 400 ca/private/ca.key 3. Check the content of ca.key openssl rsa -noout -text -in ca/private/ca.key 4. Generate a certificate file for “Root CA” openssl req -config ca/ca.conf -key ca/private/ca.key -new -x509 -days 3650 -sha256 -extensions v3_ca -out ca/certs/ca.crt 5. Change the permission of ca.crt chmod 444 ca/certs/ca.crt 6. Check the contents of ca.crt openssl x509 -noout -text -in ca/certs/ca.crt See also: OpenSSL - Initial Setup ...

February 9, 2025

Deadlock Issue in SQL Serever

What is a Deadlock? A deadlock in SQL Server occurs when two or more processes hold locks on resources and each process is waiting for the other to release its lock, causing a cycle where none can proceed. Why Does It Occur? Deadlocks typically hapen due to: Concurrent Transactions: Multiple transactions access the same resources in a conflicting order. Locking Order: Processes acquire locks in different sequences, leading to circular wait conditions. Long-Running Transactions: Holding locks for an extended period increases the chance of conflicts. Insufficient Indexing: Poor indexing leads to table scans, increasing lock contention. Blocking Issues: Heavy blocking can escalate to deadlocks if multiple processes wait indefinitely. How Poor Maintenance Can Lead to Deadlocks Fragmented Indexes & Performance Degradation If the database has grown significantly and indexes haven’t been maintained (i.e., no reindexing or rebuilding), queries will take longer to execute. Longer query execution times mean locks are held for extended periods, increasing the chances of deadlocks. Full Logging & Large Transaction Logs If transaction logs are continuously growing without proper backups or truncation, SQL Server might struggle with log management, leading to slower transaction processing. Slow transactions hold locks for longer, making deadlocks more likely. Mass Deletes Without Reindexing Deleting a large number of records without reindexing can leave fragmented pages and inefficient query plans. The database engine might perform table scans instead of index seeks, leading to increased lock contention. Query Plan Changes (Due to Increased Data Size) As the database grows, SQL Server might generate different execution plans that were not optimized for the current data size. This can lead to more locking and blocking, increasing the chance of deadlocks. Demo - Create a test table 1. Create a Large Table & Insert Sample Data USE master; GO CREATE DATABASE ConflictTestDB; GO USE ConflictTestDB; GO CREATE TABLE Orders ( OrderID INT IDENTITY(1,1) PRIMARY KEY, CustomerID INT, OrderDate DATETIME DEFAULT GETDATE(), OrderAmount DECIMAL(10,2), Status VARCHAR(20) ); GO -- Insert ~1 Million Rows SET NOCOUNT ON; DECLARE @i INT = 1; BEGIN TRAN WHILE @i <= 1000000 BEGIN INSERT INTO Orders (CustomerID, OrderAmount, Status) VALUES (ABS(CHECKSUM(NEWID())) % 1000, RAND() * 1000, 'Pending'); SET @i = @i + 1; END COMMIT TRAN; GO 2. Create Index Fragmentation (Without Reindexing) -- Delete a large number of records randomly to cause index fragmentation DELETE FROM Orders WHERE OrderID % 10 = 0; GO -- Fill gaps with new inserts (in random order) SET NOCOUNT ON; DECLARE @i INT = 1; BEGIN TRAN WHILE @i <= 100000 BEGIN INSERT INTO Orders (CustomerID, OrderAmount, Status) VALUES (ABS(CHECKSUM(NEWID())) % 1000, RAND() * 1000, 'Pending'); SET @i = @i + 1; END COMMIT TRAN; GO 3. Check Fragmentation for All Indexes on [Orders] Table SELECT index_id, index_type_desc, avg_fragmentation_in_percent, avg_page_space_used_in_percent, page_count FROM sys.dm_db_index_physical_stats(DB_ID(), OBJECT_ID('Orders'), NULL, NULL, 'LIMITED'); avg_fragmentation_in_percent → Shows fragmentation level: ...

February 9, 2025

How to Setup PasteImage

How to Paste Images into Your Hugo Blog in VS Code on Mac 1. Install the “Paste Image” Extension in VS Code Open VS Code Press Cmd + Shift + X to open Extensions Search for “Paste Image” by mushanh Click Install 2. Configure the Extension to Save Images in Your Blog Folder Open Settings (Cmd + ,) Search for “pasteImage.path” Set it to:This ensures images are saved inside the same folder as the Markdown file. ...

February 9, 2025