Docker installation on Debian

Remove any old versions of docker:

sudo apt-get remove docker docker-engine docker.io containerd runc

Install dependencies:

sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release

Add the docker key:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg –dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Add the docker repository to the apt configuration:

echo “deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Update the repository list:

sudo apt-get update

Install docker:

sudo apt-get install docker-ce docker-ce-cli containerd.io

Test docker by installing and running the hello-world image from Docker Hub:

sudo docker run hello-world

Install docker-compose from https://github.com/docker/compose/releases/:

Download the docker-compose binary and sha256sum file:

cd /usr/local/src/
wget https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64
wget https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64.sha256

Verify the sha256sum for the binary:

sha256sum -c docker-compose-Linux-x86_64.sha256sum

Copy the binary to your path (/usr/local/bin) and set the execute permissions:

cp -p docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
chmod 744 /usr/local/bin/docker-compose

MySQL timestamp integer conversion

This will output two columns. One is the original time as an integer and the second as YYYY-MM-DD hh:mm:ss.

select TIMESTAMP, from_unixtime(TIMESTAMP) from my_table;

MSSQL 2017 on Ubuntu Configuration Modifications

This will address a few basic MSSQL configuration changes when running MSSQL on a linux platform.

The first one involves changing the default database and log locations:
To set the default directories:

sudo /opt/mssql/bin/mssql-conf set filelocation.defaultdatadir /{SOMENEWDATADIRECTORY}
sudo /opt/mssql/bin/mssql-conf set filelocation.defaultlogdir /{SOMENEWLOGDIRECTORY}
sudo /opt/mssql/bin/mssql-conf set filelocation.defaultbackupdir /{SOMENEWBACKUPDIRECTORY}
sudo systmectl restart mssql-server

For example:

sudo /opt/mssql/bin/mssql-conf set filelocation.defaultdatadir /Data
sudo /opt/mssql/bin/mssql-conf set filelocation.defaultlogdir /Logs
sudo /opt/mssql/bin/mssql-conf set filelocation.defaultbackupdir /Backup
sudo systmectl restart mssql-server

Next up is enabling the SQL Agent:
Enable the SQL Agent:

/opt/mssql/bin/mssql-conf set sqlagent.enabled true
sudo systemctl restart mssql-server

Lastly is moving the default databases to a new location. For instance to the default directories you configured above. This is a bit more involved, so you have to pay attention to the details. Unless otherwise specified these are run from the linux command line.

First, you need to ensure that the new directory locations are owned by mssql, and group access is allowed for mssql group as well.

sudo chown mssql.mssql /Data
sudo chown mssql.mssql /Logs
sudo chown mssql.mssql /Backup

Determine where the tempdb data and logs files are currently:
Access the SQL server and update the tempdb location:

sqlcmd -S localhost -U SA -P {PASSWORD}
> SELECT name, physical_name AS CurrentLocation FROM sys.master_files WHERE database_id = DB_ID(N’tempdb’);
> GO

> USE master;
> GO
> ALTER DATABASE tempdb
> MODIFY FILE (NAME = tempdev, FILENAME = ‘/Data/tempdb.mdf’);
> GO
> ALTER DATABASE tempdb
> MODIFY FILE (NAME = templog, FILENAME = ‘/Logs/templog.ldf’);
> GO

Restart the MSSQL server:

sudo systemctl restart mssql-server.service

You can make subdirectories for each database if you want as well. You just have to make certain that the ownership is correct.

sudo mkdir /Data/msdb
sudo mkdir /Logs/msdb
sudo chown -R mssql.mssql /Data/
sudo chown -R mssql.mssql /Logs/

Access the SQL server:

sqlcmd -S localhost -U SA -P {PASSWORD}

Determine where the msdb data and logs files are currently:

> SELECT name, physical_name AS CurrentLocation FROM sys.master_files WHERE database_id = DB_ID(N’msdb’);
> GO

Continuing from the SQL server:
Move msdb:

> USER master
> GO
> ALTER DATABASE msdb
> MODIFY FILE (NAME = MSDBData, FILENAME = ‘/Data/msdb/MSDBData.mdf’);
> GO
> ALTER DATABASE msdb
> MODIFY FILE (NAME = MSDBLog, FILENAME = ‘/Logs/msdb/MSDBLog.ldf’);
> GO

Move the existing database files to their new locations:

sudo sudo cd /var/opt/mssql/data/
sudo systemctl stop mssql-server.service
sudo mv msdbdata.mdf /Data/msdb/
sudo mv msdblog.ldf /Logs/msdb/
sudo systemctl restart mssql-server.service
sudo systemctl status mssql-server.service

Access the SQL server:

sqlcmd -S localhost -U SA -P {PASSWORD}

Determine where the model data and logs files are currently:

> SELECT name, physical_name AS CurrentLocation FROM sys.master_files where database_id = DB_ID(N’model’)
> GO

Continuing from the SQL server:
Move model:

> USE master
> ALTER DATABASE model
> MODIFY file (NAME = modeldev, FILENAME = ‘/Data/model/model.mdf’)
> GO
> ALTER DATABASE model
> MODIFY file (NAME = modellog, FILENAME = ‘/Logs/model/modellog.ldf’)
> GO

Move the existing database files to their new locations:

sudo sudo cd /var/opt/mssql/data/
sudo systemctl stop mssql-server.service
sudo mkdir /Data/model
sudo mkdir /Logs/model
sudo chown mssql.mssql /Data
sudo chown mssql.mssql /Logs
sudo mv msdbdata.mdf /Data/model/
sudo mv msdblog.ldf /Logs/model/
sudo systemctl restart mssql-server.service
sudo systemctl status mssql-server.service

Access the SQL server:

sqlcmd -S localhost -U SA -P {PASSWORD}

Determine where the master data and log files are currently:

> SELECT name, physical_name AS CurrentLocation FROM sys.master_files where database_id = DB_ID(N’master’)
> GO

The master database is a little different than the others. You set the configuration after stopping the mssql-server process and moving the files.

sudo cd /var/opt/mssql/data
sudo mkdir /Data/master
sudo mkdir /Logs/master
sudo chown -R mssql.mssql /Data
sudo chown -R mssql.mssql /Logs
sudo mv master.mdf /Data/master
sudo mv master.mdf /Logs/master
sudo /opt/mssql/bin/mssql-conf set filelocation.masterdatafile /Data/master/master.mdf
sudo /opt/mssql/bin/mssql-conf set filelocation.masterlogfile /Logs/master/mastlog.ldf
sudo systemctl stop mssql-server
sudo systemctl start mssql-server
sudo systemctl status mssql-server

MSSQL Installation on Ubuntu Server

The installation itself is not too bad. It is pretty straightforward.
This process worked well on Ubuntu 18.x installing Microsoft SQL 2017 and 2019. The details in this post are for the 2017 version. The only thing that is different is the repository configuration, and in particular what you download configure the repository to support installing 2019.

Download and add the Microsoft public repository GPG key:

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –

Add the Micorosft apt repository:

sudo add-apt-repository “$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2017.list)”

Update repository mirror list:

sudo apt-get update

Install MSSQL 2017:

sudo apt-get install -y mssql-server

Run the MSSQL setup:

sudo /opt/mssql/bin/mssql-conf setup

The setup will ask just a couple questions. One is which version you want to run. I installed the Developer version. The second this is to accept the license agreement.

Check MSSQL status to verify it is running:

systemctl status mssql-server

Add the MSSQL tools repository:

curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | tee /etc/apt/sources.list.d/msprod.list

Update repository mirror list:

sudo apt-get update

Install MSSQL 2017 tools:

sudo apt-get install mssql-tools unixodbc-dev

Add tools directory to account path:

echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bash_profile

Add tools directory to account path for non-interactive execution:

echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bashrc
source ~/.bashrc

Connect to MSSQL via command line:

sqlcmd -S localhost -U SA -P ‘

Unitrends Backup Error

I was trying to backup a VM using a Unitrends appliance. I kept getting the following:

WARNING: Did not receive any data!!

I found the following in the vSphere client:

Create virtual machine snapshot

The operation is not allowed in the current state.

So, it turns out the the issue was not with the Unitrends job, but the snapshot process on the VMware host.

I used ssh to login into the host as root and did the following:
/etc/init.d/hostd restart:

[root@host1:~] /etc/init.d/hostd restart
watchdog-hostd: Terminating watchdog process with PID 572484
hostd stopped.
Ramdisk ‘hostd’ with estimated size of 1053MB already exists
hostd started.

/etc/init.d/vpxa restart:

[root@host01:~] /etc/init.d/vpxa restart
watchdog-vpxa: Terminating watchdog process with PID 573196
vpxa stopped.

Then, I rebooted the VM and tried the backup again. It worked fine.

Ubuntu 18.x – netplan to set static IP address

Here we go again. A completely different way to configure the network using netplan. I used the following on an Ubuntu 18.x LTS server to configure the static IP address:

$ cd /etc/netplan

If this directory, there will be a yaml file. I have seen this have a couple different names, but it has always been the only file in the directory. In this case, the file was named: 00-installer-config.yaml

If you brought the machine using DHCP, you need to change the “dhcp4: yes” line to “dhcpv: no”. Below, is an example setting the IP address, mask via the CIDR designation (subnet bits) after the IP address, the gateway, the nameservers and a search domain.

$ sudo vi 00-installer-config.yaml

network:
ethernets:
ens160:
dhcp4: no
addresses: [aaa.bbb.ccc.ddd/mm]
gateway4: eee.fff.ggg.hhh
nameservers:
addresses: [www.xxx.yyy.zzz, mmm.nnn.ooo.ppp]
search: [my.domain, my.otherdomain]
version: 2

Note: Make sure you do the following from the console, if modifying the IP address.
Apply the configuration:
$ sudo netplan apply

Mount a disk partition using the UUID in linux.

I was mounting an external drive using the partition device file. I found that over time the mounted partition would give an I/O error. It turned out it was because the device file had changed. I decided to mount it using UUID to see if took care of the issue.

Here what I did to mount it and add it to the startup:

# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk /dev/sdc: 3.7 TiB, 4000787029504 bytes, 7814037167 sectors
Disk model: One Touch HDD
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: E396A756-646C-40DC-A8F8-59CC11D40FA8

Device Start End Sectors Size Type
/dev/sdc1 2048 7814035455 7814033408 3.7T Linux filesystem

Command (m for help): quit

Use this command to determine the UUID:

# blkid

/dev/sdc1: UUID=”20f17e14-71c3-498f-8872-97dcd80c1d3e” TYPE=”ext4″ PARTUUID=”ccbd82af-94e0-431a-a54b-b9100a087133″

You can use lsblk as well:

# lsblk -fs
NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT

sdc1 ext4 20f17e14-71c3-498f-8872-97dcd80c1d3e
└─sdc

Add the entry to the fstab:

# vi /etc/fstab

UUID=20f17e14-71c3-498f-8872-97dcd80c1d3e /external ext4 defaults 0 0

Then mount it:

# mount /external

Chrome and Brave – Your connection is not private.

Here a nice trick to get around the seemingly impossible “Your connection is not private” page when you try to access a site with a self signed certificate. I really don’t understand why nobody comes up with a better way to deal with this. We need the transport on our LANs to be encrypted using https. It should be easier to get this done.

Anyway, this is how you get the screen:

This applies to the “Your connection is not private” that has the “NET::ERR_CERT_INVALID” message in it.

Click anywhere on the background of the page, and type “thisisunsafe” and hit Enter. Then, you will proceed to site.

Note: This happens in MacOS, and I seen this is the latest versions of Chrome on linux.

Debian 10 – RDP

OS: Debian 10
Desktop Environment: XFCE

Install RDP on a system running a desktop environment is really pretty simple with one caveat. It seems that you cannot steal a session from the console by logging with that same username. So, if you know you are going to need the desktop environment, make sure you log off the console, if logged into the desktop environment, before attempting to login remotely. If you do forget, you make only get part of the environment, but have no way really do anything until you logoff from the console session.

Install RDP:

# apt install xrdp xterm

Enable xrdp and xrdp-sesman:

# systemctl enable xrdp
# systemctl enable xrdp-sesman

Start both services:

# systemctl start xrdp
# systemctl start xrdp-sesman

If you do not have a desktop environment setup:

# apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils

Verify that xrdp is running:

# systemctl status xrdp
● xrdp.service – xrdp daemon
Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2021-03-28 19:49:01 PDT; 4 weeks 0 days ago
Docs: man:xrdp(8)
man:xrdp.ini(5)
Main PID: 724 (xrdp)
Tasks: 2 (limit: 4915)
Memory: 22.2M
CGroup: /system.slice/xrdp.service
├─ 724 /usr/sbin/xrdp
└─19572 /usr/sbin/xrdp

Apr 26 10:22:30 lm xrdp[19572]: (19572)(140553222580032)[DEBUG] xrdp_wm_log_msg: connecting to sesman ip 127.0.0.1 port 3350
Apr 26 10:22:31 lm xrdp[19572]: (19572)(140553222580032)[INFO ] xrdp_wm_log_msg: sesman connect ok
Apr 26 10:22:31 lm xrdp[19572]: (19572)(140553222580032)[DEBUG] xrdp_wm_log_msg: sending login info to session manager, please wait…
Apr 26 10:22:31 lm xrdp[19572]: (19572)(140553222580032)[DEBUG] return value from xrdp_mm_connect 0
Apr 26 10:22:31 lm xrdp[19572]: (19572)(140553222580032)[INFO ] xrdp_wm_log_msg: login successful for display 10
Apr 26 10:22:31 lm xrdp[19572]: (19572)(140553222580032)[DEBUG] xrdp_wm_log_msg: started connecting
Apr 26 10:22:31 lm xrdp[19572]: (19572)(140553222580032)[INFO ] lib_mod_log_peer: xrdp_pid=19572 connected to X11rdp_pid=19575 X11rdp_uid=1000 X11rdp_gid=1000 client_i
Apr 26 10:22:31 lm xrdp[19572]: (19572)(140553222580032)[DEBUG] xrdp_wm_log_msg: connected ok
Apr 26 10:22:31 lm xrdp[19572]: (19572)(140553222580032)[DEBUG] xrdp_mm_connect_chansrv: chansrv connect successful
Apr 26 10:22:31 lm xrdp[19572]: (19572)(140553222580032)[DEBUG] Closed socket 18 (AF_INET6 ::1 port 59468)

Add xrdp to ssl-cert group:

# usermod -a -G xrdp ssl-cert

Reboot:

# shutdown -r now

Connect MySQL Workbench to an AWS Instance

  • Download and install MySQL Workbench.
  • Open MySQL Workbench.
  • Select MySQL New Connection and enter a connection name.
  • Choose the Connection Method, and select Standard TCP/IP over SSH.
  • For SSH Hostname, enter the public IP address of your EC2 instance.
  • For SSH Username, enter the default SSH user name to connect to your EC2 instance.
  • Choose SSH Key File, and select the .pem file used to connect from your file system.
  • For MySQL Hostname, enter the database endpoint name.
  • To find the endpoint name:
    Login in AWS console.
    Click Services, and search for RDS (Managed Relational Database Service).
    Click on Databases.
    Click on the DB Identifier under the cluster DB Identifier you to connect to using MySql Workbench.
    The endpoint for that database will be displayed under Connectivity & security.

  • For MySQL Server Port, enter the port number that you use to connect to your database.
  • This will be in the same location as the identifier.

  • For Username, enter the user name that you use to connect to your database.
  • For Password, enter the MySQL user password.
  • Choose Test Connection. After the test is successful, choose OK to save the connection.
  • Return top

    INFORMATION