Community Articles

Find and share helpful community-sourced technical articles.
avatar
Rising Star

In a previous article, I realized that I saved my flow as a flow file instead of a template, which may make it hard to import for some.

 

So in this article, I will explain how to import a flow to NiFi registry in Datahub (knowing that NiFi registry is secure by default in CDP Datahub).

Step 1: Download and configure stores

Connect to one of the NiFi machines with the Cloudbreak user and the key you used at deployment:

 

$ ssh -i [path_to_private_key] cloudbreak@[your_nifi_host]​​​

 

Next, copy and authorize the key and trust stores:

 

$ sudo su
$ cp /var/lib/cloudera-scm-agent/agent-cert/cm-auto-host_keystore.jks /tmp
$ cp /var/lib/cloudera-scm-agent/agent-cert/cm-auto-global_truststore.jks /tmp
$ chmod a+rw /tmp/cm-auto-host_keystore.jks
$ chmod a+rw /tmp/cm-auto-global_truststore.jks​​

 

Step 2: Create a registry.properties file

Go to /tmp (for instance) and create the following file - registry.properties file:

 

baseUrl=https://fod-nifi-cluster-gateway0.fod-cdp.a465-9q4k.cloudera.site:18433
keystore=/tmp/cm-auto-host_keystore.jks
keystoreType=JKS
keystorePasswd=[YOUR_KEYSTORE_PWD]
keyPasswd=[YOUR_KEYSTORE_PWD]
truststore=/tmp/cm-auto-global_truststore.jks
truststoreType=JKS
truststorePasswd=[YOUR_TRUSTSTORE_PWD]
proxiedEntity=[YOUR_USER_AUTHORIZED_IN_RANGER]​

 

Notes:

  • I'm not going to expose the method to get your password for keystore and truststore 
  • It is important that you add a proxied entity with your workload user that is authorized in ranger to use the registry (find your user in the CDP management console)

Next, download the flow you want to import, for instance:

 

wget https://raw.githubusercontent.com/paulvid/datasets/master/hybrid-demo/nifi-flow/NiFi_Flow.json​

 

Step 3: Run the import

Run these command lines:

 

$ /opt/cloudera/parcels/CFM-2.0.6.0/TOOLKIT/bin/cli.sh

 Apache   (_)  .' ..](_)   ,
 _ .--.   __  _| |_  __    )\
[ `.-. | [  |'-| |-'[  |  /  \
|  | | |  | |  | |   | | '    '
[___||__][___][___] [___]',  ,'
                           `'
          CLI v1.11.4.2.0.6.0-27

Type 'help' to see a list of available commands, use tab to auto-complete.


Session loaded from /home/pvidal/.nifi-cli.config


#> registry create-bucket -p registry.properties --bucketName hybrid-cloud

dfc33699-0317-4893-82c4-8a12ad6ed822

#> registry create-flow -p registry.properties -b dfc33699-0317-4893-82c4-8a12ad6ed822 -fn hybridflow

8d2e7f87-f176-4f34-9788-72be034e4a3f

#> registry import-flow-version -p registry.properties -f 8d2e7f87-f176-4f34-9788-72be034e4a3f -i NiFi_Flow.json

1

#> exit                                                                                                         

 

Step 4: Import the flow in the UI

  1. Navigate to the NiFi UI, and add a processor group. Then, click Import:
    Screen Shot 2020-12-23 at 10.02.16 AM.png
  2. Select the bucket and flow we just imported using CLI:
    Screen Shot 2020-12-23 at 10.02.29 AM.png
  3. After clicking Import, your flow is successfully available!
    Screen Shot 2020-12-23 at 10.02.40 AM.png
4,289 Views