Thursday, September 19, 2013

Install and Configure Zabbix2.0 with mysql

In RHEL5 and RHEL6
Install zabbix as root user


Install mysql
-------------
        # yum install mysql
Install PHP and Apache (http)
------------------------------
        # yum install php
        # yum install http


Installation from packages
-------------------------------
   

Installing repository configuration package

    Install the repository configuration package. This package contains yum configuration files.
    Zabbix 2.0 for RHEL5:
        # rpm -ivh http://repo.zabbix.com/zabbix/2.0/rhel/5/x86_64/zabbix-release-2.0-1.el5.noarch.rpm
    Zabbix 2.0 for RHEL6:
        # rpm -ivh http://repo.zabbix.com/zabbix/2.0/rhel/6/x86_64/zabbix-release-2.0-1.el6.noarch.rpm

Installing Zabbix packages

    Install Zabbix packages. Example for Zabbix server and web frontend with mysql database.

        # yum install zabbix-server-mysql zabbix-web-mysql


Creating initial database

    Create zabbix database and user on MySQL.
          
        # mysql -uroot
        mysql> create database zabbix character set utf8;
        mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
        mysql> exit
   
     
Import initial schema and data.
        # cd /usr/share/doc/zabbix-server-mysql-2.0.4/create
        # mysql -uroot zabbix < schema.sql
        # mysql -uroot zabbix < images.sql
        # mysql -uroot zabbix < data.sql

Starting Zabbix server process

    Edit database configuration in zabbix_server.conf

        # vi /etc/zabbix/zabbix_server.conf
        DBHost=localhost
        DBName=zabbix
        DBUser=zabbix
        DBPassword=zabbix


    Start Zabbix server process.

        # service zabbix-server start

Editing PHP configuration for Zabbix frontend

        Apache configuration file for Zabbix frontend is located in /etc/httpd/conf.d/zabbix.conf. Some PHP settings are already configured.
        php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        # php_value date.timezone Europe/Riga

    It's necessary to uncomment the “date.timezone” setting and set the 
right timezone for you. After changing the configuration file restart 
the apache web server.

        # service httpd restart
        
    Start MySql service

        # service mysql start
     
Browse the URL and Configure the zabbix  http://hostname/zabbix
    username : admin
    password : zabbix
    note : use localhost in the place of hostname
    database : zabbix
    username : zabbix
    password : zabbix

Have fun.....
    

Tuesday, November 27, 2012

Check the dir size

To check the Dir size.
=====================

[root@TESTBED ~]# du -h --max-depth=1 /opt/ | sort -n -r

[root@TESTBED ]# du -h --max-depth=1 | sort -n -r


File size
=====

[root@TESTBED ]# du -h -s /opt/abc.txt

[root@TESTBED ]# du -h -s /opt/*

Clear the memory cache.

Clear the memory cache.
======================

# sync; echo 3 > /proc/sys/vm/drop_caches

Hardware clock set

# hwclock --show
$ date

Set clock

To set the system clock directly:

# date MMDDhhmmYYYY



Hardware Clock Set
====================
To set the hardware clock directly (the argument must be in local time, even if you keep your hardware clock in UTC.):

# hwclock --set --date="YYYY-MM-DD hh:mm:ss"

# hwclock --set --date=hh:mm:ss"


or

Synch time to hardware to OS / OS to hardware

The hardware clock can be set from the system clock and vice versa:

# hwclock --systohc
# hwclock --hctosys

Create a local compressed tarball from remote system directory

Create a local compressed tarball from remote host directory


# ssh user@host "tar -cf - /path/to/dir" | gzip > dir.tar.gz

Public Key issue while installing rpm through yum


Public Key issue while installing rpm through yum.

============================================

1. Check keys.
  
    find / -name "*GPG*"

  - Will get answers like below

    /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-former
    /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-rhx
    /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-auxiliary
    /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta


2. Go to the /etc/pki/rpm-gpg/
    # cd /etc/pki/rpm-gpg/

3. type the below command.
   # rpm --import *GPG*

 The above command wont be give any kind of output.

Adding SWAP by dd command

Create and add swap space in linux.
===========================

#dd if=/dev/zero of=/swap1 bs=1024 count=1048576

#dd if=/dev/zero of=/dev/swap1 bs=1G count=4

#mkswap /swap1

#swapon /swap1

#free -m


bs=1024 ( 1MB )
count=1048576 ( 1GB )

Adding proxy in Linux

Adding proxy in Linux
===================

Run the below commands  in terminal to get proxy details for temporary.

export http_proxy=http://proxy-ip:port/
export https_proxy=https://proxy-ip:port/

export http_proxy=http://proxy-url:port/
export https_proxy=https://proxy-url:port/


Add the proxy details in /etc/profile to permanent changes and access to all users (global set),
or else add in user .bach_profile file to get effect on selected user.


---------------------------------------------

For FTP

$export ftp_proxy=http://<proxy-server-ip>:<port>

with auth
$export ftp_proxy=http://<user>:<password>@<proxy-server-ip>:<port>

------------------------------------------

For svn

#vi /etc/subversion/servers


[global]
#http-proxy-host=my.proxy
#http-proxy-port=80
#http-proxy-username=[username]
#http-proxy-password=[password]

Friday, October 12, 2012

Remote ssh login issue

If you have reinstalled Linux or UNIX with OpenSSH, you will get the bellow

error. (or else changes in hostname and ip address)
=======
Error
=======

[root@TESTBED ]# ssh root@192.168.x.x
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
8c:32:d8:2c:94:18:4f:7f:7f:2a:15:60:4d:6f:50:79.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:3
RSA host key for 192.168.x.x has changed and you have requested strict

checking.
Host key verification failed.
lost connection
[root@TESTBED ]#

=====================================

Solution :
Add the remote machine as known host as below.
to known host


[root@TESTBED ]# ssh-keygen -R 192.168.x.x
/root/.ssh/known_hosts updated.
Original contents retained as /root/.ssh/known_hosts.old
[root@TESTBED ]#


Saturday, February 11, 2012

SVN from Windows and more on SVN

https://docs.google.com/viewer?a=v&pid=sites&srcid=ZGVmYXVsdGRvbWFpbnxsaW51eHdlYndvcmxkfGd4OjVhNjA0MjhjZTY4OTY1OQ

SVN and more on SVN

#which svn

If this returns a valid path as output, then it means that svn is installed on your linux box. If not, you need to install it. Installing subversion is very easy (for most distributions) and ample documentation is available on the web. You can start with http://subversion.apache.org/.

Four steps to complete svn repository creation on linux

1. log onto server as root
2. I prefer to have all svn repositories in one directory for better organization and easy maintenance. So next step for me would be to change to my svn directory.

cd /svnRepos

If you do not already have a directory for svn repositories, I would recommend creating one.

mkdir svnRepos

3. Create repository using following command

svnadmin create /path/to/repo/RepoName

where : RepoName is the name of repository to be created. As an example, I want to create a repository for my testproject. I would write

svnadmin create testproject

4. Change group ownership of repository for the intended group. In this case, consider I have a user group created as “all” and I want this group to have ownership to this repository.


chown -R :all /path/to/repo/RepoName
5. Grant Read/Write/Execute permissions to “all” on this repository

chmod -R 770 /path/to/repo/RepoName

6. Go to the /path/to/repo/RepoName/conf dir
and edit teh files. authz passwd svnserve.conf

authz
=====
[groups]
# harry_and_sally = harry,sally
admin = admin

# [/foo/bar]
# harry = rw
# * =
admin = rw


# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
admin = rw
==============================
==============================
passwd
======
[users]
# harry = harryssecret
# sally = sallyssecret
admin = admin123
==============================
==============================
svnserve.conf
==========
[general]
anon-access = none [edit these 4 linies without giving any space]
auth-access = write
password-db = /svnrepo/repo/conf/passwd
realm = repo [repo is my repository name]

===========-------------==============


Kill the process.

[If old repo is thare - killall svnserve]
[ to remove all - rm -rf find .-type d - name svnrepo/]


start the server
==========
svnserve -d --listen-port 2122 -r /svnrepo/repo

svnserve -d --listen-host 172.2x.x.12 -r /svnrepo/repo

svn import /svnrepo/repo/main svn://172.2x.x.12/svnrepo/repo/ -m "Import"

svn checkout svn://172.2x.x.12/svnrepo/repo/

---------------===================----------------===========

try from windows it will work

===================================================

Add folder's in svn

Go to repo dir

mkdir project
svn add project
svn commit project


svn import DATA svn://172.2x.x.33/svnrepo/repo -F DATA/file1

svn import svn://172.2x.x.33/svnrepo/repo -F DATA/file1

====================================================

SVN repository creation on linux in four steps

  1. log onto server as root
  2. I prefer to have all svn repositories in one directory for better organization and easy maintenance. So next step for me would be to change to my svn directory.

cd /svnRepos

If you do not already have a directory for svn repositories, I would recommend creating one.

mkdir svnRepos

  1. Create repository using following command

svnadmin create /path/to/repo/RepoName

where : RepoName is the name of repository to be created. As an example, I want to create a repository for my testproject. I would write

svnadmin create testproject

  1. Change group ownership of repository for the intended group. In this case, consider I have a user group created as “all” and I want this group to have ownership to this repository.

chown -R :all /path/to/repo/RepoName

  1. Grant Read/Write/Execute permissions to “all” on this repository

chmod -R 770 /path/to/repo/RepoName

6. svnserve -d --listen-port 2122 -r /home/demo/repository

Adding user to the sudoers

https://docs.google.com/viewer?a=v&pid=sites&srcid=ZGVmYXVsdGRvbWFpbnxsaW51eHdlYndvcmxkfGd4OjUyYWZmNTE1MmU3MGI2MTc

Adding Additional Hard Drives in Linux

https://docs.google.com/viewer?a=v&pid=sites&srcid=ZGVmYXVsdGRvbWFpbnxsaW51eHdlYndvcmxkfGd4OjQxYWZhNTNkODMxZjUzZTk

Restrict the user his home dir at ssh login

1. make a copy of bash with the name of rbash
#cp /bin/bash /bin/rbash

2. Add the user with rbash
[#useradd -s /bin/rbash ]
#useradd -s /bin/rbash admin

Restrict the user his home dir at ftp login

Go to /etc/vsftpd/vsftpd.conf file

# vi /etc/vsftpd/vsftpd.conf

add the below line at the end of file

chroot_local_user=YES

save the file and restart the vsftpd serverice.

ex :
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd whith two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES

chroot_local_user=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

Mount .iso file

# mount -o loop /ISO/rhel-server-5.1-i386-dvd.iso /mnt

mounting the .iso image to the /mnt directory.

For unmount

# umount /mnt

Fix MBR in dual boot system

Issue:

How can I fix a dual-booting system if I had to reinstall Windows and now I can no longer boot to Red Hat Enterprise Linux?

Resolution:

When Windows is reinstalled, it overwrites the GRUB bootloader in the Master Boot Record (MBR). The next time the system is booted, the usual GRUB menu will no longer be available and the system boots straight to Windows. This can be easily fixed.

Boot from Red Hat Enterprise Linux installation CD #1. At the installation boot prompt, type linux rescue then hit Enter. Follow the instructions as you would in a normal installation process. (There is no need to enable networking.) It will then inquire if you want to search for a Red Hat Enterprise Linux installation. Select Continue and the installer will now attempt to search for the operating system in your drives. If the search is successful, the rescue environment will mount it in /mnt/sysimage. You will be given a minimal shell.

At the shell prompt, do the following:

# chroot  /mnt/sysimage
# cd /boot/grub
# head grub.conf

The last command will show something similar to the following:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,1)
#          kernel /boot/vmlinuz-version ro root=/dev/hda2
#          initrd /boot/initrd-version.img
#boot=/dev/hda
default=0

Notice the commented line #boot=/dev/hda. This shows where the GRUB bootloader was previously installed. In this case it is in the MBR of the first IDE drive. To restore the bootloader, execute:

# grub-install /dev/hda

Reboot the system exiting the shell (twice) by executing:

# exit
# exit

The original GRUB bootloader should now be restored.

Create .iso file from cdrom

# dd if=/dev/cdrom of=/ISO/rhel5.iso

if=/dev/cdrom is the location of cdrom drive

/ISO is the direcrory where the iso file going to store.

rhel.iso is the file iso image dile name.

===============================

mkisofs also use to create iso image fine.

================================

Cisco VPN anyconnect Client Configuration

https://docs.google.com/viewer?a=v&pid=sites&srcid=ZGVmYXVsdGRvbWFpbnxsaW51eHdlYndvcmxkfGd4OjlmNGE5YWZjYzVlOWQ4