3.3 Changing the DNS Name or DNS Name and the IP Address of a Primary Server after Installing ZENworks

If you want to change only the DNS name or if you want to change both the IP address and DNS name of the Primary Server after installing ZENworks, and if the certificate’s CN has fully qualified DNS configured, use the following steps to change only the DNS name or to change both the IP address and DNS name of the Primary Server.

The following two scenarios are supported:

3.3.1 Zone configured with external certificate

  1. Take a reliable backup of the following on all the Primary Servers in the Management Zone:

  2. Change the DNS name or the DNS name and IP address.

  3. If the database is located on the Primary Server whose IP address you changed in Step 2.

    1. Change the database server address on all the second Primary Servers. On all the second Primary Servers, change the value of database server address in the ZENworks_Installation_Directory\microfocus\ZENworks\conf\datamodel\zdm.xml to point to the new IP address of the first Primary Server.

    2. Change the audit database server address on all the second Primary Servers. On all the second Primary Servers, change the value of audit database server address in the ZENworks_Installation_Directory\microfocus\ZENworks\conf\datamodel\zenaudit.xml to point to the new IP address of the first Primary Server.

  4. Run the microfocus-zenworks-configure -c GenerateOSPProperties configure action.

  5. (Conditional) If ZooKeeper or Kafka is configured

    1. Update database with new DNS. For more information, see SQL Query for Updating DNS in the Database.

    2. Update ZooKeeper or/and Kafka properties files with new DNS using shell script or bat file on Primary Servers. For more information on running script, see Creating the Replace DNS Script.

    NOTE:To know if ZooKeeper, Kafka or Vertica is configured, run the following query:

    select d.zuid, d.hostname, r.roles from zzenserverroles r, zdevice d where r.id = d.zuid and r.roles in ('ZooKeeper', 'Kafka', 'Vertica')

  6. (Conditional) If Vertica is configured, update zenvertica.xml with new DNS using shell script or bat file on all primary servers.

  7. (Conditional) On a Linux Primary Server, you need to remove the Docker container for the modified hostname to take effect. To remove the container:

    1. Stop all ZENworks services.

    2. Remove the docker containers using the command docker container prune -f.

    3. Restart all ZENworks services.

  8. Remint the server certificate. For information, see Reminting Server Certificates in the ZENworks SSL Management Reference.

  9. (Conditional) If Multizone is configured with this server (whose IP address and DNS name is changed) as Publisher, then after replacing the First Primary Server with the Second Primary Server, update the new IP address and DNS name of this server for all its Subscribers. Perform the following to update the new IP address and DNS name:

    1. Log in to ZENworks Control Center (ZCC) of subscribers.

    2. Navigate to Subscribe And Share > Subscriptions > <subscription_name> > Remote Server > Base URL>Edit.

    3. Update the IP address or Hostname with new IP address or Hostname of the Primary Server (Publisher).

  10. To update the new certificate:

    1. Navigate to Subscribe And Share > Subscriptions > <subscription_name> > Remote Server > Update Certificate.

    2. Update the certificate.

3.3.2 Zone configured with internal certificate

If you want to change only the DNS name or if you want to change both the IP address and the DNS name of the Primary Server after installing ZENworks 2020, and if the certificates CN has fully qualified DNS configured, perform the following steps to change only the DNS name or to change both the IP address and the DNS name of the Primary Server.

  1. Take a reliable backup of the following on all the Primary Servers in the Management Zone:

  2. Change the DNS name or the DNS name and IP address.

  3. If the database is located on the Primary Server whose IP address you changed.

    1. Change the database server address on all the second Primary Servers. On all the second Primary Servers, change the value of database server address in the ZENworks_Installation_Directory\microfocus\ZENworks\conf\datamodel\zdm.xml to point to the new IP address of the first Primary Server.

    2. Change the audit database server address on all the second Primary Servers. On all the second Primary Servers, change the value of audit database server address in the ZENworks_Installation_Directory\microfocus\ZENworks\conf\datamodel\zenaudit.xml to point to the new IP address of the first Primary Server.

  4. Run the microfocus-zenworks-configure -c GenerateOSPProperties configure action.

  5. (Conditional) If ZooKeeper or kafka is configured

    1. Update database with new DNS. For more information, see SQL Query for Updating DNS in the Database.

    2. Update ZooKeeper or/and Kafka properties files with new DNS using shell script or bat file on Primary Servers. For more information, see Creating the Replace DNS Script.

    NOTE:To know if ZooKeeper, Kafka or Vertica is configured, run the following query:

    select d.zuid, d.hostname, r.roles from zzenserverroles r, zdevice d where r.id = d.zuid and r.roles in ('ZooKeeper', 'Kafka', 'Vertica')

  6. (Conditional) On a Linux Primary Server, you need to remove the Docker container for the modified hostname to take effect. To remove the container:

    1. Stop all ZENworks services.

    2. Remove the docker containers using the command docker container prune -f.

    3. Restart all ZENworks services.

  7. (Conditional) If Vertica is configured, update zenvertica.xml with new DNS using shell script or bat file on all Primary Servers.

  8. Remint the server certificate. For information, see Reminting Server Certificates in the ZENworks SSL Management Reference.

  9. (Conditional) If your zone includes Intel AMT devices, unprovision and provision the devices.

    For more information about unprovisioning and provisioning Intel AMT devices, see Introducing Intel Active Management Technology in the ZENworks Out-of-Band Management Reference.

  10. (Conditional) If Multizone is configured with this server (whose IP address and DNS name is changed) as Publisher, then after replacing the First Primary Server with the Second Primary Server, update the new IP address and DNS name of this server for all its Subscribers. Perform the following to update the new IP address and DNS name:

    1. Log in to ZENworks Control Center (ZCC) of subscribers.

    2. Navigate to Subscribe And Share > Subscriptions > <subscription_name> > Remote Server > Base URL>Edit.

    3. Update the IP address or Hostname with new IP address or Hostname of the Primary Server (Publisher).

  11. To update the new certificate:

    1. Navigate to Subscribe And Share > Subscriptions > <subscription_name> > Remote Server > Update Certificate.

    2. Update the certificate.

Creating the Replace DNS Script

The following script replaces the old DNS with the new DNS. Ensure that you update the parameters accordingly and then run the script file.

Windows Script (.bat)

Create a .bat file and add the following content.

@echo off

set "oldDNS=PutOldDnsHere"
set "newDNS=PutNewDnsHere"

setlocal EnableExtensions EnableDelayedExpansion
set "SOURCEFILE=<ZENworks_Installation_Directory>\Micro Focus\ZENworks\conf\zookeeper.properties"
set "TEMPFILE=test_out.txt"

for /f "delims=" %%A in ('type "%SOURCEFILE%"') do (
    set "string=%%A"
    set "modified=!string:%oldDNS%=%newDNS%!"
    echo !modified!>>"%TEMPFILE%"
)

del "%SOURCEFILE%"
move "%TEMPFILE%" "%SOURCEFILE%"
endlocal

After creating the script file, update the PutOldDnsHere and PutNewDnsHere, and then execute the bat file.

Linux Script (.sh)

Create a .sh file and then add the following content.

#!/bin/bash
oldDns=PutOldDnsHere;
newDns=PutNewDnsHere;

echo $oldDns
echo $newDns

#zookeeper.properties
file=/etc/opt/microfocus/zenworks/zookeeper.properties
if test -f $file; then
    sed -i "s/$oldDns/$newDns/" $file
fi

# kafka-service-config.properties
file=/etc/opt/microfocus/zenworks/kafka-service-config.properties
if test -f $file; then
    sed -i "s/$oldDns/$newDns/" $file
fi

#kafka.properties
file=/etc/opt/microfocus/zenworks/kafka/zenworks-kafka-server.properties
if test -f $file; then
    sed -i "s/$oldDns/$newDns/" $file
fi

# schema-registry.properties 
file=/etc/opt/microfocus/zenworks/kafka/zenworks-schema-registry.properties
if test -f $file; then
    sed -i "s/$oldDns/$newDns/" $file
fi

# kafka-connect.properties
file=/etc/opt/microfocus/zenworks/kafka/zenworks-connect-avro-distributed.properties
if test -f $file; then
    sed -i "s/$oldDns/$newDns/" $file
fi

# vertica-datamodel
file=/etc/opt/microfocus/zenworks/datamodel/zenvertica.xml
if test -f $file; then
    sed -i "s/$oldDns/$newDns/" $file
fi

After creating the script file, update the PutOldDnsHere and PutNewDnsHere, and then execute the script file.

SQL Query for Updating DNS in the Database

Depending on the database configured in the zone, ensure that you run the following SQL query to update the DNS in the database.

PostgreSQL Query

CREATE OR REPLACE FUNCTION replaceDNS(guid character varying,oldDns character varying, newDns character varying  )
RETURNS void AS 
$$ 
DECLARE 
  actualValue varchar(1024);
  updatedValue varchar(1024);
  guidAsBytea bytea;
BEGIN
 select decode(guid, 'hex') into guidAsBytea;
 raise notice '%', guidAsBytea;
 select  data into actualValue from zzenserverroles where id=guidAsBytea and roles = 'ZooKeeper';     
 raise notice '%', actualValue;
 updatedValue := REPLACE(actualValue, oldDns, newDns );
 raise notice '%', updatedValue;
 update zzenserverroles set data=updatedValue where id=guidAsBytea and roles = 'ZooKeeper';
 
 -- update zopaquedata for kafka cluster 
 IF EXISTS (select 1 from zopaquedata where name = 'kafka.cluster.config')  THEN    
   select data into actualValue from zopaquedata where name = 'kafka.cluster.config';     
   raise notice '%', actualValue;
   updatedValue := REPLACE(actualValue, oldDns, newDns );
   raise notice '%', updatedValue;
   update zopaquedata set data=updatedValue where name = 'kafka.cluster.config';
 END IF;
END;
$$ 
LANGUAGE plpgsql; -- language specification
Execute function/procedures in the database, for postgresql to run the following function:
select replaceDNS(server_guid, oldDns ,newDns);

Example:

select replaceDNS('c79de1490818e00f55c82cd6b28e157c', 'oldDns.novell.com','newDns.microfocus.com');

MS SQL Query

CREATE PROCEDURE replaceDNS @guid  nvarchar(100),@oldDns nvarchar(1024), @newDns  nvarchar(1024) 
AS 
BEGIN
  declare @actualValue nvarchar(1024), @updatedValue nvarchar(1024);
  select  @actualValue=data from zzenserverroles where id=@guid and roles = 'ZooKeeper';     
  print 'Actual value: ' + @actualValue;
  set @updatedValue = REPLACE(@actualValue, @oldDns, @newDns );
  print 'update value: ' + @updatedValue;
  update zzenserverroles set data=@updatedValue where id=@guid and roles = 'ZooKeeper';

  -- update zopaquedata for kafka cluster 
  IF EXISTS (select 1 from zopaquedata where name = 'kafka.cluster.config')   
  BEGIN
   select  @actualValue=data from zopaquedata where name = 'kafka.cluster.config';     
   print 'Actual value: ' + @actualValue;
   set @updatedValue = REPLACE(@actualValue, @oldDns, @newDns );
   print 'update value: ' + @updatedValue;
   update zopaquedata set data=@updatedValue where name = 'kafka.cluster.config';
  END
END;
Execute function/procedures in the database, for MS SQL to run the following function:
exec replaceDNS guid, oldDns, newDns

Example:

exec replaceDNS 0xc79de1490818e00f55c82cd6b28e157c, 'oldDns.novell.com','newDns.microfocus.com';

Oracle Query

CREATE OR REPLACE PROCEDURE replaceDNS(guid in varchar2,oldDns in varchar2, newDns in varchar2  )
as
 actualValue varchar2(1024);
 updatedValue varchar2(1024);
 BEGIN
 
   select data into actualValue from zzenserverroles where id=guid and roles = 'ZooKeeper';     
   dbms_output.put_line('Actual value: ' || actualValue);
   updatedValue := REPLACE(actualValue, oldDns, newDns );
   dbms_output.put_line('update value: ' || updatedValue);
   update zzenserverroles set data=updatedValue where id=guid and roles = 'ZooKeeper';
   
   -- update zopaquedata for kafka cluster 
   BEGIN
     select data into actualValue from zopaquedata where name = 'kafka.cluster.config';     
     dbms_output.put_line('Actual value: ' || actualValue);
     updatedValue := REPLACE(actualValue, oldDns, newDns );
     dbms_output.put_line('update value: ' || updatedValue);
     update zopaquedata set data=updatedValue where name = 'kafka.cluster.config';
   EXCEPTION 
    WHEN NO_DATA_FOUND THEN
      NULL;
   END;
 END;
Execute function/procedures in the database, for Oracle to run the following function:
select replaceDNS (guid, oldDns, newDns)

Example:

select replaceDNS('C79DE1490818E00F55C82CD6B28E157C', 'oldDns.novell.com' ,'newDns.microfocus.com');