How to install and configure ELK 7.x on Centos 7

Pre-req

sudo yum list installed | grep -e 'jre|jdk'
sudo yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel
sudo yum install java-1.8.0-openjdk

Installing and configuring elasticsearch

sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
sudo vi /etc/yum.repos.d/elasticsearch.repo

Add those lines in /etc/yum.repos.d/elasticsearch.repo

[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

sudo cat /etc/yum.repos.d/elasticsearch.repo
sudo yum clean all
sudo yum makecache
sudo yum -y install elasticsearch

Modify those lines in /etc/elasticsearch/elasticsearch.yml

network.host: localhost

sudo sed -i 's/\#network.host: 192.168.0.1/network.host: localhost/g' /etc/elasticsearch/elasticsearch.yml
sudo cat /etc/elasticsearch/elasticsearch.yml | grep network

Modify those lines in /etc/elasticsearch/jvm.options

sudo cat /etc/elasticsearch/jvm.options | grep ^-Xm[s,x]
sudo sed -i 's/-Xms1g/-Xms256m/g' /etc/elasticsearch/jvm.options
sudo sed -i 's/-Xmx1g/-Xmx512m/g' /etc/elasticsearch/jvm.options
sudo cat /etc/elasticsearch/jvm.options | awk '/^-Xm[s,x]/ {print}'

Restart elasticsearch service

sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch
sudo systemctl status elasticsearch
rpm -qi elasticsearch

Test your connection

curl -X GET "localhost:9200"
curl http://127.0.0.1:9200
curl -X PUT "http://127.0.0.1:9200/devops_index"

Installing and configuring Kibana**

sudo yum install kibana

Configure the firewall

sudo firewall-cmd --add-port=5601/tcp --permanent
sudo firewall-cmd --reload

Modify the file */etc/kibana/kibana.yml* as needed

server.host: "tvtlwelk01std.localdomain"

sudo cat /etc/kibana/kibana.yml
sudo vi /etc/kibana/kibana.yml
sudo cat /etc/kibana/kibana.yml |grep -v \# |sed '/^$/d'

Start and enable Kibana service

sudo systemctl stop kibana
sudo systemctl start kibana
sudo systemctl status kibana
>sudo lsof -i

Got to `http://:5601/` (eg. )

sudo lsof -i :5601

Installing and configuring logstash

sudo yum install logstash

Configure Logstash Input config files from */etc/logstash/conf.d*

sudo touch /etc/logstash/conf.d/02-beats-input.conf
sudo vi /etc/logstash/conf.d/02-beats-input.conf

Add the lines

input {
 beats {
 port => 5044
 }
}

sudo cat /etc/logstash/conf.d/02-beats-input.conf

Configure Logstash Filter config files from */etc/logstash/conf.d*

sudo touch /etc/logstash/conf.d/10-syslog-filter.conf
sudo vi /etc/logstash/conf.d/10-syslog-filter.conf

Add the following lines

filter {
  if [fileset][module] == "system" {
    if [fileset][name] == "auth" {
      grok {
        match => { "message" => ["%{SYSLOGTIMESTAMP:[system][auth][timestamp]} %{SYSLOGHOST:[system][auth][hostname]} sshd(?:\[%{POSINT:[system][auth][pid]}\])?: %{DATA:[system][auth][ssh][event]} %{DATA:[system][auth][ssh][method]} for (invalid user )?%{DATA:[system][auth][user]} from %{IPORHOST:[system][auth][ssh][ip]} port %{NUMBER:[system][auth][ssh][port]} ssh2(: %{GREEDYDATA:[system][auth][ssh][signature]})?",
                  "%{SYSLOGTIMESTAMP:[system][auth][timestamp]} %{SYSLOGHOST:[system][auth][hostname]} sshd(?:\[%{POSINT:[system][auth][pid]}\])?: %{DATA:[system][auth][ssh][event]} user %{DATA:[system][auth][user]} from %{IPORHOST:[system][auth][ssh][ip]}",
                  "%{SYSLOGTIMESTAMP:[system][auth][timestamp]} %{SYSLOGHOST:[system][auth][hostname]} sshd(?:\[%{POSINT:[system][auth][pid]}\])?: Did not receive identification string from %{IPORHOST:[system][auth][ssh][dropped_ip]}",
                  "%{SYSLOGTIMESTAMP:[system][auth][timestamp]} %{SYSLOGHOST:[system][auth][hostname]} sudo(?:\[%{POSINT:[system][auth][pid]}\])?: \s*%{DATA:[system][auth][user]} :( %{DATA:[system][auth][sudo][error]} ;)? TTY=%{DATA:[system][auth][sudo][tty]} ; PWD=%{DATA:[system][auth][sudo][pwd]} ; USER=%{DATA:[system][auth][sudo][user]} ; COMMAND=%{GREEDYDATA:[system][auth][sudo][command]}",                   "%{SYSLOGTIMESTAMP:[system][auth][timestamp]} %{SYSLOGHOST:[system][auth][hostname]} groupadd(?:\[%{POSINT:[system][auth][pid]}\])?: new group: name=%{DATA:system.auth.groupadd.name}, GID=%{NUMBER:system.auth.groupadd.gid}",                   "%{SYSLOGTIMESTAMP:[system][auth][timestamp]} %{SYSLOGHOST:[system][auth][hostname]} useradd(?:\[%{POSINT:[system][auth][pid]}\])?: new user: name=%{DATA:[system][auth][user][add][name]}, UID=%{NUMBER:[system][auth][user][add][uid]}, GID=%{NUMBER:[system][auth][user][add][gid]}, home=%{DATA:[system][auth][user][add][home]}, shell=%{DATA:[system][auth][user][add][shell]}$",                   "%{SYSLOGTIMESTAMP:[system][auth][timestamp]} %{SYSLOGHOST:[system][auth][hostname]} %{DATA:[system][auth][program]}(?:\[%{POSINT:[system][auth][pid]}\])?: %{GREEDYMULTILINE:[system][auth][message]}"] }         pattern_definitions => {           "GREEDYMULTILINE"=> "(.|\n)*"         }         remove_field => "message"       }       date {         match => [ "[system][auth][timestamp]", "MMM  d HH:mm:ss", "MMM dd HH:mm:ss" ]       }       geoip {         source => "[system][auth][ssh][ip]"         target => "[system][auth][ssh][geoip]"       }     }     else if [fileset][name] == "syslog" {       grok {         match => { "message" => ["%{SYSLOGTIMESTAMP:[system][syslog][timestamp]} %{SYSLOGHOST:[system][syslog][hostname]} %{DATA:[system][syslog][program]}(?:\[%{POSINT:[system][syslog][pid]}\])?: %{GREEDYMULTILINE:[system][syslog][message]}"] }         pattern_definitions => { "GREEDYMULTILINE" => "(.|\n)*" }         remove_field => "message"       }       date {         match => [ "[system][syslog][timestamp]", "MMM  d HH:mm:ss", "MMM dd HH:mm:ss" ]       }     }   } }

sudo cat /etc/logstash/conf.d/10-syslog-filter.conf

Configure Logstash output config files from */etc/logstash/conf.d*

sudo touch /etc/logstash/conf.d/30-elasticsearch-output.conf
sudo vi /etc/logstash/conf.d/30-elasticsearch-output.conf

Add those lines

output {
  elasticsearch {
    hosts => ["localhost:9200"]
    manage_template => false
    index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
  }
}

sudo cat /etc/logstash/conf.d/30-elasticsearch-output.conf

Start Logstash

sudo -u logstash /usr/share/logstash/bin/logstash --path.settings /etc/logstash -t
sudo systemctl start logstash
sudo systemctl enable logstash
sudo systemctl status logstash
sudo lsof -i :9200
grep wap-wsp /etc/services
sudo lsof -i :5044
grep lxi-evntsvc /etc/services

Installing and configuring Filebeats agents**

sudo yum install filebeat

Configure the file */etc/filebeat/filebeat.yml*

sudo ls -lrt /etc/filebeat/filebeat.yml
sudo vi /etc/filebeat/filebeat.yml

Add the Lines

filebeat.inputs:
- type: log
  enabled: false
  paths:
    - /var/log/*.log
filebeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false
setup.template.settings:
  index.number_of_shards: 1
setup.kibana:
output.logstash:
  hosts: ["localhost:5044"]
processors:
  - add_host_metadata: ~
  - add_cloud_metadata: ~
  - add_docker_metadata: ~
  - add_kubernetes_metadata: ~

sudo cat /etc/filebeat/filebeat.yml |grep -v \# | sed '/^$/d'

Enable system module

sudo filebeat modules enable system
sudo filebeat modules list
sudo ls -lrt /etc/filebeat/modules.d/system.yml
sudo cat /etc/filebeat/modules.d/system.yml

Create Template and index

sudo filebeat setup --template -E output.logstash.enabled=false -E 'output.elasticsearch.hosts=["localhost:9200"]'
sudo filebeat setup --index-management -E output.logstash.enabled=false -E 'output.elasticsearch.hosts=["localhost:9200"]'
sudo cat /etc/kibana/kibana.yml |grep -v \# |sed '/^$/d'
sudo lsof -i :5601
sudo filebeat setup -e -E output.logstash.enabled=false -E output.elasticsearch.hosts=['localhost:9200'] -E setup.kibana.host=tvtlwelk01std.localdomain:5601

ps -ef |grep java

Start Filebeat service

sudo systemctl start filebeat
sudo systemctl enable filebeat
sudo systemctl status filebeat
curl -X GET 'http://localhost:9200/filebeat-*/_search?pretty'
sudo ls -lrt /var/log/{filebeat,logstash,elasticsearch}
Comments Off on How to install and configure ELK 7.x on Centos 7 Posted in Linux

How To Install Docker-Ce on IoT or VM

How to install Docker-ce on Raspberry pi 4 (Buster)

Download all required packages

wget https://download.docker.com/linux/debian/dists/buster/pool/stable/armhf/containerd.io_1.2.6-3_armhf.deb
wget https://download.docker.com/linux/debian/dists/buster/pool/stable/armhf/docker-ce-cli_18.09.7~3-0~debian-buster_armhf.deb
wget https://download.docker.com/linux/debian/dists/buster/pool/stable/armhf/docker-ce_18.09.7~3-0~debian-buster_armhf.deb

Install all the debian packages in the following order

sudo dpkg -i containerd.io_1.2.6-3_armhf.deb
sudo dpkg -i docker-ce-cli_18.09.7~3-0~debian-buster_armhf.deb
sudo dpkg -i docker-ce_18.09.7~3-0~debian-buster_armhf.deb
sudo usermod -G docker pi

Verify that docker-ce is running properly

sudo systemctl status docker.service
sudo systemctl status containerd.service
ps -ef |grep docker
sudo docker version

Run Docker services manually in case they are not running

sudo systemctl start docker.service
sudo systemctl enable docker.service
sudo systemctl status docker.service

sudo systemctl start containerd.service
sudo systemctl enable containerd.service
sudo systemctl status containerd.service

ps -ef |grep docker
sudo docker version

How to install Docker-ce on Ubuntu LTS 18.04 (Bionic)

Procedure is the same but you need to change the repository to amd64 processor

wget https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/amd64/containerd.io_1.2.6-3_amd64.deb
wget https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/amd64/docker-ce-cli_19.03.5~3-0~ubuntu-bionic_amd64.deb
wget https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/amd64/docker-ce_19.03.5~3-0~ubuntu-bionic_amd64.deb
Comments Off on How To Install Docker-Ce on IoT or VM Posted in Linux

Hands-On with GitLab

How to create a GitLab repository

Create a project on GitLab

  1. open a web browser session
  2. go to the following link
  3. logon with your credentials
  4. Click on ‘New Project’
  5. choose a blank page from template
  6. From Project path, choose the user or groups from the list (eg. dev084)
  7. From Project Name, choose a project name (eg. Test)
  8. From Project description, put a small description of your project
  9. From Visibility Level, choose private so only you and member you allow can access your data
  10. click on ‘Create project’ once you are done

Create your Public Key

ssh-keygen -t rsa -b 4096 -C "" 
cd .ssh
copy the content of the file id_rsa.pub to your clipboard

 

Add your Public keys on Gitlab from security menu

  1. open a web browser session
  2. got to the following link
  3. logon with your credentials
  4. Drop down the list from the right corner using your right click mouse and go to Settings
  5. From the main menu at the top, go to SSH Keys
  6. In the Key section, paste the content of your clipboard
  7. click on ‘Add Key’ button

How to setup your Global Settings of your local repository

git config --global user.name "" 
git config --global user.email "@" 
git config --global color.ui true
git config --global http.sslverify false
git config --list

How to Create a Local repository

Option 1: Clone your GitLab project locally
git clone 
cd 
git add . 
git add 
git commit -m ""
git push 
Option 2: Create a Local repository from scratch
mkdir
cd
git init
git remote add origin 
git remote -v
git add . 
git add
git commit -m ""
git push origin master

How to Create a Remote (central)repository

cd
git init --bare .git 

How to Update your Remote Git Repository

cd
git push origin master
git push --all
git push
git push --tags
git status
git show

GitLab operation commands

Create a file

touch
git status 
git diff
git add
git status 
gitt diff --staged
git commit -m ""
git status 

Modify a file

vi
git diff
git commit -a -m ""
git status 
gitt diff --staged
git commit -m ""
git log --oneline
git show

Remove a file from Working Directory and Local Repository

git rm 
ls 
git ls-files 
git status 
git commit -m ""
git status 

Remove a file from Local Repository only

git rm --cached 
ls 
git ls-files 
git status 
git commit -m ""
git status 

Ignore some file using .gitignore

vi .gitignore
git status
git add .gitignore
git status

Modify the last commit message

git log --oneline
git commit --amend -m "" 
git log --oneline
git log --pretty=oneline 
git status

How to create tag

git log --oneline
git tag --a -m ""
git log --online
git show
git tag
git tag -l 
git show
git status
git pull origin master
git push origin master
git status
git tag --delete

How to undo commit

touch
git commit -a -m ""
git status
git log --online
git revert 
put a message then save (!wq)
git log --online
ls
git ls-files

How to remove logs and reset

git log --oneline
git reset --hard 
git log --oneline
Comments Off on Hands-On with GitLab Posted in Linux

How to install Ansible on Centos 7

The following procedure will give you steps to proceed with ansible on Centos 7.

This article will not describe how to create a VM depending on Hypervisor (VMware, Virtuel Box, Hyper-V …). You need to choose your own virtualization solution for installing your Virtual Machine.

Before installing Ansible, you need to have a VM fully installed and updated with Centos 7.

Make sure the latest Python version is installed on your system. As root, do as follow:

$ sudo yum install dnf

$ sudo dnf update

$ sudo dnf install python3

$ sudo python3 -V

If python is installed properly, you should have the following ouput:

$ sudo python3 -V
Python 3.6.8

Make sure pip (Python Package Manager) is installed on your system:

$ sudo dnf install python3-pip

Usually python3-pip package is installed at the same time you install the lastest version of python:

$ sudo dnf install python3
Last metadata expiration check: 0:00:24 ago on Tue 01 Oct 2019 07:29:47 PM CEST.
Dependencies resolved.
=============================================================================================================================================================================================================================================
Package                                                          Arch                                                 Version                                                      Repository                                          Size
=============================================================================================================================================================================================================================================
Installing:
python3                                                          x86_64                                               3.6.8-10.el7                                                 base                                                69 k
Installing dependencies:
python3-libs                                                     x86_64                                               3.6.8-10.el7                                                 base                                               7.0 M
python3-pip                                                      noarch                                               9.0.3-5.el7                                                  base                                               1.8 M
python3-setuptools                                               noarch                                               39.2.0-10.el7                                                base                                               629 k
Transaction Summary
=============================================================================================================================================================================================================================================
Install  4 Packages
Total download size: 9.4 M
Installed size: 48 M
Is this ok [y/N]:

Now that all requirement are met, let’s start with Ansible installation. logon to your VM as regular user and perform the following steps:

$ pip3 install ansible –user

You should have the following output:

[user@ansible ~]$ pip3 install ansible –user
Collecting ansible
Downloading https://files.pythonhosted.org/packages/04/25/48fee5f8048360d9375e01846fcf395dda58242ed1f25a2106b6794452eb/ansible-2.8.5.tar.gz (14.4MB)
100% |████████████████████████████████| 14.4MB 119kB/s
Collecting jinja2 (from ansible)
Downloading https://files.pythonhosted.org/packages/1d/e7/fd8b501e7a6dfe492a433deb7b9d833d39ca74916fa8bc63dd1a4947a671/Jinja2-2.10.1-py2.py3-none-any.whl (124kB)
100% |████████████████████████████████| 133kB 3.3MB/s
Requirement already satisfied: PyYAML in /usr/lib64/python3.6/site-packages (from ansible)
Requirement already satisfied: cryptography in /usr/lib64/python3.6/site-packages (from ansible)
Collecting MarkupSafe>=0.23 (from jinja2->ansible)
Downloading https://files.pythonhosted.org/packages/b2/5f/23e0023be6bb885d00ffbefad2942bc51a620328ee910f64abe5a8d18dd1/MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
Requirement already satisfied: idna>=2.1 in /usr/lib/python3.6/site-packages (from cryptography->ansible)
Requirement already satisfied: asn1crypto>=0.21.0 in /usr/lib/python3.6/site-packages (from cryptography->ansible)
Requirement already satisfied: six>=1.4.1 in /usr/lib/python3.6/site-packages (from cryptography->ansible)
Requirement already satisfied: cffi!=1.11.3,>=1.7 in /usr/lib64/python3.6/site-packages (from cryptography->ansible)
Requirement already satisfied: pycparser in /usr/lib/python3.6/site-packages (from cffi!=1.11.3,>=1.7->cryptography->ansible)
Installing collected packages: MarkupSafe, jinja2, ansible
Running setup.py install for ansible … done
Successfully installed MarkupSafe-1.1.1 ansible-2.8.5 jinja2-2.10.1

Once installed, you can verify that installation was done correctly by checking the version of Ansible package:

$ ansible –version

You should have the following output:

[user@ansible ~]$ ansible –version
ansible 2.8.5
config file = None
configured module search path = [‘/home/nathan/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.6.8 (default, Jul  1 2019, 16:43:04) [GCC 8.2.1 20180905 (Red Hat 8.2.1-3)]

You are done !

Comments Off on How to install Ansible on Centos 7 Posted in Linux

How To find HBA Link on Linux (RHEL) or Solaris

To find out the HBA Link staTus on Unix (Solaris) or Linux (RHEL), run the following command:

On Linux (RHEL) system

Make sure you have systool utility installed on your system first

which systool

example:

# which systool
/usr/bin/systool

If it return an error, please install the package sysfsutils

yum install -y sysfsutils

Run the following command to see the HBA Link status

for list in `ls -ld /sys/class/fc_host/host[0-9]*/ |cut -d ‘/’ -f5`; do systool -c fc_host -v $list | egrep -e ‘path|fabric_name|node_name|port_name|port_state|port_type|speed’ ; done

example:

# for list in `ls -ld /sys/class/fc_host/host[0-9]*/ |cut -d ‘/’ -f5`; do systool -c fc_host -v $list | egrep -e ‘path|fabric_name|node_name|port_name|port_state|port_type|speed’ ; done
Class Device path = “/sys/devices/pci0000:80/0000:80:01.0/0000:86:00.0/host3/fc_host/host3”
fabric_name = “0x0”
node_name = “0x20000090fa47a382”
port_name = “0x10000090fa47a382”
port_state = “Linkdown”
port_type = “Unknown”
speed = “unknown”
supported_speeds = “2 Gbit, 4 Gbit, 8 Gbit”
Device path = “/sys/devices/pci0000:80/0000:80:01.0/0000:86:00.0/host3”
Class Device path = “/sys/devices/pci0000:80/0000:80:03.0/0000:8b:00.0/host4/fc_host/host4”
fabric_name = “0x0”
node_name = “0x20000090fa47a6a5”
port_name = “0x10000090fa47a6a5”
port_state = “Linkdown”
port_type = “Unknown”
speed = “unknown”
supported_speeds = “2 Gbit, 4 Gbit, 8 Gbit”
Device path = “/sys/devices/pci0000:80/0000:80:03.0/0000:8b:00.0/host4”
Class Device path = “/sys/devices/pci0000:80/0000:80:07.0/0000:90:00.0/host5/fc_host/host5”
fabric_name = “0x1000000533beec13”
node_name = “0x20000090fa5284f4”
port_name = “0x10000090fa5284f4”
port_state = “Online”
port_type = “NPort (fabric via point-to-point)”
speed = “8 Gbit”
supported_speeds = “2 Gbit, 4 Gbit, 8 Gbit”
Device path = “/sys/devices/pci0000:80/0000:80:07.0/0000:90:00.0/host5”
Class Device path = “/sys/devices/pci0000:80/0000:80:07.0/0000:90:00.1/host6/fc_host/host6”
fabric_name = “0x1000000533bef762”
node_name = “0x20000090fa5284f5”
port_name = “0x10000090fa5284f5”
port_state = “Online”
port_type = “NPort (fabric via point-to-point)”
speed = “8 Gbit”
supported_speeds = “2 Gbit, 4 Gbit, 8 Gbit”
Device path = “/sys/devices/pci0000:80/0000:80:07.0/0000:90:00.1/host6”

On Unix (Solaris) System

run the following command to see HBA Link status

fcinfo hba-port | egrep -e ‘OS|Type|State|Speed|WWN’

example:

# fcinfo hba-port | egrep -e ‘OS|Type|State|Speed|WWN’
HBA Port WWN: 2100001b329c54b5
OS Device Name: /dev/cfg/c2
FCode/BIOS Version: BIOS: 2.02; fcode: 2.01; EFI: 2.00;
Type: N-port
State: online
Supported Speeds: 1Gb 2Gb 4Gb
Current Speed: 4Gb
Node WWN: 2000001b329c54b5
HBA Port WWN: 2100001b329c92b4
OS Device Name: /dev/cfg/c3
FCode/BIOS Version: BIOS: 2.02; fcode: 2.01; EFI: 2.00;
Type: N-port
State: online
Supported Speeds: 1Gb 2Gb 4Gb
Current Speed: 4Gb
Node WWN: 2000001b329c92b4

You are Done!

Comments Off on How To find HBA Link on Linux (RHEL) or Solaris Posted in ALL, Linux, System, Unix

How to merge compressed files under Linux/Unix/Windows

If you want to merge several compressed files into one file, do as follow:

Under Linux/Unix

cat “<filename1>” “<filename2>” “<filenamen>” > “<filename>”

example

# cat “NetBackup_7.1_CLIENTS_tar-gz.1of2” “NetBackup_7.1_CLIENTS_tar-gz.2of2” > “NetBackup_7.1_CLIENTS.tar.gz”
# ls -lrt
total 7867428
-rw-r–r–. 1 root root 1430244430 Dec 8 17:39 NetBackup_7.1_LinuxR_x86_64.tar.gz
-rw-r–r–. 1 root root 1866465280 Dec 8 17:43 NetBackup_7.1_CLIENTS_tar-gz.1of2
-rw-r–r–. 1 root root 1446523985 Dec 8 17:43 NetBackup_7.1_CLIENTS_tar-gz.2of2
-rw-r–r–. 1 root root 3312989265 Feb 22 12:26 NetBackup_7.1_CLIENTS.tar.gz
# file NetBackup_7.1_CLIENTS.tar.gz
NetBackup_7.1_CLIENTS.tar.gz: gzip compressed data, was “NetBackup_7.1_CLIENTS.tar”, from Unix, last modified: Mon Feb 14 19:44:10 2011

Under Windows

copy /B “<filename1>” + “<filename2>” + “<filenamen>” “<filename>”

or

copy /B “<filename1>” + “<filename2>” + “<filenamen>” DRIVE:\”<filename>”

example

F:\Symantec\NetBackup\7.1\Pkgs>copy /B “NetBackup_7.1_Win_zip.1of2” + “NetBackup_7.1_Win_zip.2of2” “Netbackup_7.1.zip”
NetBackup_7.1_Win_zip.1of2
NetBackup_7.1_Win_zip.2of2
1 file(s) copied.

or

F:\Symantec\NetBackup\7.1\Pkgs>copy /B “NetBackup_7.1_Win_zip.1of2” + “NetBackup_7.1_Win_zip.2of2″ d:\”NetBackup_7_1.zip”
NetBackup_7.1_Win_zip.1of2
NetBackup_7.1_Win_zip.2of2
1 file(s) copied.

You’re done!

Comments Off on How to merge compressed files under Linux/Unix/Windows Posted in ALL, System

Understanding RedHat package naming convention and format

RedHat packages use a specific naming convention with the following format:

name-version-release.arch.rpm

example

mypkg-2.7-5.x86_64.rpm

the following package is named mypkg, the version is 2.7, the release is 5 and the architecture is

a 64bit (x86_64).

Comments Off on Understanding RedHat package naming convention and format Posted in RedHat

How to create Partition larger than 2TB on RHEL6

Because you cannot create partition larger than 2TB with fdisk utility, you need to use GNU parted with GPT (http://en.wikipedia.org/wiki/File:GUID_Partition_Table_Scheme.svg).

Suppose you have a logical volume  /dev/sdb which size is 7TB. Here is the procedure on how to create a partition of 7B under Linux

1) logon as root on your system

2) launch parted utility from command line

# parted /dev/sdb
GNU Parted 2.1
Using /dev/sdb
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted)

3) Label the disk with gpt flag

(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted)

4) Specify the unit

(parted) unit TB

5) Create the partition

(parted) mkpart primary 0.00TB 7.20TB

or

(parted) mkpart primary 0 7

6) verify the partition was created successfully

(parted) p
Model: LSI RAID 5/6 SAS 6G (scsi)
Disk /dev/sdb: 7.20TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1 0.00TB 7.20TB 7.20TB primary

7) exit from parted utility. When you exit from parted, it will automatically save the configuration and label the disk automatically

(parted) quit
Information: You may need to update /etc/fstab.

8) Re-read the partition table

# partprobe /dev/sdb

9) Print the partition table again

# parted /dev/sdb print
Model: LSI RAID 5/6 SAS 6G (scsi)
Disk /dev/sdb: 7196GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1 1049kB 7196GB 7196GB primary

10) format the partition in ext4

# mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
439230464 inodes, 1756909568 blocks
87845478 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
53617 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848, 512000000, 550731776, 644972544

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

11) verify the blockID

# blkid
/dev/sda1: UUID=”a1766d87-966f-4dab-ac66-c0849fed93dd” TYPE=”ext4″
/dev/sda2: UUID=”9e45fb76-52d0-4354-8dee-a48ac96a87ef” TYPE=”swap”
/dev/sda3: UUID=”dd865595-70de-493f-80f7-3acfe502f584″ TYPE=”ext4″
/dev/sda5: UUID=”3d83eb71-4cd5-409b-8a7c-52f2cbb80bb7″ TYPE=”ext4″
/dev/sdb1: UUID=”d55ca767-3199-4c17-983c-c6598e3e7a4b” TYPE=”ext4″

12) Label the disk (you can name as you want, i have labelled it ‘SPData’

[root@linwbp32 ~]# e2label /dev/sdb1 SPData

13) verify it has been labelled correctly with blkid and findfs command
# blkid
/dev/sda1: UUID=”a1766d87-966f-4dab-ac66-c0849fed93dd” TYPE=”ext4″
/dev/sda2: UUID=”9e45fb76-52d0-4354-8dee-a48ac96a87ef” TYPE=”swap”
/dev/sda3: UUID=”dd865595-70de-493f-80f7-3acfe502f584″ TYPE=”ext4″
/dev/sda5: UUID=”3d83eb71-4cd5-409b-8a7c-52f2cbb80bb7″ TYPE=”ext4″
/dev/sdb1: UUID=”d55ca767-3199-4c17-983c-c6598e3e7a4b” TYPE=”ext4″ LABEL=”SPData”
# findfs LABEL=SPData
/dev/sdb1

14) create a mount point call ‘Data’

# mkdir /Data

15) mount the partition on /Data and verify the diskspace

# mount LABEL=SPData /data
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 25G 1.3G 22G 6% /
tmpfs 71G 0 71G 0% /dev/shm
/dev/sda1 194M 31M 154M 17% /boot
/dev/sda5 28G 297M 26G 2% /var
/dev/sdb1 6.5T 181M 6.2T 1% /data

16) Add the following lines in /etc/fstab

LABEL=SPData /data                    ext4    defaults,nodev       1 2

17) reboot your system and make sure SPData is mounted on /Data properly

#init 6

Your’re done!

Comments Off on How to create Partition larger than 2TB on RHEL6 Posted in RedHat

How to install Linux RedHat 5.x or 6.x using kickstart with TFTP (PXE) method

A. TFTP (PXE) Kickstart installation method

This post will not cover basic windows or Linux command that you must know before following this procedure.

1) Install Apache packages

rpm -ivh apr-util-1.2.7-11.el5_5.2.i386.rpm
rpm -ivh apr-1.2.7-11.el5_6.5.i386.rpm
rpm -ivh httpd-2.2.3-45.el5.i386.rpm

or

yum install apr-util
yum install apr
yum install httpd

2) install dnsmasq (if not alreay installed)

rpm -ivh dnsmasq-2.45-1.1.el5_3.i386.rpm

or

yum install dnsmasq

3) Add the following entry in /etc/httpd/conf/httpd.conf for Apache server

ServerName localhost:80

<Directory /var/www/html/pub>
    Options +Indexes
    AllowOverride AuthConfig
    Order allow,deny
    Allow from all
</Directory>

4) uncomment and modify the following lines in /etc/dnsmasq.conf for DHCP server

domain-needed
bogus-priv
expand-hosts
domain=mydomain.com
dhcp-range=<start_ip_address>,<endt_ip_address>,24H
dhcp-host=08:00:27:54:10:17,<ip_address>
dhcp-boot=linux-install/pxelinux.0
log-queries
log-dhcp
conf-dir=/etc/dnsmasq.d

5) run the following command to create the RHEL directory and necessary kernel/ram disk files

pxeos -a -i “PXE installation” -p HTTP -D 0 -s <ip_address> -K http://<ip_address>/pub/kickstart/ks.cfg -L /pub RHEL

verify with the command

pxeos -l

example:

pxeos -l

RHEL5
        Description:    PXE installation
        Protocol:       HTTP
        isDiskless:     False
        Server:         10.10.10.1
        Location:       /pub

ls -lrt /tftpboot/linux-install/RHEL
total 9400
-rw-r–r– 1 root root 1888084 Sep 20 14:46 vmlinuz
-rw-r–r– 1 root root      61 Sep 20 14:46 ks.cfg
-rw-r–r– 1 root root 7700914 Sep 20 14:46 initrd.img

6) run the following command to create specific boot configuration which will overide the default boot configuration files

pxeboot -a -K http://<ip_address>/pub/kickstart/ks.cfg -O RHEL <ip_address>

verify with the command

pxeboot -l

example:

pxeboot -l

pxelinux client: 10.10.10.1
default RHEL
label RHEL
    kernel RHEL/vmlinuz
    append initrd=RHEL/initrd.img  ramdisk_size=9322 method=http://10.10.10.1/pub ip=dhcp

ls -lrt /tftpboot/linux-install/pxelinux.cfg

total 24
-rw-r–r– 1 root root 276 Sep 20 14:46 pxeos.xml
-rw-r–r– 1 root root 345 Sep 20 14:46 default
-rw-r–r– 1 root root 148 Sep 23 11:14 0A0A0A01

cat /tftpboot/linux-install/pxelinux.cfg/0A0A0A01

default RHEL

label RHEL

    kernel RHEL/vmlinuz
    append initrd=RHEL/initrd.img  ramdisk_size=9322 ks=http://10.10.10.1/pub/kickstart/ks.cfg

7) turn on dnsmasq and httpd sercices

chkconfig dnsmasq on
chkconfig httpd on

8) copy the complete RedHat DVD to the public location of your Apache server (On this case, copy the content of the DVD to /var/www/html/pub)

Modify the file /var/www/html/pub/kickstart/ks.cfg as follow:

install
text
url –url http://<ip_address>/pub
key –skip
lang en_US.UTF-8
keyboard be-latin1
network –bootproto=dhcp –device=eth0 –noipv6

9) start apache server

/usr/sbin/apachectl -k start

Test your connection to HTTP server and make sure you can download files :

wget http://<ip_address>/pub/kickstart/ks.cfg

example:

wget http://10.29.1.11/pub/kickstart/ks.cfg

–2011-09-20 14:36:32–  http://10.29.1.11/pub/kickstart/ks.cfg
Connecting to 10.29.1.11:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 6211 (6.1K) [text/plain]
Saving to: `ks.cfg’
100%[==============================================================================>] 6,211       –.-K/s   in 0s
2011-09-20 14:36:32 (127 MB/s) – `ks.cfg’ saved [6211/6211]

10) start dnsmasq daemon

/etc/init.d/dnsmasq start

11) from another terminal session on your kickstart server, monitor /var/log/messages to see messages from DHCP server  and /var/log/httpd/access.log to see message from Apache server:

tail -f /var/log/messages
tail -f /var/log/httpd/access.log

12) change the boot order of the linux client

Network -> Harddisk

13) if you are using VirtualBox, Make sure both VM are in “internal network (inet)” mode

14) if you are using VirtualBox, Make sure the client use the following Network interface

PCnet-Fast III (Am 79c973)

15) Power on your virtual machine

16) At boot option, choose option 1 (PXE installation)

17) the installation will start automatically:

to see system log, do ALt+F3
to see kernel log, do ALt+F4
to access graphical view, do ALT+F1
to access shell prompt, do ALT+F2

18) At the End of the installation, power off the virtual machine (kickstart configuration will only shutdown after full installation automatically)  and change the boot order to :

HardDisk -> CD-ROM and disable network boot

19) power on your virtual machine

20) You are done!

B. TFTP method is not working with static IP address:

“Considerations when using static IP addresses:

– It is not possible to use PXE; you must use diskettes/CD/DVD
– You must designate a pool of IP addresses in advance by either assigning a permanent static IP address or reusing a deployment pool of static IP addresses
– Changing addresses requires that individual computers are modified
– A security risk exists if intruders know the available IP addresses

Mitigating risks associated with using static IPs include:

– Establish a small pool of static IP addresses that are used exclusively for deployment, using permanent IP addresses for deployed systems
– Create a set of boot diskettes for as many systems as you will deploy at one time
– Use virtual computers (import computers) to preassign tasks and computer names or permanent IP addresses before computers are powered on
– Install the BootWorks hidden or embedded partition after the system is deployed to enable easy remote management and imaging. 
  This method uses a permanent IP address.”

Comments Off on How to install Linux RedHat 5.x or 6.x using kickstart with TFTP (PXE) method Posted in Kickstart

How to upgrade Linux RedHat 5.x or 6.x using kickstart over HTTP or CD-ROM (or .iso)

The following kickstart upgrade procedure apply for RedHat version 5.x or 6.x.
If you plan to upgrade from a version 5.x to 6.x, it will not work (you must reinstall your system from scratch!).
If you plan to upgrade from a release 5.x to a latest one, it will work (example from 5.5 to 5.6, and so on …).
This post will not cover basic windows or Linux command that you must know before following this procedure.

If you plan to upgrade your linux system, please refer first to my previous post to know how kickstart work
and then follow those instructions:

1) modify the file ks.cfg as follow

=> If you plan to use a static IP (modify the text between <> with your data):

upgrade
text
url –url http://<ip_address>/pub/
lang en_US.UTF-8
keyboard be-latin1
network –device eth0 –bootproto static –ip=<ip_address> –netmask=<netmask> –gateway=<gateway> –nameserver=<nameserver1,nameserver2> –hostname=<hostanme> –noipv6
bootloader –upgrade –location mbr
shutdown
clearpart –none

=> If you plan to use a DHCP IP (modify the text between <> with your data):

upgrade
text
url –url http://<ip_address>/pub/
lang en_US.UTF-8
keyboard be-latin1
network –device eth0 –bootproto dhcp –noipv6
bootloader –upgrade –location mbr
shutdown
clearpart –none

2) at boot menu (spalshscreen RedHat) type F2 if you install RedHat 5.x (or esc if you install RedHat 6.x)
3) at the boot prompt, type the following command:

=> If you plan to install over HTTP with DHCP address for the client, type the following command (modify the text between <> with your data)

linux ks=http://<ip_address>/pub/kickstart/ks.cfg

=> If you plan to install over HTTP with Static address for the client, type the following command (modify the text between <> with your data)

linux ks=http://<ip_address>/pub/kickstart/ks.cfg append ip=<ip_address> netmask=<netmask>

4) Once your upgradeis complete, logon to your linux system as root and check the file upgrade.log in the root directory. It contains the list of packages that have been upgraded during the installation:

[root@linux_kick01 ~]# ls -lrt
total 60
-rw-r–r– 1 root root  3329 Sep 27 10:15 install.log.syslog
-rw-r–r– 1 root root 19899 Sep 27 10:15 install.log
-rw——- 1 root root  1059 Sep 27 10:15 anaconda-ks.cfg
-rw-r–r– 1 root root  4613 Sep 27 10:22 upgrade.log
-rw-r–r– 1 root root   897 Sep 27 10:23 upgrade.log.syslog
[root@linux_kick01 ~]# more upgrade.log

Upgrading tzdata-2011g-1.el5.i386
warning: tzdata-2011g-1.el5: Header V3 DSA signature: NOKEY, key ID 37017186
Upgrading glibc-common-2.5-65.i386
warning: glibc-common-2.5-65: Header V3 DSA signature: NOKEY, key ID 897da07a
Upgrading nash-5.1.19.6-71.el5.i386
Upgrading yum-security-1.1.16-15.el5.noarch
Upgrading hwdata-0.213.23-1.el5.noarch
Upgrading emacs-leim-21.4-24.el5.i386
Upgrading libgcc-4.1.2-51.el5.i386
Upgrading glibc-2.5-65.i686
Upgrading bash-3.2-32.el5.i386
Upgrading coreutils-5.97-34.el5.i386

Upgrading rhn-client-tools-0.4.20-53.el5.noarch
Upgrading rhn-setup-0.4.20-53.el5.noarch
Upgrading yum-rhn-plugin-0.5.4-20.el5.noarch
Upgrading rhn-check-0.4.20-53.el5.noarch
Upgrading rhnsd-4.7.0-10.el5.i386
Upgrading rhn-setup-gnome-0.4.20-53.el5.noarch

5) You are done!

Comments Off on How to upgrade Linux RedHat 5.x or 6.x using kickstart over HTTP or CD-ROM (or .iso) Posted in Kickstart