Samba :- Name Resolution – From Linux, Resolve Windows Host

Background

Here is how to use Samba to perform name resolution from a Linux Host to MS Windows computers.

Lineage

  1. Windows
    • WINS
      • Installing & Configuring WINS
        Link
  2. Linux
    • Samba
      • Samba – Host Name Resolution
        Link

Steps

Outline

  1. Package Installation
    • samba-winbind
  2. Network Configuration
    • Names Service Switch
      • /etc/nsswitch.conf
    • Samba
      • etc/smb.conf
  3. Firewall Configuration
    • Firewall – firewalld
      • Allow tcp/137 and ucp/137
  4. Restart Services
    • winbind

Package Installation

samba-winbind

yum

yum – is package installed?
Objective

Is samba-winbind installed?

Code

sudo yum list installed | grep samba

Output

package.install.yum.list.01.20190711.png

yum – Install Package
Objective

Install samba-winbind

Code

sudo yum -y install samba-winbind

Output

Image – 1

package.install.yum.install.01.20190711.0801PM.png

Image – 2

package.install.yum.install.01.20190711.0802PM.png

Network Configuration

Files

File :- etc/nsswitch.conf
Outline
  1. Load the /etc/nsswitch.conf file in an editor
  2. Ensure that wins is included in the list of hosts to consult for name resolution requests
    • Original Entry
      • hosts : files dns myhostname
    • Revised Entry
      • hosts : files dns myhostname wins
Images
Image – 01

nsswitch.conf.01.20190711.png

Image – 02

nsswitch.conf.03.20190711.0807PM.png

File :- etc/smb.conf
Outline
  1. Load the /etc/smb.conf file in an editor
  2. Sections
    • Section – Global
      • Configuration Entry
        • workgroup
          • Please have your network domain name
        • netbios name
          • Your computer’s host name
        • wins server
          • Please ensure that your wins server is referenced
Images

smb.conf.01.20190712.0436AM.PNG

 

Network Firewall Configuration

Firewalld

Our OS is centOS and our current firewall is firewalld.

Configuration
Command – Syntax

sudo firewall-cmd --zone={zone} --add-port={port-number}/{protocol} --permanent

Command – Sample

sudo firewall-cmd --zone=public --add-port=137/udp --permanent

sudo firewall-cmd --zone=public --add-port=137/tcp --permanent

Images

firewall.allow.01.20190711.png

Restart Services

Outline

Please restart relevant services.  Those are :-

  1. winbind

 

Configuration

Command – Syntax
sudo service {service} restart
Command – Sample

sudo service winbind restart

Troubleshooting

Issues

ping: unknown host <hostname>

  1. Restart Services
    • Restart winbind
  2. Configuration
    • Linux
      • Configuration – File –
        • /etc/smb.conf
          • Ensure that your WINS Server is referenced

Referenced Work

Vladyslav Baidak
Backend Engineer at Scalified
Devops: Configuring Host Name Resolution
Link
September 24, 2017

References

  1. StackExchange
    • Ask Ubuntu
      • Windows Hostnames are not resolved
        Link
      • Why can’t my machine resolve local windows hostnames?
        Link

IBM Divestiture – 2019

Background

IBM recently completed its purchase of Raleigh’s North Carolina Linux Powerhouse, Red Hat.

As part of that corporate merger, it appears regulars whether here overseas are concerned of allowing too much vertical technology ( Application software, Operating System, and Integration Software ) to rest in a single entity.

 

Affected Product Lines

HCL Software

  1. Collaboration
    • Notes Domino
  2. Application Security
    • AppScan
  3. Application Delivery
    • Bigfix
  4. Marketing
    • Unica
  5. Digital Experience

 

Impact

The current customer base of the products will obviously be affected.

Impacts will include license renewals, support issue tracking, etc.

Customer facing support staff will also have to respond graciously concerns raised by customers.

Referenced Material

  1. HCL
    • HCL TECHNOLOGIES ANNOUNCES CLOSE OF ACQUISITION OF SELECT IBM PRODUCTS
      Link

 

Eclipse/Hibernate – Installation – Day/01

 

Outline

  1. Download & Install Eclipse
  2. JDBC Driver
    • Microsoft JDBC Driver
      • Download Microsoft JDBC Driver
  3. Configure Database
    • Microsoft SQL Server
      • Provision Database
        • WideWorldImporters ( Sample Database )
          • Restore Database
      • Provision Principal
        • Create SQL Server Principal
        • Grant Principal access to database
        • Grant principal access to database objects
  4. Configure Eclipse
    • Install Components
      • JBoss Tools
        • Hibernate

Tasks

Download & Install Eclipse

Please peruse this post per installing Eclipse :-

Eclipse IDE – Installation On MS Windows
Link

JDBC Drivers

Our database back-end is Microsoft SQL Server and so we will reach for Microsoft SQL Server JDBC Drivers.

Microsoft

SQL Server

JDBC Driver
Links
  1. Microsoft JDBC Driver for SQL Server
    Link
  2. Download Microsoft JDBC Driver for SQL Server
    Link
Available

Here are all the drivers available as of 2019-May-6th :-drivers.microsoft.jdbc.20190506.1231PM

We are on 7.0.

And, we will cover that in this post!

Database

Again, our database back-end is Microsoft SQL Server.  There are a few sample databases on that platform; the latest official is WorldWideImporters.

Microsoft

SQL Server

Worldwide Importers
Links
  1. SQL Samples
    Link
  2. Wide World Importers
    • Wide World Importers sample database v1.0
      Link
Brochure

Brochure

microsoft.sample.20190506.1246PM

Choice

We can go with traditional database backup files ( bak ).

Or with bacpac.

We chose :-

SQL Server 2016 SP1 (or later) Any Edition aside from LocalDB; SQL Server 2016 RTM (or later) Evaluation/Developer/Enterprise Edition
WideWorldImporters-Full.bak

Restore database

Launched SQL Server Management Studio and restored the backup file


USE [master]
go

exec master..xp_create_subdir N'C:\Microsoft\SQLServer\Datafiles\WideWorldImporters\'
go

exec master..xp_create_subdir N'C:\Microsoft\SQLServer\Logfiles\WideWorldImporters\'
go

RESTORE DATABASE [WideWorldImporters]
FROM  DISK = N'C:\downloads\Microsoft\SQLServer\Sample\WideWorldImporters\WideWorldImporters-Full.bak'
WITH
       FILE = 1
    ,  MOVE N'WWI_Primary' TO N'C:\Microsoft\SQLServer\Datafiles\WideWorldImporters\WideWorldImporters.mdf'
    ,  MOVE N'WWI_UserData' TO N'C:\Microsoft\SQLServer\Datafiles\WideWorldImporters\WideWorldImporters_UserData.ndf'
    ,  MOVE N'WWI_Log' TO N'C:\Microsoft\SQLServer\Logfiles\WideWorldImporters\WideWorldImporters.ldf'
    ,  MOVE N'WWI_InMemory_Data_1' TO N'C:\Microsoft\SQLServer\Datafiles\WideWorldImporters\WideWorldImporters_InMemory_Data_1'
    ,  NOUNLOAD
    ,  STATS = 5
    ,  REPLACE

GO
Create Database Account

Let us create SQL Server Account


use [WideWorldImporters]
go

/*
    SQL Server Principal - helloDB
*/
if suser_id('helloDB') is null
begin

    create login [helloDB]
    with password = 'Nu3Hu5RuSt'
       , DEFAULT_DATABASE = [WideWorldImporters]
       , CHECK_EXPIRATION = OFF
       , CHECK_POLICY = OFF

end
go

/*
    SQL Server Principal - helloDB
*/
if user_id('helloDB') is null
begin

    create user [helloDB]
    from login [helloDB];

end
go

grant select, insert, update, delete on schema::[Application] to [helloDB]
go

grant select, insert, update, delete on schema::[Purchasing] to [helloDB]
go

grant select, insert, update, delete on schema::[Sales] to [helloDB]
go

grant select, insert, update, delete on schema::[Warehouse] to [helloDB]
go

jboss.org

Available Software

In the Work With entry box, please enter :-

http://download.jboss.org/jbosstools/photon/development/updates

Once entered please click the “Add…” button

install.AvailableSoftware.02.WorkWith.20190505.0225PM.PNG

Add Repository

Please give a Name for the Repository we are adding.

In our case we chose jboss.

install.AvailableSoftware.03.WorkWith.20190505.0225PM.PNG

 

Check the items that you wish to install

Using Web Services, jboss.org is reached.

Available Items are returned and displayed.

install.AvailableSoftware.05.AddRepository.20190505.0228PM.PNG

Item – jBoss Data Services Development

We selected the following items :-

  1. JBoss Data Services Development
    • Hibernate Tools

install.AvailableSoftware.06.AddRepository.20190505.0229PM.PNG

Item – jBoss Data Services Development – Install Details

Please review the selected items :-

  1. JBoss Data Services Development
    • Hibernate Tools

install.AvailableSoftware.07.AddRepository.20190505.0230PM.PNG

 

Item – Review Licenses

Please review License Agreement

  1. License text(for Hibernate Tools 5.4.4.v20190328-1505)

 

Item – Review Licenses

Please review License Agreement

  1. License text(for Hibernate Tools 5.4.4.v20190328-1505)

Item – Installing Software

 

Item – Security Warning

Security Warning – The authenticity or validity of the software cannot be established

Even Hibernate.org is shipping software without SSL Certificates?

 

It is good, please click “Install anyway”.

Restart

Please restart Eclipse ID to effect the changes.

Restarted

Upon restart, we are asked to opt in for anonymous usage statistics.

Summary

Enough shenanigans for Day 01.

 

 

Linux :- ODBC / SQL Server – Configuration

Background

On our Linux box, wanted to configure a Database Source to a SQL Server Instance.

Lineage

In a previous post, we installed SQL Server Command Line Tools and ODBC Development Tools.

That post is :-

SQL Server On Linux – Installing Command Line Tools
Link

ODBC Manager

Here are some of the ODBC Managers that frequently ship with Linux systems :-

  1. iODBC
  2. unixODBC
    • Project Homepage
      Link

Microsoft relies on unixODBC and that fact is documented here :-

Docs / SQL / Connect your client to SQL / ODBC / Linux and Mac
Installing the Driver Manager
Link

Install MS SQL Server ODBC Driver

Linux

CentOS

Our OS is Linux and so we will get Version Number for that OS.

Get Version Number

Syntax

cat /etc/centos-release

Output

linux.version.20181204.1220AM.PNG

Explanation

The returned value is “CentOS Linux release 7.5.1804 (Core)“; version 7.

Installation

Driver

Register Repository

Syntax

sudo su

curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo
exit

Install ODBC Driver ( msodbcsql17 )

Sample

sudo ACCEPT_EULA=Y yum install msodbcsql17

Output

yum.install.20181204.1233AM

Review ODBC Manager

odbcinst

odbcinst -j
Sample
odbcinst -j
Output

odbcinst-j.20181204.0224PM

Explanation
  1. version
    • unixODBC 2.3.1
  2. Drivers
    • /etc/odbcinst.ini
  3. System Data Sources
    • /etc/odbc.ini
  4. File Data Source
    • /etc/ODBCDataSources
  5. User Data Source
    • /home/dadeniji/.odbc.ini

Review Installed Library ( msodbcsql17 )

Folder List

Sample
ls -l /opt/microsoft/msodbcsql17/lib64
Output

msodbcsql.lib64.20181204.1241AM

ldd ( Print Shared Object’s Dependency )

Objective

Validate that the ODBC Driver can be successfully accessed and loaded.

Sample
ldd /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1
Output

ldd.20181204.0550AM

dltest ( Library Symbol Test )

Objective

Test that driver’s module can be loaded and that specific function can be invoked.

Syntax

dltest /opt/microsoft/msodbcsql17/lib64/libmsodbcsql[version-number] SQLGetInstalledDrivers

Sample

dltest /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1 SQLGetInstalledDrivers

Output

dltest.20181204.1244AM

Data Source Registration

/etc/odbcinst.ini

cat

Sample

cat /etc/odbcinst.ini
Output

odbcinst.ini.20181204.1249AM

Data source Registration

/etc/odbc.ini

vi

sudo to vi and edit /etc/odbc.ini.

Add entries for targeted SQL Server Instance.

Sample

sudo vi /etc/odbc.ini
Output

odbc.ini.20181204.1257AM

List configured Data Sources

Syntax

odbcinst -q -s
Sample

odbcinst -q -s
Output

odbc.list.20181204.0100AM

Query

isql

Launch

Syntax


isql -v [datasource] [user] [pwd]

Sample


isql -v bible dadeniji mystupidpwd

Output

launch.20181204.0108AM

Query

Query – Get Current Database

Sample

select db_name as [dbname]

Output

query.getDBName.20181204.0207PM

Referenced Work

  1. Microsoft
    • Docs / SQL / Connect your client to SQL / ODBC / Linux and Mac
      • Installing the Driver Manager
        Link
      • Installing the Microsoft ODBC Driver for SQL Server on Linux and macOS
        Link
  2. capside
    • Using Azure SQL Database and Azure SQL DataWarehouse with Perl
      Link
  3. MAPR
    • Support Portal
      • How to test ODBC connections for debugging in Linux using unixODBC
        Link
  4.  mkleehammer/pyodbc
    • mkleehammer/pyodbc
      • Connecting to SQL Server from RHEL or Centos
        Link
  5. Snowflake
    • DOCS » CONNECTING TO SNOWFLAKE » ODBC DRIVER
      • INSTALLING AND CONFIGURING THE ODBC DRIVER FOR LINUX
        Link
  6. azurewebsites
    • Create PHP apps using SQL Server on RHEL
      Link
  7.  isql
  8. Man7.org
    • Linux Programmers Manual
  9. unixodbc
    • odbcinst.ini
      • unixODBC without the GUI
        Link
    • dltest
      • dltest man page
        Link
  10. systutorials.com
    • odbcinst
      • odbcinst (1) – Linux Man Pages
        Link
  11. SQReam
    • ODBC for Linux documentation

SQL Server On Linux – Installing Command Line Tools

Background

It is time to start playing around with command line client tools for SQL Server On Linux.

os

Each os has its own installation platform.

Our os is CentOS and so that is the os we singularly target.

Components

Here are the actual components that are part of SQL Server Client Tools :-

  1. sqlcmd
    • SQL Query Tools
  2. bcp
    • Transfer data in and out from SQL Server to text-file

 

Repositories

Review Registered Repositories

Syntax


yum repolist

Output

yum.repolist.20181130.0947PM

Explanation

  1. packages-microsoft-com-prod
    • That is the repo we are are looking for

Register Repository

If the Repository is not registered, please register it!

Syntax

sudo curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo

Output

yum.register.20181130.1000PM

Explanation

  1. Added Repositories
    • Added msprod.repo

 

Install Application

Is Application installed

Syntax


sudo yum list installed | grep -i mssql

Output

yum.list.installed.20181130.0908PM

Explanation

  1. Review installed mssql applications
    • mssql-server.x86_64
      • Server
    • client???

Review Applications

List all available applications.

Our options are :-

  1. yum list
  2. yum search

yum list

Syntax

yum list | grep -i mssql

Output

yum.list.20181130.0903PM

yum search

Syntax


yum search mssql

Output

yum.search.20181201.0757AM

Explanation

  1. The applications we need are :-
    • mssql-tools.x86_64

 

Application Info

List all available applications.

Syntax

yum info mssql-tools.x86_64

Output

yum.info.mssql-tools.x86_64.20181201.0736AM

Install Application

Install application.

Syntax

sudo yum install mssql-tools unixODBC-devel

Output

yum.install.mssql-tools.20181130.1045PM.PNG

 

Application Installed Location

whereis

Syntax


whereis [app]

Sample


whereis sqlcmd


Sample


whereis bcp

Output

whereIs.20181201.0742AM

Explanation

  1. Our applications, sqlcmd and bcp, are installed in the /opt/mssql-tools/bin folder

 

Invoke Application

sqlcmd

Syntax


/opt/mssql-tools/bin/sqlcmd -S localhost -U dadeniji -Q "select @@servername as servername"

Output

query.servername.20181130.0930PM

Explanation

  1. We are prompted for the password to our username
  2. We entered the username
  3. And, the query returns the username

 

References

  1. Microsoft
    • Docs / SQL / SQL Server on Linux
      • Install sqlcmd and bcp the SQL Server command-line tools on Linux
        Link

SQL Server – Installation on Linux/CentOS

Background

Let us install SQL Server v2017 on our CentOS System.

Installation

Outline

  1. Repositories
    • Review registered Repositories
    • Add missing Repositories
  2. MS SQL Server Engine
    • Install
    • Configure
  3. Services
    • Service Review
  4. Adjust Network Firewall Rules
  5. Validate

Repositories

Review Registered Repositories

yum repolist

Syntax

yum repolist

Output

yum.repolist.20181126.0831PM.PNG

Explanation

We do not see the repositories that we need :-

  1. Repositories
    • packages-microsoft-com-mssql-server-2017

 

yum repository – add

Sample
Sample – Add SQL Server RTM

sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017-gdr.repo

 

Sample – Add Cumulative Patch

sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo

 

Review Registered Repositories

yum repolist

Syntax

yum repolist

Output

yum.repolist.post.20181126.1034PM

Explanation
  1. Repositories
    • packages-microsoft-com-mssql-server-2017

 

Install

Install SQL Server Engine

Syntax

yum install -y mssql-server

Output

install.20181126.0859PM.PNG

 

Configuration

License

Syntax

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

sudo-ms-config-20181126-0914PM.PNG

 

Explanation
  1. Licensing
    • Developer
  2. sa password
    • Enter and Confirm sa password

Services

Review Services :- mssql-server

Syntax

systemctl status [service]
Sample

systemctl status mssql-server

Output

systemctl.20181126.0917PM.PNG

Explanation
  1. Service is running

Firewall

iptables

Our Firewall Software is iptables.

Port TCP/1433 ( mssql-server )

/etc/sysconfig
Outline
  1. Using an editor load /etc/sysconfig/iptables
  2. Add Entry for TCP/port 1433
    • -A INPUT -p tcp -m state –state NEW -m tcp –dport 1433 -j ACCEPT
Image – Pre

firewall.etc.sysconfig.pre.20181126.0942PM.PNG

Image – Post

firewall.etc.sysconfig.post.20181126.1052PM

Reload
Syntax

sudo systemctl reload iptables

Validation

SQL Query

@@version

Syntax

select @@version

Output

@@version.20181126.1110PM

 

References

  1. CentOS.Org
  2.  DigitalOcean
    • Mitchell Anicas
      • How To List and Delete Iptables Firewall Rules
        Link
  3. Sharad Chhetri
    • How to start / stop / restart / reload iptables on CentOS 7 / RHEL 7
      Link

 

 

PowerShell – Get Computer name

Background

Wanted to highlight a couple of APIs for retrieving the computer name in Powershell.

Platform

Linux/Cent OS.

 

Outline

  1. Environment Variable
    • Get-ChildItem Env:HOSTNAME
  2. system.environment
    • machineName
  3. system.net.Dns
    • GetHostName
  4. Get-WmiObject ( only works on MS Windows )
    • Win32_ComputerSystem
      • Name

 

Environment Variables

Get-ChildItem Env:

Syntax


pwsh -Command "Get-Childitem Env:"

Output

Get-ChildItem.Env.20181112.0729PM

 

Get-ChildItem Env:HOSTNAME

Syntax


pwsh -Command "Write-Host( (Get-ChildItem Env:HOSTNAME).Value )"

Output

Get-ChildItem.Env.HostName.20181112.0723PM

system.environment

machineName

Syntax


pwsh -Command "Write-Host([system.environment]::machineName)"

Output

system.environment.machineName.20181112.0708PM

system.net.Dns

GetHostName

Syntax


pwsh -Command "Write-Host([system.net.Dns]::GetHostName())

Output

system.net.Dns.GetHostName.20181112.0706PM

 

Get-WmiObject.Win32_ComputerSystem.Name.20181113.0159AM.PNG

Win32_ComputerSystem

Syntax


powershell -Command "Write-Host((Get-WmiObject Win32_ComputerSystem).Name)"

Output

OS – MS Windows

Get-WmiObject.Win32_ComputerSystem.Name.20181113.0159AM.PNG

OS – Linux

Image

Get-WmiObject.Win32_ComputerSystem.Name.Linux.20181113.0203AM

Textual


>pwsh -Command "Write-Host( Write-Host((Get-WmiObject Win32_ComputerSystem).Name))"
Get-WmiObject : The term 'Get-WmiObject' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:25
+ Write-Host( Write-Host((Get-WmiObject Win32_ComputerSystem).Name))
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-WmiObject:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException