<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Syamkumar</title>
    <description>The latest articles on Forem by Syamkumar (@dauntlessnomad).</description>
    <link>https://forem.com/dauntlessnomad</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F285252%2Ff0557dd9-a9ff-438c-88bd-60334f7be4e6.png</url>
      <title>Forem: Syamkumar</title>
      <link>https://forem.com/dauntlessnomad</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/dauntlessnomad"/>
    <language>en</language>
    <item>
      <title>Apache Airflow in Centos 7</title>
      <dc:creator>Syamkumar</dc:creator>
      <pubDate>Tue, 08 Feb 2022 07:03:43 +0000</pubDate>
      <link>https://forem.com/dauntlessnomad/apache-airflow-in-centos-7-4hb8</link>
      <guid>https://forem.com/dauntlessnomad/apache-airflow-in-centos-7-4hb8</guid>
      <description>&lt;p&gt;Apache Airflow is an open-source workflow management platform. It started at Airbnb in October 2014 as a solution to manage the company's increasingly complex workflows. Creating Airflow allowed Airbnb to programmatically author and schedule their workflows and monitor them via the built-in Airflow user interface. &lt;/p&gt;

&lt;p&gt;This document assumes you have a centos 7 VM with internet connectivity and a Sudo user.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Login as sudo
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo --login 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Update Packages
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum update -y 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install Epel release and yum-utils packages
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum -y install epel-release yum-utils
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install Development tools
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum groupinstall "Development tools" -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install required npm packages
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel python-devel wget cyrus-sasl-devel.x86_64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install python and python developer tools Packages
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum install -y python3 python3-devel 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Disable SeLinux
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;setenforce 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make the change permanent by editing&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vi /etc/selinux/config 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;change value&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELINUX=enforcing to SELINUX=disabled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Install Postgres Database
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Add Postgres repository to centos
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;View info your Postgres repo by running
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rpm -qi pgdg-redhat-repo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Enable and Install Postgresql
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum-config-manager --enable pgdg12

yum install -y postgresql12-server postgresql12 postgresql-devel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Initialize Database
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/usr/pgsql-12/bin/postgresql-12-setup initdb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Enable and Start Postgresql Service
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl enable --now postgresql-12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Confirm Database is started by Running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl status postgresql-12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Configure a String Administrator Password for Postgres
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Login to Postgresql
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;su - postgres 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Open psql shell
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;psql&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run the alter user query
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alter user postgres with password 'StrongPassword';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Edit the Postgres Service to enable MD5 authentication&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;vi /var/lib/pgsql/12/data/pg_hba.conf&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Accept from anywhere
host all all 0.0.0.0/0 md5

# Accept from trusted subnet
host all all 192.168.18.0/24 md5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Choose according to your requirement.&lt;/p&gt;

&lt;h4&gt;
  
  
  Optional Step
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Enable remote Postgres access ( Not recommended for Production systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;vi /var/lib/pgsql/12/data/postgresql.conf&lt;/code&gt;&lt;br&gt;
Edit the above file Find the entry named &lt;code&gt;listen_address&lt;/code&gt;&lt;br&gt;
uncomment the entry and modify it as below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;listen_addresses = '192.168.10.10'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or ( Not recommended in Production )&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;listen_addresses = '*' 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*Restart Postgres Service after you are done.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl restart postgresql-12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>airflow</category>
      <category>opensource</category>
    </item>
    <item>
      <title>How to take Hourly RDS snapshots for Disaster Recovery?</title>
      <dc:creator>Syamkumar</dc:creator>
      <pubDate>Tue, 08 Feb 2022 06:13:07 +0000</pubDate>
      <link>https://forem.com/dauntlessnomad/how-to-take-hourly-rds-snapshots-for-disaster-recovery-e2k</link>
      <guid>https://forem.com/dauntlessnomad/how-to-take-hourly-rds-snapshots-for-disaster-recovery-e2k</guid>
      <description>&lt;p&gt;Amazon RDS creates and saves automated backups of your DB instance during the backup window of your DB instance. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;RDS creates a storage volume snapshot of your DB instance, backing up the entire DB instance and not just individual databases. &lt;/li&gt;
&lt;li&gt;RDS saves the automated backups of your DB instance according to the backup retention period that you specify. &lt;/li&gt;
&lt;li&gt;You can recover your database to any point in time during the backup retention period.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Creating a DB snapshot
&lt;/h2&gt;

&lt;p&gt;Amazon RDS creates a storage volume snapshot of your DB instance, backing up the entire DB instance and not just individual databases. * Creating this DB snapshot on a Single-AZ DB instance results in a brief I/O suspension that can last from a few seconds to a few minutes, depending on the size and class of your DB instance. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For MariaDB, MySQL, Oracle, and PostgreSQL, I/O activity is not suspended on your primary during backup for Multi-AZ deployments, because the backup is taken from the standby. &lt;/li&gt;
&lt;li&gt;For SQL Server, I/O activity is suspended briefly during backup for Multi-AZ deployments. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Unlike automated backups, manual snapshots aren't subject to the backup retention period. Snapshots don't expire.&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Taking Backups using AWS Cli
&lt;/h3&gt;

&lt;p&gt;When you create a DB snapshot using the AWS Cli, you need to identify which DB instance you are going to back up, and then give your DB snapshot a name so you can restore from it later. &lt;br&gt;
You can do this by using the AWS Cli create-db-snapshot command with the following parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--db-instance-identifier&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--db-snapshot-identifier&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  The Action to do this.
&lt;/h2&gt;

&lt;p&gt;The Action requires the following environment variables to be set as secrets in the repository you will be running this action from. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS_REGION -&amp;gt; Your AWS Region&lt;/li&gt;
&lt;li&gt;AWS_ACCESS_KEY_ID -&amp;gt; Access key ID&lt;/li&gt;
&lt;li&gt;AWS_SECRET_ACCESS_KEY -&amp;gt; Access Secret&lt;/li&gt;
&lt;li&gt;DB_INSTANCE_IDENTIFIER -&amp;gt; DB Name&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The above access key should have the permission to create snapshots.&lt;br&gt;
The action has a cron based trigger that runs every hour and also a manual trigger that you can run if you want to take a snapshot manually(eg snapshot before running a migration).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Take Database Snapshots
on:
  schedule:
    - cron: '0 */1 * * *'
  workflow_dispatch:

env:
  AWS_REGION: ${{ secrets.AWS_REGION}}
  AWS_DEFAULT_OUTPUT: json
  AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID}}
  AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  DB_INSTANCE_IDENTIFIER: ${{ secrets.DB_INSTANCE_IDENTIFIER }}

jobs:
  snapshot:
    runs-on: ubuntu-latest
    name: Take Database Snapshot
    steps:
      - name: Set current date &amp;amp; time as ENV variable
        run: echo "NOW=$(date +'%Y-%m-%d-%H-%M-%S')" &amp;gt;&amp;gt; $GITHUB_ENV

      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: $AWS_ACCESS_KEY_ID
          aws-secret-access-key: $AWS_SECRET_ACCESS_KEY }}
          aws-region: $AWS_REGION
      - name: Take the Snapshot
        run: |
          aws rds create-db-snapshot --db-instance-identifier $DB_INSTANCE_IDENTIFIER --db-snapshot-identifier $DB_INSTANCE_IDENTIFIER-$NOW
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above GitHub action uses the AWS cli to trigger a snapshot creation .&lt;br&gt;
The creation time depends on the actual db size. &lt;br&gt;
PS. AWS charges you &lt;code&gt;$0.095 per GB-Month ( us-east-1)&lt;/code&gt; for RDS snapshot storage as part of backup service .&lt;/p&gt;

</description>
      <category>aws</category>
      <category>github</category>
      <category>devops</category>
      <category>rds</category>
    </item>
    <item>
      <title>MongoDB Cluster Setup Centos</title>
      <dc:creator>Syamkumar</dc:creator>
      <pubDate>Mon, 10 Aug 2020 14:19:12 +0000</pubDate>
      <link>https://forem.com/dauntlessnomad/mongodb-cluster-setup-centos-7-47hh</link>
      <guid>https://forem.com/dauntlessnomad/mongodb-cluster-setup-centos-7-47hh</guid>
      <description>&lt;p&gt;We will be setting up Mongo DB for high availability using 3 virtual machines &lt;/p&gt;

&lt;p&gt;1) Mongo Primary (t3a.medium)&lt;br&gt;
2) Mongo Secondary (t3a.medium)&lt;br&gt;
3) Mongo Arbiter (t3a.small)&lt;/p&gt;
&lt;h2&gt;
  
  
  Let's begin the system preparations
&lt;/h2&gt;
&lt;h3&gt;
  
  
  The following setup has to be done in all 3 machines
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;login as sudo in each machine
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo --login 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt; Update centos packages to the latest version
Centos 7
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum update -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Centos 8&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dnf update -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;install Nano editor (I am a Nano fan)
Centos 7
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum install nano -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Centos 8&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dnf install nano -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;add hosts values 
edit the &lt;code&gt;nano /etc/hosts&lt;/code&gt; file to add the following entries
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;172.31.28.16 mongo1
172.31.31.194 mongo2
172.31.25.65 mongo3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  important Step
&lt;/h2&gt;

&lt;p&gt;Disable SELinux as it has breaking effects  on internode connection&lt;br&gt;
 edit &lt;code&gt;/etc/selinux/config&lt;/code&gt;&lt;br&gt;
change&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELINUX=disabled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;do the above step in all 3 machines and make sure to do a reboot by running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reboot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Now Install Mongo
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Configure the package management system&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create a &lt;code&gt;nano /etc/yum.repos.d/mongodb-org-4.4.repo&lt;/code&gt; file so that you can install MongoDB directly using yum&lt;/p&gt;

&lt;p&gt;Add the following content to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install Mongo DB latest Stable
Centos 7
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum install -y mongodb-org
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Centos 8&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dnf install -y mongodb-org
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before we can begin cluster Setup lets prepare mongo&lt;/p&gt;

&lt;h3&gt;
  
  
  Enable Mongo Authentication
&lt;/h3&gt;

&lt;p&gt;To add authentication to mongo add the following lines to &lt;br&gt;
&lt;code&gt;nano /etc/mongod.conf&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;security:
    authorization: enabled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then do a restart&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;service mongod restart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;let's create mongodb user
Open mongo shell&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;mongo&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;the following commands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use admin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.createUser({
    user: "tomahawk",
    pwd: "tomahawkPilot",
    roles: [ 
        { 
            role: "userAdminAnyDatabase", 
            db: "admin" 
        },
        {
            role: "clusterAdmin",
             db: "admin"
        },
        {
            role: "root,
            db: "admin
        }
    ]
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Now let's Begin the Replication Configuration
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Add replSet to mongod.conf in all 3 machines
edit your &lt;code&gt;nano /etc/mongod.conf&lt;/code&gt; file
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;replication:
  replSetName: rs0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Keyfile Access Control on Replica Set
&lt;/h2&gt;

&lt;p&gt;navigate to your mongo path&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/var/lib/mongo in my case
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use the following command to generate a keyfile&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openssl rand -base64 756 &amp;gt; keyfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy the key file to all 3 machines&lt;br&gt;
add Appropriate permissions&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod 400 keyfile
chown mongod:mongod keyfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now add the keyfile to your &lt;code&gt;nano /etc/mongod.conf&lt;/code&gt; file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;security:
    authorization: enabled
    keyFile: /var/lib/mongo/keyfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;do a restart of all mongod services
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl restart mongod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;for the changes in replication to take effect before initializing the replica&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On mongo1
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use admin
db.auth("tomahawk","tomahawkPilot");
rs.initiate(
   {
      _id: "rs0",
      version: 1,
      members: [
         { _id: 0, host : "mongo1:27017" }
      ]
   }
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can always run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mongo --port 27017 -u tomahawk --authenticationDatabase 'admin' -p tomahawkPilot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to directly login to the cluster&lt;/p&gt;

&lt;p&gt;Now let's create the replica set&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rs.add("mongo2:27017");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check connection status by running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rs.status()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Successful connection, you will get a response&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rs.status()
{
        "set" : "rs0",
        "date" : ISODate("2020-08-10T14:03:42.405Z"),
        "myState" : 1,
        "term" : NumberLong(2),
        "syncSourceHost" : "",
        "syncSourceId" : -1,
        "heartbeatIntervalMillis" : NumberLong(2000),
        "majorityVoteCount" : 2,
        "writeMajorityCount" : 2,
        "votingMembersCount" : 2,
        "writableVotingMembersCount" : 2,
        "optimes" : {
                "lastCommittedOpTime" : {
                        "ts" : Timestamp(1597068221, 2),
                        "t" : NumberLong(2)
                },
                "lastCommittedWallTime" : ISODate("2020-08-10T14:03:41.727Z"),
                "readConcernMajorityOpTime" : {
                        "ts" : Timestamp(1597068221, 2),
                        "t" : NumberLong(2)
                },
                "readConcernMajorityWallTime" : ISODate("2020-08-10T14:03:41.727Z"),
                "appliedOpTime" : {
                        "ts" : Timestamp(1597068221, 2),
                        "t" : NumberLong(2)
                },
                "durableOpTime" : {
                        "ts" : Timestamp(1597068221, 2),
                        "t" : NumberLong(2)
                },
                "lastAppliedWallTime" : ISODate("2020-08-10T14:03:41.727Z"),
                "lastDurableWallTime" : ISODate("2020-08-10T14:03:41.727Z")
        },
        "lastStableRecoveryTimestamp" : Timestamp(1597066170, 1),
        "electionCandidateMetrics" : {
                "lastElectionReason" : "electionTimeout",
                "lastElectionDate" : ISODate("2020-08-10T14:03:41.721Z"),
                "electionTerm" : NumberLong(2),
                "lastCommittedOpTimeAtElection" : {
                        "ts" : Timestamp(0, 0),
                        "t" : NumberLong(-1)
                },
                "lastSeenOpTimeAtElection" : {
                        "ts" : Timestamp(1597066987, 1),
                        "t" : NumberLong(1)
                },
                "numVotesNeeded" : 2,
                "priorityAtElection" : 1,
                "electionTimeoutMillis" : NumberLong(10000),
                "numCatchUpOps" : NumberLong(0),
                "newTermStartDate" : ISODate("2020-08-10T14:03:41.727Z"),
                "wMajorityWriteAvailabilityDate" : ISODate("2020-08-10T14:03:41.898Z")
        },
        "members" : [
                {
                        "_id" : 0,
                        "name" : "mongo1:27017",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 454,
                        "optime" : {
                                "ts" : Timestamp(1597068221, 2),
                                "t" : NumberLong(2)
                        },
                        "optimeDate" : ISODate("2020-08-10T14:03:41Z"),
                        "syncSourceHost" : "",
                        "syncSourceId" : -1,
                        "infoMessage" : "",
                        "electionTime" : Timestamp(1597068221, 1),
                        "electionDate" : ISODate("2020-08-10T14:03:41Z"),
                        "configVersion" : 2,
                        "configTerm" : 2,
                        "self" : true,
                        "lastHeartbeatMessage" : ""
                },
                {
                        "_id" : 1,
                        "name" : "mongo2:27017",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 7,
                        "optime" : {
                                "ts" : Timestamp(1597066987, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDurable" : {
                                "ts" : Timestamp(1597066987, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDate" : ISODate("2020-08-10T13:43:07Z"),
                        "optimeDurableDate" : ISODate("2020-08-10T13:43:07Z"),
                        "lastHeartbeat" : ISODate("2020-08-10T14:03:41.727Z"),
                        "lastHeartbeatRecv" : ISODate("2020-08-10T14:03:42.261Z"),
                        "pingMs" : NumberLong(0),
                        "lastHeartbeatMessage" : "",
                        "syncSourceHost" : "",
                        "syncSourceId" : -1,
                        "infoMessage" : "",
                        "configVersion" : 2,
                        "configTerm" : 1
                }
        ],
        "ok" : 1,
        "$clusterTime" : {
                "clusterTime" : Timestamp(1597068221, 2),
                "signature" : {
                        "hash" : BinData(0,"17CdXYPWQ6I24TCLhxpQt8nGGPk="),
                        "keyId" : NumberLong("6859346398467325956")
                }
        },
        "operationTime" : Timestamp(1597068221, 2)
}
rs0:PRIMARY&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Setting up the Arbiter
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rs.addArb("mongo3:27017");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
        "ok" : 1,
        "$clusterTime" : {
                "clusterTime" : Timestamp(1597068567, 1),
                "signature" : {
                        "hash" : BinData(0,"q5F6v883q8+1gBfmEJtwINbXAYY="),
                        "keyId" : NumberLong("6859346398467325956")
                }
        },
        "operationTime" : Timestamp(1597068567, 1)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now check connection status by running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rs.status()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;rs.status()&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rs0:PRIMARY&amp;gt; rs.status()
{
        "set" : "rs0",
        "date" : ISODate("2020-08-10T14:10:18.328Z"),
        "myState" : 1,
        "term" : NumberLong(2),
        "syncSourceHost" : "",
        "syncSourceId" : -1,
        "heartbeatIntervalMillis" : NumberLong(2000),
        "majorityVoteCount" : 2,
        "writeMajorityCount" : 2,
        "votingMembersCount" : 3,
        "writableVotingMembersCount" : 2,
        "optimes" : {
                "lastCommittedOpTime" : {
                        "ts" : Timestamp(1597068611, 1),
                        "t" : NumberLong(2)
                },
                "lastCommittedWallTime" : ISODate("2020-08-10T14:10:11.737Z"),
                "readConcernMajorityOpTime" : {
                        "ts" : Timestamp(1597068611, 1),
                        "t" : NumberLong(2)
                },
                "readConcernMajorityWallTime" : ISODate("2020-08-10T14:10:11.737Z"),
                "appliedOpTime" : {
                        "ts" : Timestamp(1597068611, 1),
                        "t" : NumberLong(2)
                },
                "durableOpTime" : {
                        "ts" : Timestamp(1597068611, 1),
                        "t" : NumberLong(2)
                },
                "lastAppliedWallTime" : ISODate("2020-08-10T14:10:11.737Z"),
                "lastDurableWallTime" : ISODate("2020-08-10T14:10:11.737Z")
        },
        "lastStableRecoveryTimestamp" : Timestamp(1597068601, 1),
        "electionCandidateMetrics" : {
                "lastElectionReason" : "electionTimeout",
                "lastElectionDate" : ISODate("2020-08-10T14:03:41.721Z"),
                "electionTerm" : NumberLong(2),
                "lastCommittedOpTimeAtElection" : {
                        "ts" : Timestamp(0, 0),
                        "t" : NumberLong(-1)
                },
                "lastSeenOpTimeAtElection" : {
                        "ts" : Timestamp(1597066987, 1),
                        "t" : NumberLong(1)
                },
                "numVotesNeeded" : 2,
                "priorityAtElection" : 1,
                "electionTimeoutMillis" : NumberLong(10000),
                "numCatchUpOps" : NumberLong(0),
                "newTermStartDate" : ISODate("2020-08-10T14:03:41.727Z"),
                "wMajorityWriteAvailabilityDate" : ISODate("2020-08-10T14:03:41.898Z")
        },
        "members" : [
                {
                        "_id" : 0,
                        "name" : "mongo1:27017",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 850,
                        "optime" : {
                                "ts" : Timestamp(1597068611, 1),
                                "t" : NumberLong(2)
                        },
                        "optimeDate" : ISODate("2020-08-10T14:10:11Z"),
                        "syncSourceHost" : "",
                        "syncSourceId" : -1,
                        "infoMessage" : "",
                        "electionTime" : Timestamp(1597068221, 1),
                        "electionDate" : ISODate("2020-08-10T14:03:41Z"),
                        "configVersion" : 3,
                        "configTerm" : 2,
                        "self" : true,
                        "lastHeartbeatMessage" : ""
                },
                {
                        "_id" : 1,
                        "name" : "mongo2:27017",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 403,
                        "optime" : {
                                "ts" : Timestamp(1597068611, 1),
                                "t" : NumberLong(2)
                        },
                        "optimeDurable" : {
                                "ts" : Timestamp(1597068611, 1),
                                "t" : NumberLong(2)
                        },
                        "optimeDate" : ISODate("2020-08-10T14:10:11Z"),
                        "optimeDurableDate" : ISODate("2020-08-10T14:10:11Z"),
                        "lastHeartbeat" : ISODate("2020-08-10T14:10:17.346Z"),
                        "lastHeartbeatRecv" : ISODate("2020-08-10T14:10:17.389Z"),
                        "pingMs" : NumberLong(0),
                        "lastHeartbeatMessage" : "",
                        "syncSourceHost" : "mongo1:27017",
                        "syncSourceId" : 0,
                        "infoMessage" : "",
                        "configVersion" : 3,
                        "configTerm" : 2
                },
                {
                        "_id" : 2,
                        "name" : "mongo3:27017",
                        "health" : 1,
                        "state" : 7,
                        "stateStr" : "ARBITER",
                        "uptime" : 50,
                        "lastHeartbeat" : ISODate("2020-08-10T14:10:17.351Z"),
                        "lastHeartbeatRecv" : ISODate("2020-08-10T14:10:17.471Z"),
                        "pingMs" : NumberLong(0),
                        "lastHeartbeatMessage" : "",
                        "syncSourceHost" : "",
                        "syncSourceId" : -1,
                        "infoMessage" : "",
                        "configVersion" : 3,
                        "configTerm" : 2
                }
        ],
        "ok" : 1,
        "$clusterTime" : {
                "clusterTime" : Timestamp(1597068611, 1),
                "signature" : {
                        "hash" : BinData(0,"Pir6qAUNxIu6/AbFv6fCxpVVwOs="),
                        "keyId" : NumberLong("6859346398467325956")
                }
        },
        "operationTime" : Timestamp(1597068611, 1)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rs.conf()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to see your config&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rs0:PRIMARY&amp;gt; rs.conf()
{
        "_id" : "rs0",
        "version" : 3,
        "term" : 2,
        "protocolVersion" : NumberLong(1),
        "writeConcernMajorityJournalDefault" : true,
        "members" : [
                {
                        "_id" : 0,
                        "host" : "mongo1:27017",
                        "arbiterOnly" : false,
                        "buildIndexes" : true,
                        "hidden" : false,
                        "priority" : 1,
                        "tags" : {

                        },
                        "slaveDelay" : NumberLong(0),
                        "votes" : 1
                },
                {
                        "_id" : 1,
                        "host" : "mongo2:27017",
                        "arbiterOnly" : false,
                        "buildIndexes" : true,
                        "hidden" : false,
                        "priority" : 1,
                        "tags" : {

                        },
                        "slaveDelay" : NumberLong(0),
                        "votes" : 1
                },
                {
                        "_id" : 2,
                        "host" : "mongo3:27017",
                        "arbiterOnly" : true,
                        "buildIndexes" : true,
                        "hidden" : false,
                        "priority" : 0,
                        "tags" : {

                        },
                        "slaveDelay" : NumberLong(0),
                        "votes" : 1
                }
        ],
        "settings" : {
                "chainingAllowed" : true,
                "heartbeatIntervalMillis" : 2000,
                "heartbeatTimeoutSecs" : 10,
                "electionTimeoutMillis" : 10000,
                "catchUpTimeoutMillis" : -1,
                "catchUpTakeoverDelayMillis" : 30000,
                "getLastErrorModes" : {

                },
                "getLastErrorDefaults" : {
                        "w" : 1,
                        "wtimeout" : 0
                },
                "replicaSetId" : ObjectId("5f314b35458f8460ab22cda1")
        }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Have an awesome day ahead&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>centos</category>
      <category>opensource</category>
      <category>linux</category>
    </item>
    <item>
      <title>Setup an OpenLDAP Server in Centos</title>
      <dc:creator>Syamkumar</dc:creator>
      <pubDate>Wed, 29 Jul 2020 07:44:09 +0000</pubDate>
      <link>https://forem.com/dauntlessnomad/setup-an-openldap-in-centos-5hge</link>
      <guid>https://forem.com/dauntlessnomad/setup-an-openldap-in-centos-5hge</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fz0pioz7mztix47nwlc7t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fz0pioz7mztix47nwlc7t.png" alt="Alt Text" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;OpenLDAP is a free, open-source implementation of the Lightweight Directory Access Protocol developed by the OpenLDAP Project. It is released under its own BSD-style license called the OpenLDAP Public License. LDAP is a platform-independent protocol.&lt;/p&gt;

&lt;p&gt;Follow the following steps to setup an OpenLDAP server in centos &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;login as Sudo. &lt;code&gt;sudo --login&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run package updates  &lt;code&gt;yum update -y&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install Epel Release &lt;code&gt;yum install -y epel-release&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install nano editor &lt;code&gt;yum install -y nano&lt;/code&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install OpenLDAP&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum -y install openldap compat-openldap openldap-clients openldap-servers openldap-servers-sql openldap-devel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;start the LDAP daemon and enable it on boot
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl start slapd
systemctl enable slapd
systemctl status slapd 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Now create an OpenLDAP administrative user and assign a password for that user&lt;br&gt;
&lt;code&gt;slappasswd&lt;/code&gt; will generate a hashed value for a given password which we can use to configure admin auth&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;create an LDIF file (ldaprootpasswd.ldif) which is used to add an entry to the LDAP directory.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nano ldaprootpasswd.ldif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following contents in it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dn: olcDatabase={0}config,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}PASSWORD_CREATED
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;add the corresponding LDAP entry by specifying the URI referring to the LDAP server and the file above.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ldapadd -Y EXTERNAL -H ldapi:/// -f ldaprootpasswd.ldif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt; copy the sample database configuration file for slapd into the /var/lib/ldap directory, and set the correct permissions on the file.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
chown -R ldap:ldap /var/lib/ldap/DB_CONFIG
systemctl restart slapd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt; import some basic LDAP schemas from the /etc/openldap/schema directory
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif 
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;add your domain in the LDAP database and create a file called ldapdomain.ldif for your domain.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dn: olcDatabase={1}monitor,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth"
  read by dn.base="cn=auth,dc=example,dc=com" read by * none

dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=example,dc=com

dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=auth,dc=example,dc=com

dn: olcDatabase={2}hdb,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}PASSWORD_CREATED

dn: olcDatabase={2}hdb,cn=config
changetype: modify
add: olcAccess
olcAccess: {0}to attrs=userPassword,shadowLastChange by
  dn="cn=auth,dc=example,dc=com" write by anonymous auth by self write by * none
olcAccess: {1}to dn.base="" by * read
olcAccess: {2}to * by dn="cn=auth,dc=example,dc=com" write by * read
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;add the above configuration to the LDAP database
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ldapmodify -Y EXTERNAL -H ldapi:/// -f ldapdomain.ldif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;create baseldapdomain.ldif
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dn: dc=example,dc=com
objectClass: top
objectClass: dcObject
objectclass: organization
o: example com
dc: example

dn: cn=auth,dc=example,dc=com
objectClass: organizationalRole
cn: Manager
description: Directory Manager

dn: ou=People,dc=example,dc=com
objectClass: organizationalUnit
ou: People

dn: ou=Group,dc=example,dc=com
objectClass: organizationalUnit
ou: Group 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;add the entries to the LDAP directory.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ldapadd -Y EXTERNAL -x -D cn=auth,dc=example,dc=com -W -f baseldapdomain.ldif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;create an LDAP User
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useradd tomahawk
passwd tomahawk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;create an LDAP group
&lt;code&gt;create a file called ldapgroup.ldif&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dn: cn=auth,ou=Group,dc=example,dc=com
objectClass: top
objectClass: posixGroup
gidNumber: 1005
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;gidNumber is the GID in /etc/group for tomahawk and add it to the OpenLDAP directory.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add to OpenLDAP directory.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ldapadd -Y EXTERNAL -x  -W -D "cn=auth,dc=example,dc=com" -f ldapgroup.ldif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Create an LDAP user 
&lt;code&gt;create a file named tomahawk.ldif&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dn: uid=tomahawk,ou=People,dc=example,dc=com
objectClass: top
objectClass: account
objectClass: posixAccount
objectClass: shadowAccount
cn: tomahawk
uid: tomahawk
uidNumber: 1005
gidNumber: 1005
homeDirectory: /home/tomahawk
userPassword: {SSHA}PASSWORD_HERE
loginShell: /bin/bash
gecos: tecmint
shadowLastChange: 0
shadowMax: 0
shadowWarning: 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;** Run &lt;code&gt;slappasswd&lt;/code&gt; to generate a hashed password **&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add the above file to LDAP directory
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ldapadd -Y EXTERNAL  -x -D cn=auth,dc=example,dc=com -W -f  tomahawk.ldif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also download Tools like&lt;br&gt;
&lt;a href="https://directory.apache.org/studio/" rel="noopener noreferrer"&gt;Apache Directory Studio&lt;/a&gt; to manage LDAP after following the above steps to add more user and groups without creating config files. &lt;/p&gt;

&lt;h3&gt;
  
  
  Optional Steps
&lt;/h3&gt;

&lt;h4&gt;
  
  
  LDAPS ( LDAP via SSL)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Now we will generate a certificate and a private key so we can communicate securely with the OpenLDAP server using OpenSSL
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openssl req -new -x509 -nodes -out \
/etc/openldap/certs/auth.example.com.cert \
-keyout /etc/openldap/certs/auth.example.com.key \
-days 365
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Change the owner and group permissions so OpenLDAP can read the files:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chown -R ldap:ldap /etc/openldap/certs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now create ssl.ldif to configure OpenLDAP to use the LDAPS protocol:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dn: cn=config
changetype: modify
replace: olcTLSCertificateFile
olcTLSCertificateFile: /etc/openldap/certs/auth.example.com.cert

dn: cn=config
changetype: modify
replace: olcTLSCertificateKeyFile
olcTLSCertificateKeyFile: /etc/openldap/certs/auth.example.com.key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add the above file to LDAP directory
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ldapmodify -Y EXTERNAL -H ldapi:/// -f ssl.ldif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Test SSL configuration using
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;slaptest -u
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You have completed Openldap Setup in Centos 7&lt;/p&gt;

</description>
      <category>centos</category>
      <category>linux</category>
      <category>openldap</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Centos 7 to 8 Upgrade</title>
      <dc:creator>Syamkumar</dc:creator>
      <pubDate>Wed, 29 Jul 2020 07:09:41 +0000</pubDate>
      <link>https://forem.com/dauntlessnomad/centos-7-to-8-upgrade-2bj8</link>
      <guid>https://forem.com/dauntlessnomad/centos-7-to-8-upgrade-2bj8</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fd1mlbptmfps7r8450pzx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fd1mlbptmfps7r8450pzx.png" alt="Alt Text" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Red Hat Enterprise Linux 8 was released on 2019-05-07, and everyone is waiting to find out when the CentOS rebuild will occur. This document is meant to cover general questions and a timeline for what is happening.&lt;/p&gt;

&lt;p&gt;A CentOS major release takes a lot of planning and changes in tooling as it is based on a much newer version of Fedora than previous versions. This means that everything from the installer, packages, packaging, and build systems need major overhauls to work with the newer OS. This means that there is always a ramp-up period depending on the changes needed to make a rebuild work. The differences between EL-8 and EL-7 are no exception as the kernel has changed drastically, the repository format has added 'modules' and RPMS has grown many features that EL7 and before do not have. About the only item which has not drastically changed between EL7 and EL8 is the init system which is still system.&lt;/p&gt;

&lt;p&gt;To upgrade centos 7 to centos 8 &lt;/p&gt;

&lt;p&gt;Login as sudo &lt;code&gt;sudo --login&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Steps :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Epel release package
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum install epel-release -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install yum utils
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum install yum-utils -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Resolve RPM packages by executing the command.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum install rpmconf -y
rpmconf -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Perform a clean-up of all the packages you don’t require.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; package-cleanup --leaves
 package-cleanup --orphans
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install DNF package manager since Centos 8 uses DNF instead of yum
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum install dnf -y 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Remove yum package manager which was part of centos 7
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dnf -y remove yum yum-metadata-parser 
rm -Rf /etc/yum
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Run &lt;code&gt;dnf upgrade -y&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;install CentOS 8 release package&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dnf install http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-repos-8.2-2.2004.0.1.el8.x86_64.rpm http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-release-8.2-2.2004.0.1.el8.x86_64.rpm http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-gpg-keys-8.2-2.2004.0.1.el8.noarch.rpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;upgrade the EPEL repository.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dnf -y upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;remove all the temporary files.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dnf clean all 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Remove the old kernel core for CentOS 7.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; rpm -e `rpm -q kernel` 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;to remove conflicting packages.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rpm -e --nodeps sysvinit-tools 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;launch the CentOS 8 system upgrade
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Troubleshooting for common errors during this step.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python 3 dependency error. 
fix by
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;dnf remove python3&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Segmentation fault
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm -rf /var/lib/rpm/__db.*
rpm --rebuilddb
dnf clean all
dnf makecache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;install a new kernel for CentOS 8
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dnf -y install kernel-core
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;install CentOS 8 minimal package
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dnf -y groupupdate "Core" "Minimal Install"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;check the version of CentOS installed by running.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat /etc/redhat-release
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You have complete Centos Upgrade&lt;/p&gt;

</description>
      <category>devops</category>
      <category>linux</category>
      <category>centos</category>
    </item>
  </channel>
</rss>
