NIFI: Grant All Access to Initial Admin User

—

—

NIFI: Grant All Access to Initial Admin User

Following document shows how to use NIFI API to grant super Admin (ALL) access to initial admin user

As we need to process lot json input/output through bash we are going to use jq tool.

Use the following to install jq https://stedolan.github.io/jq/

Steps needed

  • Generate NIFI token and save
export NIFI_API_URL=https://$(hostname -f):9443/nifi-api
export NIFI_ADMIN_USER=<YOUR_NIFI_ADMIN_ID>
export NIFI_ADMIN_PASSWORD=<YOUR_NIFI_ADMIN_PASSWORD>
export NIFI_ADMIN_TOKEN=$(curl -k ${NIFI_API_URL}/access/token -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \  
 --data "username=${NIFI_ADMIN_USER}&password=${NIFI_ADMIN_PASSWORD})"
  • Get NiFI root process ID
url=${NIFI_API_URL}/flow/process-groups/root
export ROOT_PROCESS_ID=$(curl -k -H "Authorization: Bearer ${NIFI_ADMIN_TOKEN}" $url |jq -r '.processGroupFlow.id')
  • Create initial user List Json
export url=${NIFI_API_URL}/tenants/users
curl -k -H "Authorization: Bearer ${NIFI_ADMIN_TOKEN}" $url |jq -r '.users[].id' > /tmp/initial-user-list.txt  
${jq} -R '.' /tmp/initial-user-list.txt|${jq} -s '{"revision": {"version": 0},"component":{"identity": "superadmin",users:map({id:.})}}' >> /tmp/initial-user-groups-list.json  

  • Create Group
export groupId=$(curl -k -H "Authorization: Bearer ${NIFI_ADMIN_TOKEN}" -X POST  -H "content-type:application/json"   ${NIFI_API_URL}/tenants/user-groups \  
-d "@/tmp/initial-user-groups-list.json"|jq -r '.id')
  • Add a function to create Root policy
create_root_policy(){  
  
  local url=${NIFI_API_URL}/policies  
  
  
    local groupId=${1}  
    local action=${2} #example : action="read" OR action="write"  
  local resource=${3} #example : resource="/provenance-data"  
  kurl -k -H "Authorization: Bearer ${NIFI_ADMIN_TOKEN}" -X POST  -H "content-type:application/json" $url -d \  
        '{  
 "revision": { "version": 0 }, "component": { "action": "'${action}'",  
 "resource": "'${resource}'/process-groups/'${ROOT_PROCESS_ID}'",  
 "users": [], "userGroups": [ { "id": "'${groupId}'",  
 "permissions": { "canRead": true, "canWrite": true } } ] } }'  
}
  • Create all policies
create_root_policy ${superAdmingroupId} "read"  
create_root_policy ${superAdmingroupId} "write"  
create_root_policy ${superAdmingroupId} "read" "/provenance-data"  
create_root_policy ${superAdmingroupId} "write" "/provenance-data"  
create_root_policy ${superAdmingroupId} "read" "/data"  
create_root_policy ${superAdmingroupId} "write" "/data"  
create_root_policy ${superAdmingroupId} "read" "/policies"  
create_root_policy ${superAdmingroupId} "write" "/policies"

At this point if you login to NIFI web ui, with Initial admin id, you should have all access.

Secure your CDH Cloudera server with Kerberos – Part 3

—

—

COMING SOON…

Part -1 we installed and configured Cloudera Manager and configure repository from command line.
Part -2 we installed and configure a CDH services using CM API.
Part -3 will cover installation of MIT Kerberos and Configuration of

  • Part -1 Install Cloudera Manager (cluster) like a boss.
  • Part -2 Add services and Configure CDH using API
  • Part -3 Secure your CDH Cloudera server with Kerberos
  • Part -4 Configure TLS Encryption on CDH services
Sample code block

{: #code-example-1}

Automate your Hadoop Cluster (CDH) – Part 2

Automate your Hadoop Cluster (CDH) – Part 2

Automate your Hadoop Cluster (CDH) – Part 2

Our Part -1 goal was to install and configure a Cloudera Manager and configure repository from command line.

Our Part -2 goal is to install and configure a CDH services using CM API.

  • Part -1 Install Cloudera Manager (cluster) like a boss.
  • ** Part -2 Add services and Configure CDH using API **
  • Part -2 Secure your CDH Cloudera server with Kerberos
  • Part -3 Configure TLS Encryption on CDH services

Create CDH Services Using API

  • Install jq tools

    jq is great tool to parse and json documents using unix shell. We will use jq tools to create json contents

    For more information on jq can be read at

    https://stedolan.github.io/jq

    Use the following command to install jq

sudo yum install epel-release
sudo yum install jq
  • Start Trial
basicauth=admin:admin
apiURL=http://$(hostname -f):7180/api/v19
curl -i -X POST -u "${basicauth}"  ${apiURL}/cm/trial/begin
  • Register all Data node hosts with Cloudera Manager
basicauth=admin:admin 
apiURL=http://$(hostname -f):7180/api/v19

export DATA_NODE_HOSTS='"data-1.example.com", "data-2.example.com", "data-2.example.com"'
PRIVATE_KEY=$(sed 's/$/\\n/' ~cloudera/.ssh/id_rsa | paste -sd '' -)
echo '{ "hostNames": ['${DATA_NODE_HOSTS}'],  
 "userName" : "cloudera", "privateKey":"'$PRIVATE_KEY'",  
 "unlimitedJCE":"true", "javaInstallStrategy":"NONE" }' > /tmp/hostInstall.json

curl -i -X POST -u "${basicauth}" -H "content-type:application/json" -d @'/tmp/hostInstall.json'    ${apiURL}/cm/commands/hostInstall

Response should look like

HTTP/1.1 200 OK
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Set-Cookie: CLOUDERA_MANAGER_SESSIONID=7j26djm83ly1usy2rl2sbj89;Path=/;HttpOnly
Content-Type: application/json
Date: Sat, 22 Dec 2018 19:23:05 GMT
Transfer-Encoding: chunked
Server: Jetty(6.1.26.cloudera.4)

{
  "id" : 12,
  "name" : "GlobalHostInstall",
  "startTime" : "2018-12-22T19:23:05.009Z",
  "active" : true,
  "children" : {
    "items" : [ ]
  }
}
  • Check for Installed hosts
basicauth=admin:admin 
apiURL=http://$(hostname -f):7180/api/v19

curl -i -X GET -u "${basicauth}" -H "content-type:application/json"     ${apiURL}/hosts |grep "hostname"

Wait until all hosts are installed.

  • Install Cloudera Management Service
export basicauth=admin:admin
export apiURL=http://$(hostname -f):7180/api/v19
export POSTGRES_SERVER=cm.example.com
curl -i -X PUT -u "${basicauth}" -i -H "content-type:application/json" -d '{ "name": "mgmt" ,"displayName":"Cloudere Management Service"}' ${apiURL}/cm/service
curl -i -X PUT -u "${basicauth}" ${apiURL}/cm/service/autoAssignRoles  
curl -i -X PUT -u "${basicauth}" ${apiURL}/cm/service/autoConfigure

curl -u "${basicauth}" \  
-H "Content-Type: application/json" \  
-X POST \  
--data '{}' \  
${apiURL}/cm/service/commands/restart
  • Configure reporting database
curl -i -X PUT -u "${basicauth}"  \
      -H "content-type:application/json" \
      -d '{ "items": [{"name": "headlamp_database_host",     "value": "'${POSTGRES_SERVER}'"},
                      {"name": "headlamp_database_name",     "value": "reportman"},
                      {"name": "headlamp_database_password", "value": "averycomplexpassword"},
                      {"name": "headlamp_database_user",     "value": "reportman"},
                      {"name": "headlamp_database_type",     "value": "postgresql"}
          ]}'  \
    ${apiURL}/cm/service/roleConfigGroups/mgmt-REPORTSMANAGER-BASE/config
  • Delete Navigator Entry
curl -X DELETE -u "${basicauth}"  \
    ${apiURL}/cm/service/roles/$(curl -sS -X GET -u "${basicauth}"  ${apiURL}/cm/service/roles | grep -B1 '"type" : "NAVIGATORMETASERVER"' | grep name | cut -d'"' -f4)

curl -X DELETE -u "${basicauth}"  \
    ${apiURL}/cm/service/roles/$(curl -sS -X GET -u "${basicauth}"  ${apiURL}/cm/service/roles | grep -B1 '"type" : "NAVIGATOR"' | grep name | cut -d'"' -f4)

  • Create Service cluster and add hosts
export clusterName=cdhcluster-01
curl -X POST -u "${basicauth}"  \
      -H "content-type:application/json" \
      -d '{ "items": [
              {
                "name": "'${clusterName}'",
                "version": "CDH5",
                "fullVersion":"5.13.1"
              }
          ] }'  \
 ${apiURL}/clusters

# Add hosts 
hostIds=$(curl -sS -X GET -u ${basicauth}  ${apiURL}/hosts |grep "hostId" | cut -d'"' -f4)
for hostid in ${hostIds};do
   curl -X POST -u "${basicauth}"  \
    -H 'content-type:application/json' \
    -d '{ "items": [ {"hostId": "'${hostid}'"} ]}'  \
  ${apiURL}/clusters/${clusterName}/hosts
done  
  • Distribute CDH Parcel
# define a function
wait_for_parcel () {
  wait_for=$1
  service=$2
  version=$3
  while [ 1 ]
  do
    curl -sS -X GET -u "${basicauth}"  ${apiURL}/clusters/${clusterName}/parcels/products/$service/versions/$version | grep '"stage" : "'$wait_for'"' && break
    sleep 5
  done
}
# Distribute parcel
service=CDH
PARCEL_VERSION=5.13.1-1.cdh5.13.1.p0.2
curl -i -X POST -u "${basicauth}"  ${apiURL}/clusters/${clusterName}/parcels/products/${service}/versions/${PARCEL_VERSION}/commands/startDistribution
# Check Status until DISTRIBUTED
wait_for_parcel DISTRIBUTED ${service} ${PARCEL_VERSION}
# Activate 
curl -i -X POST -u "${basicauth}"  ${apiURL}/clusters/${clusterName}/parcels/products/${service}/versions/${PARCEL_VERSION}/commands/activate
wait_for_parcel ACTIVATED $service $PARCEL_VERSION
  • Distribute KAFKA Parcel
# define a function
wait_for_parcel () {
  wait_for=$1
  service=$2
  version=$3
  while [ 1 ]
  do
    curl -sS -X GET -u "${basicauth}"  ${apiURL}/clusters/${clusterName}/parcels/products/$service/versions/$version | grep '"stage" : "'$wait_for'"' && break
    sleep 5
  done
}
# Distribute parcel
service=KAFKA
PARCEL_VERSION=3.1.0-1.3.1.0.p0.35
curl -i -X POST -u "${basicauth}"  ${apiURL}/clusters/${clusterName}/parcels/products/${service}/versions/${PARCEL_VERSION}/commands/startDistribution
# Check Status until DISTRIBUTED
wait_for_parcel DISTRIBUTED ${service} ${PARCEL_VERSION}
# Activate 
curl -i -X POST -u "${basicauth}"  ${apiURL}/clusters/${clusterName}/parcels/products/${service}/versions/${PARCEL_VERSION}/commands/activate
wait_for_parcel ACTIVATED $service $PARCEL_VERSION
  • Create CDH Services
export basicauth=admin:admin
export apiURL=http://$(hostname -f):7180/api/v19
export clusterName=cdhcluster-01

curl -X POST -u "${basicauth}" \
-H "content-type:application/json" \
-d '{ "items": [  {"name": "zookeeper", "type": "ZOOKEEPER","displayName":"Zookeeper"}, {"name": "yarn", "type": "YARN","displayName":"YARN (MR2 Included)"}, {"name": "hdfs", "type": "HDFS","displayName":"HDFS"}, {"name": "kafka", "type": "KAFKA","displayName":"Kafka"}, {"name": "hbase", "type": "HBASE","displayName":"HBase"} ] }' \
${apiURL}/clusters/${clusterName}/services

Configure CDH Services Using API

  • HDFS
curl -i -u "${basicauth}" \
      -H "Content-Type: application/json" -i \
      -X PUT \
      --data '{
          "items" : [ {
            "name" : "zookeeper_service",
            "value" : "zookeeper",
            "sensitive" : false
          } ]
        }' \
${apiURL}/clusters/${clusterName}/services/hdfs/config
  • YARN
curl -i -u "${basicauth}" \
     -H "Content-Type: application/json" -i \
     -X PUT \
     --data '{
        "items" : [ {
          "name" : "hdfs_service",
          "value" : "hdfs",
          "sensitive" : false
        }, {
          "name" : "zookeeper_service",
          "value" : "zookeeper",
          "sensitive" : false
        } ]
      }' \
${apiURL}/clusters/${clusterName}/services/yarn/config
  • KAFKA
curl -i -u "${basicauth}" \
     -H "Content-Type: application/json" -i \
     -X PUT \
     --data '{
         "items" : [ {
           "name" : "zookeeper_service",
           "value" : "zookeeper",
           "sensitive" : false
         } ]
       }' \
${apiURL}/clusters/${clusterName}/services/kafka/config
  • HBASE
curl -i -u "${basicauth}" \
     -H "Content-Type: application/json" -i \
     -X PUT \
     --data '{
        "items" : [ {
          "name" : "hdfs_service",
          "value" : "hdfs",
          "sensitive" : false
        }, {
          "name" : "zookeeper_service",
          "value" : "zookeeper",
          "sensitive" : false
        } ]
      }' \
${apiURL}/clusters/${clusterName}/services/hbase/config

Create CDH services Roles

  • Generate hostIds
export basicauth=admin:admin
export apiURL=http://$(hostname -f):7180/api/v19
export clusterName=cdhcluster-01
# save Cloudera host id's for all data node
curl -X GET -u ${basicauth} ${apiURL}/hosts |jq -r '.items[].hostId'  > /tmp/all-hosts-id.txt
# save Cloudera host id's for first  node
# this will be used to configure NODEMAnaGER
curl -X GET -u admin:admin http://$(hostname -f):7180/api/v19/hosts |jq -r '.items[0].hostId' > /tmp/hosts-id-1.txt
  • configure zookeeper roles
export serviceName="zookeeper"  
export roleType="SERVER"
jq -R '.' /tmp/all-hosts-id.txt | jq -s '{items:map({type:"'$roleType'",hostRef:{hostId:.}})}' > /tmp/items-json-${serviceName}-${roleType}.txt
curl -i -X POST -u "${basicauth}" ${apiURL}/clusters/${clusterName}/services/${serviceName}/roles  -H "content-type:application/json" -d  @/tmp/items-json-${serviceName}-${roleType}.txt
  • configure hdfs roles
export serviceName="hdfs"  
export roleTypes="NAMENODE SECONDARYNAMENODE BALANCER"
for roleType in ${roleTypes};do
   jq -R '.' /tmp/hosts-id-1.txt | jq -s '{items:map({type:"'$roleType'",hostRef:{hostId:.}})}' > /tmp/items-json-${serviceName}-${roleType}.txt
   curl -i -X POST -u "${basicauth}" ${apiURL}/clusters/${clusterName}/services/${serviceName}/roles  -H "content-type:application/json" -d  @/tmp/items-json-${serviceName}-${roleType}.txt
done

export roleTypes="DATANODE"
for roleType in ${roleTypes};do
   jq -R '.' /tmp/all-hosts-id.txt | jq -s '{items:map({type:"'$roleType'",hostRef:{hostId:.}})}' > /tmp/items-json-${serviceName}-${roleType}.txt
   curl -i -X POST -u "${basicauth}" ${apiURL}/clusters/${clusterName}/services/${serviceName}/roles  -H "content-type:application/json" -d  @/tmp/items-json-${serviceName}-${roleType}.txt
done
  • configure hdfs directories
curl -i -u "${basicauth}" \
      -H "Content-Type: application/json" -i \
      -X PUT \
      --data '{
              "items" : [ {
                 "name" : "dfs_name_dir_list",
                 "value" : "/dfs/nn",
                 "sensitive" : false
              }  ]
            }' \
${apiURL}/clusters/${clusterName}/services/hdfs/roleConfigGroups/hdfs-NAMENODE-BASE/config

curl -i -u "${basicauth}" \
      -H "Content-Type: application/json" -i \
      -X PUT \
      --data '{
          "items" : [ {
             "name" : "fs_checkpoint_dir_list",
             "value" : "/dfs/snn",
             "sensitive" : false
          }
          ]
        }
        ' \
${apiURL}/clusters/${clusterName}/services/hdfs/roleConfigGroups/hdfs-SECONDARYNAMENODE-BASE/config
curl -i -u "${basicauth}" \
      -H "Content-Type: application/json" -i \
      -X PUT \
      --data '{
          "items" : [ {
            "name" : "dfs_data_dir_list",
            "value" : "/dfs/dn",
            "sensitive" : false
          }
          ]
        }' \
${apiURL}/clusters/${clusterName}/services/hdfs/roleConfigGroups/hdfs-DATANODE-BASE/config


  • configure hbase roles
export serviceName="hbase"  
export roleTypes="MASTER"
for roleType in ${roleTypes};do
   jq -R '.' /tmp/hosts-id-1.txt | jq -s '{items:map({type:"'$roleType'",hostRef:{hostId:.}})}' > /tmp/items-json-${serviceName}-${roleType}.txt
   curl -i -X POST -u "${basicauth}" ${apiURL}/clusters/${clusterName}/services/${serviceName}/roles  -H "content-type:application/json" -d  @/tmp/items-json-${serviceName}-${roleType}.txt
done

export roleTypes="REGIONSERVER"
for roleType in ${roleTypes};do
   jq -R '.' /tmp/all-hosts-id.txt | jq -s '{items:map({type:"'$roleType'",hostRef:{hostId:.}})}' > /tmp/items-json-${serviceName}-${roleType}.txt
   curl -i -X POST -u "${basicauth}" ${apiURL}/clusters/${clusterName}/services/${serviceName}/roles  -H "content-type:application/json" -d  @/tmp/items-json-${serviceName}-${roleType}.txt
done
  • configure yarn roles
export serviceName="yarn"  
export roleTypes="NODEMANAGER RESOURCEMANAGER JOBHISTORY"
for roleType in ${roleTypes};do
   jq -R '.' /tmp/hosts-id-1.txt | jq -s '{items:map({type:"'$roleType'",hostRef:{hostId:.}})}' > /tmp/items-json-${serviceName}-${roleType}.txt
   curl -i -X POST -u "${basicauth}" ${apiURL}/clusters/${clusterName}/services/${serviceName}/roles  -H "content-type:application/json" -d  @/tmp/items-json-${serviceName}-${roleType}.txt
done```

- [ ] configure yarn directories
```curl -i -u "${basicauth}" \
     -H "Content-Type: application/json" -i \
     -X PUT \
             --data '{
         "items" : [ {
           "name" : "yarn_nodemanager_local_dirs",
           "value" : "/yarn/nm",
           "sensitive" : false
         }, {
           "name" : "yarn_nodemanager_log_dirs",
           "value" : "/yarn/container-logs",
           "sensitive" : false
         }]
       }' \
${apiURL}/clusters/${clusterName}/services/yarn/roleConfigGroups/yarn-NODEMANAGER-BASE/config

  • configure kafka roles
export serviceName="kafka"  
export roleTypes="KAFKA_BROKER"
for roleType in ${roleTypes};do
	jq -R '.' /tmp/all-hosts-id.txt | jq -s '{items:map({type:"'$roleType'",hostRef:{hostId:.}})}' > /tmp/items-json-${serviceName}-${roleType}.txt
	curl -i -X POST -u "${basicauth}" ${apiURL}/clusters/${clusterName}/services/${serviceName}/roles  -H "content-type:application/json" -d  @/tmp/items-json-${serviceName}-${roleType}.txt
done

Execute firstRun

  • Deploy Client Config
curl -u ${basicauth} \
    -H "Content-Type:application/json" \
    -X POST  \
    -i \    ${apiURL}/clusters/${clusterName}/commands/deployClientConfig

The output will generate a JSON with command id. In this case it is 51 , but it will vary.

{
  "id" : 51,
  "name" : "DeployClusterClientConfig",
  "startTime" : "2018-12-25T06:35:00.200Z",
  "active" : true,
  "clusterRef" : {
    "clusterName" : "cdhcluster-01"
  }
}

Wait until the command is finished with success .

"success" : true

Following command can be used to check the status

export commandId=51
curl -i -X GET -u ${basicauth} ${apiURL}/commands/${commandId}

First Run

  • zookeeper
export serviceName=zookeeper
curl -X POST -u ${basicauth}  ${apiURL}/clusters/${clusterName}/services/${serviceName}/commands/firstRun

Wait until the command is finished with success .

"success" : true

Following command can be used to check the status

export commandId=<commandId>
curl -i -X GET -u ${basicauth} ${apiURL}/commands/${commandId}
  • hdfs
export serviceName=hdfs
curl -X POST -u ${basicauth}  ${apiURL}/clusters/${clusterName}/services/${serviceName}/commands/firstRun

Wait until the command is finished with success .

"success" : true

Following command can be used to check the status

export commandId=<commandId>
curl -i -X GET -u ${basicauth} ${apiURL}/commands/${commandId}
  • hbase
export serviceName=hbase
curl -X POST -u ${basicauth}  ${apiURL}/clusters/${clusterName}/services/${serviceName}/commands/firstRun

Wait until the command is finished with success .

"success" : true

Following command can be used to check the status

export commandId=<commandId>
curl -i -X GET -u ${basicauth} ${apiURL}/commands/${commandId}
  • yarn
export serviceName=yarn
curl -X POST -u ${basicauth}  ${apiURL}/clusters/${clusterName}/services/${serviceName}/commands/firstRun

Wait until the command is finished with success .

"success" : true

Following command can be used to check the status

export commandId=<commandId>
curl -i -X GET -u ${basicauth} ${apiURL}/commands/${commandId}
  • kafka
export serviceName=kafka
curl -X POST -u ${basicauth}  ${apiURL}/clusters/${clusterName}/services/${serviceName}/commands/firstRun

Wait until the command is finished with success .

"success" : true

Following command can be used to check the status

export commandId=<commandId>
curl -i -X GET -u ${basicauth} ${apiURL}/commands/${commandId}

At this point we should have a working Cloudera cluster. Next part 3 will cover the security configurations using Cloudera CDH API

Automate your Hadoop Cluster (CDH)

Automate your Hadoop Cluster (CDH)

Automate your Hadoop Cluster (CDH) – Part 1

There are multiple approaches you can take when architecting a cluster. We will assume that high availability with minimum number of nodes and security(TLS and Kerberos) is a must.

Our Part -1 goal is to install and configure a Cloudera Manager and configure repository from command line.

  • Part -1 Install Cloudera Manager (cluster) like a boss.
  • Part -2 Add services and Configure CDH using API
  • Part -2 Secure your CDH Cloudera server with Kerberos
  • Part -3 Configure TLS Encryption on CDH services

Configure Hosts

In this configuration we are using Centos 7.5 1805 build but any other distribution of Redhat or Centos distribution above 7.5 should work exactly same way.

We will be installing Hadoop with CDH 5.13 on CentOS 7.5 We will also install Postgres as a database for Cloudera Manager.

  • Environment
  • Single node: 4 CPUs, 32 GB RAM.
  • Multiple nodes:
    • 4 VMs, 2 CPUs per VM and 8 GB RAM per VM.
Nodes Component
cm.example.com Cloudera Manager, Database
data-1.example.com DataNode
data-2.example.com DataNode
data-3.example.com DataNode

Configure cloudera ssh account

  • Login to each node with an user with root sudo privilege.
  • Create cloudera user id with sudo privilege on all hosts.
sudo useradd -m cloudera
	export clouderapassword="averycomplexpassword"
echo ${clouderapassword} | sudo passwd cloudera --stdin
  • Generate ssh-key on any node ( I do it on Cloudera CM node) and

    copy to all other nodes

sudo su - cloudera
ssh-keygen -t rsa -N "" -C "cloudera" -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
  • Copy ~/.ssh/id_rsa ,.ssh/id_rsa.pub, .ssh/authorized_keys

    to all other hosts

sudo su - cloudera
export CM_NODE=cm.example.com
export DATA_NODES=(data-1.example.com data-2.example.com data-2.example.com)

for h in  ${DATA_NODES[@]}; do  
	ssh cloudera@${h} "mkdir -p ~/.ssh/;chmod 700 ~/.ssh"
	scp ~/.ssh/* cloudera@${h}:~/.ssh/
	ssh cloudera@${h} "chmod 600 ~/.ssh/*"
done
  • Test passwordless ssh. The below script should print all the

    hostname without prompting passwords

sudo su - cloudera
export CM_NODE=cm.example.com
export DATA_NODES=(data-1.example.com data-2.example.com data-2.example.com)
for h in  ${DATA_NODES[@]}; do  
	ssh cloudera@${h} 'echo "ssh success. I am : $(hostname -f)"'
done
  • Configure sudo privilege on cloudera account
sudo sh -c 'echo "cloudera ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/cloudera-users'

Install and configure Database (Postgres)

CDH Cloudera Manager uses databases and datastores to store Cloudera Manager configuration, health of the system and task progress.

Postgres is one of the mostly used database for Production installation.

Follow these procedures to install Postgres 9.6.3 database on Cloudera Manager.

  • SSH to Cloudera Manager as cloudera
sudo yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm  -y
sudo yum install postgresql96-server postgresql96 -y
sudo /usr/pgsql-9.6/bin/postgresql96-setup initdb
sudo systemctl enable postgresql-9.6
sudo systemctl start postgresql-9.6
  • Create required databases
psql -U postgres -c "CREATE USER scm WITH PASSWORD 'averycomplexpassword';"
psql -U postgres -c "CREATE DATABASE scm OWNER scm ENCODING 'UTF8';"
psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE scm TO scm;"
psql -U postgres -c "ALTER DATABASE scm SET standard_conforming_strings = off;"


psql -U postgres -c "CREATE USER metastore WITH PASSWORD 'averycomplexpassword';"
psql -U postgres -c "CREATE DATABASE metastore OWNER metastore ENCODING 'UTF8';"
psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE metastore TO metastore;"
psql -U postgres -c "ALTER DATABASE metastore SET standard_conforming_strings = off;"

# Configure report manager user / database
psql -U postgres -c "CREATE USER reportman WITH PASSWORD 'averycomplexpassword';"
psql -U postgres -c "CREATE DATABASE reportman OWNER reportman ENCODING 'UTF8';"
psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE reportman TO reportman;"
psql -U postgres -c "ALTER DATABASE reportman SET standard_conforming_strings = off;"
  • Change postgres password
sudo -u postgres psql -c "\password"
Enter new password:
Enter it again:
  • Configure remote access

Edit /var/lib/pgsql/9.6/data/postgresql.conf uncomment and change following lines

listen_addresses = '*'
  • Edit /var/lib/pgsql/9.6/data/pg_hba.conf change following lines
# "local" is for Unix domain socket connections only
local   all   all   md5
# IPv4 local connections:
host    all   all   0.0.0.0/0 md5
# IPv6 local connections:
host  all  all  ::/0  md5
  • Restart Postgres
    sudo systemctl restart postgresql-9.6
    

Install Cloudera Manager

  • Configure cloudera manager repo

    ssh to Cloudera Manager as cloudera

sudo su - cloudera
export CDH_CM_VERSION=5.14.1
export CDH_NODES=(cm.example.com data-1.example.com data-2.example.com data-2.example.com)
curl https://archive.cloudera.com/cm5/redhat/7/x86_64/cm/cloudera-manager.repo --output /tmp/cloudera-manager.repo

sed -i "/baseurl=/ s/=.*/=https:\/\/archive.cloudera.com\/cm5\/redhat\/7\/x86_64\/cm\/"${CDH_CM_VERSION}"\//" /tmp/cloudera-manager.repo

for h in  ${CDH_NODES[@]}; do  
	scp /tmp/cloudera-manager.repo cloudera@${h}:/tmp	
done

for h in  ${CDH_NODES[@]}; do  
	ssh cloudera@${h} "sudo cp /tmp/cloudera-manager.repo /etc/yum.repos.d/" 
done
  • Install JDK and JCE

    Install JDK on all hosts

sudo yum install java-1.8.0-openjdk

You may also install Oracle JDK from the link below

https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

https://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

  • Install cloudera manager
sudo yum install cloudera-manager-daemons cloudera-manager-agent cloudera-manager-server -y
  • Configure scm database
export scmpassword="averycomplexpassword"
export POSTGRES_HOST=cm.example.com
sudo /usr/share/cmf/schema/scm_prepare_database.sh postgresql scm scm "${scmpassword}" -h ${POSTGRES_HOST}
  • Download CDH Parcel
sudo -i 
cd /opt/cloudera/parcel-repo
curl -O https://archive.cloudera.com/cdh5/parcels/5.13.1/CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel
curl -O https://archive.cloudera.com/cdh5/parcels/5.13.1/CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel.sha1
mv /opt/cloudera/parcel-repo/CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel.sha1 /opt/cloudera/parcel-repo/CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel.sha
sudo chown cloudera-scm:cloudera-scm /opt/cloudera/parcel-repo/*
  • Download Kafka Parcel
sudo -i 
cd /opt/cloudera/parcel-repo
curl -O http://archive.cloudera.com/kafka/parcels/3.1.0.35/KAFKA-3.1.0-1.3.1.0.p0.35-el7.parcel
curl -O http://archive.cloudera.com/kafka/parcels/3.1.0.35/KAFKA-3.1.0-1.3.1.0.p0.35-el7.parcel.sha1
mv /opt/cloudera/parcel-repo/KAFKA-3.1.0-1.3.1.0.p0.35-el7.parcel.sha1 /opt/cloudera/parcel-repo/KAFKA-3.1.0-1.3.1.0.p0.35-el7.parcel.sha
sudo chown cloudera-scm:cloudera-scm /opt/cloudera/parcel-repo/*
  • Start cloudera Manager
sudo systemctl restart cloudera-scm-server
  • Run your first API command

    Check server status

isCMUp=$(curl -s -o /dev/null -I -w "%{http_code}" -u "admin:admin" http://$(hostname -f):7180/api/version|grep "200"|wc -l);echo ${isCMUp}

wait until isCMUp is 1

At this point cloudera manager should be completely installed and and can be accessible through UI.

Next Part 2 will cover to create Cloudera Services (CDH) using API.