BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Nigel_Pain
Lapis Lazuli | Level 10

SAS 9.4M7 on four Windows Server 2019 platforms (metadata, compute, mid-tier, LASR)

 

Does anyone know a way to test from a Windows Powershell command whether the metadata server is started? After applying Windows Updates on our servers they are scheduled to reboot overnight. However, the metadata server is taking significantly longer to restart than the other three and so any SAS services on the other servers which rely on the metadata server are failing to start. I have Powershell scripts on all the servers to start all the SAS services but some won't start properly if there's no metadata (crucially, Object Spawners). So I wanted them to check for the metadata before continuing. The scripts are run by Windows Task Scheduler as internal System accounts so they can't use WMI or CIM to check the metadata service.

Of course, I could simply delay the restarts to a time when the metadata server should have restarted but that has the possibility of failing too if it's not given long enough.

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
gwootton
SAS Super FREQ
You could use Test-NetConnection to see if the server is listening on the port. e.g.
$rc = Test-NetConnection meta.example.com -port 8561
if ($rc.TcpTestSucceeded) {
echo "Metadata Server Up"
}
You could build this logic into a loop that checks every few seconds and then exits the loop or fails after your max wait time has passed.
--
Greg Wootton | Principal Systems Technical Support Engineer

View solution in original post

7 REPLIES 7
carl_sommer
SAS Employee

I think you could run a batch SAS program that does the following:

  • set the metadata options
  • make sure a semaphore file (for example /opt/sas/ServerIsReady) does not exist
  • define a macro to do the following:
    • PROC METAOPERATE ACTION=STATUS OUT=WORK.STATOUT; RUN;
    • Data step to read WORK.STATOUT
      • if it exists and things look good, create /opt/sas/ServerIsReady
      • Otherwise, sleep a minute and then jump to the top of the macro again
      • Keep track of how many times this jump happens - after 10 tries (or whatever number is acceptable to you) you probably want to abort and toss an error (maybe create /opt/sas/ServerWillNotStart)

Your powershell script could run this batch SAS program, and then wait until it finishes and look for the signal files and proceed accordingly.

 

Carl Sommer

 

gwootton
SAS Super FREQ
You could use Test-NetConnection to see if the server is listening on the port. e.g.
$rc = Test-NetConnection meta.example.com -port 8561
if ($rc.TcpTestSucceeded) {
echo "Metadata Server Up"
}
You could build this logic into a loop that checks every few seconds and then exits the loop or fails after your max wait time has passed.
--
Greg Wootton | Principal Systems Technical Support Engineer
carl_sommer
SAS Employee
I really like this solution better than mine.
Nigel_Pain
Lapis Lazuli | Level 10

This looks exactly like what I was wanting. But will it test whether there is a response on the port, or just whether the port is open?

gwootton
SAS Super FREQ
The TcpTestSucceeded means that it successfully established a TCP session which will only occur if both the port is open and a process is listening on that port (though not necessarily a Metadata Server).
--
Greg Wootton | Principal Systems Technical Support Engineer
carl_sommer
SAS Employee

If you really wanted to ensure that you were talking to a functional metadata server, then  you would want to pursue the PROC METADATA approach.   That's more code and coordination than the command @gwootton suggested.

 

Carl 

Nigel_Pain
Lapis Lazuli | Level 10

That answers my question. I'll give it a try. I don't think there's any data of anything else listening on port 8561. Thanks Greg (and Carl).

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

Get Started with SAS Information Catalog in SAS Viya

SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 1848 views
  • 0 likes
  • 3 in conversation