Tuesday, 19 July 2016

How to Mount External Hard Drive as a partition on CentOS 6.5

First, list devices on your system using one of the following command :

#fdisk -l | grep '^Disk'

Now, assuming your new drive is “sda”, use the following command to invoke the fdisk partition utility :

#fdisk /dev/sda

To create a new partition (assuming this is a new unused drive), just type “n“. Then, save your work typing “w” and “q” to exit the utility.
Any doubt or need help about fdisk utility, just type “m“.

Let’s format the partition as traditional EXT4 Linux file system :

#mkfs.ext4 /dev/sda

Okay, the hard disk partitioning and formatting is done now.

Create a directory where you want to have your drive mounted (replace all “external_hd” value with the name you want to use ) :

#mkdir /data

#mount /dev/sda /data

You’re now ready to use it! However, this mount will not survive to a reboot. To make it permanent, you need to edit fstab :

#vi /etc/fstab

/dev/sda        /data          ext4        defaults     0 0

NOTE : If you manually mount the drive instead doing the fstab way, do not forget to manually unmount it before unplug it! Serious data loss problem may occur if you skip this step!

#umount /dev/sda

How to install Webmin on CentOS 6.5

Download rpm file 
# wget http://sourceforge.net/projects/webadmin/files/webmin/1.660/webmin-1.660-1.noarch.rpm
Install from rpm file 
# rpm -Uvh webmin-1.660-1.noarch.rpm
Check the status of daemon 
# service webmin status
Start at boot 
# chkconfig webmin on

Saturday, 9 July 2016

Starting libvirtd daemon: libvirtd: relocation error: libvirtd: symbol dm_task_get_info_with_deferred_remove, version Base not defined in file libdevmapper.so.1.02 with link time reference

[root@org Desktop]# /etc/init.d/libvirtd start
Starting libvirtd daemon: libvirtd: relocation error: libvirtd: symbol dm_task_get_info_with_deferred_remove, version Base not defined in file libdevmapper.so.1.02 with link time reference

#yum upgrade device-mapper-libs

Tuesday, 21 June 2016

How to install OpenLDAP Server/Client and Configure on RHEL 6 Centos 6

Step 1. Install OpenLDAP packages via YUM 
#yum install openldap*

Step 2. Now generate a encrypted password for Administrator User That is "Manager"
New password: redhat
Re-enter new password: redhat

The above command will generate the password something like 

NOTE: You need to copy above generated password

Step 4. Now Configure OpenLDAP Server, so edit the following file:
#vim /etc/openldap/slapd.d/"cn=config"/"olcDatabase={2}bdb.ldif"

Inside this file do the following changes:
olcSuffix: dc=example,dc=com

olcRootDN: cn=Manager,dc=example,dc=com

Inside this file create the following lines:
olcTLSCertificateFile: /etc/pki/tls/certs/example.pem
olcTLSCertificateKeyFile: /etc/pki/tls/certs/examplekey.pem

:wq (save and exit) 

Step 5. Now specify the Monitoring privileges 
#vim /etc/openldap/slapd.d/"cn=config"/"olcDatabase={1}monitor.ldif"

Inside this file search the following "cn=manager,dc=my-domain,dc=com" 
and change this into "cn=Manager,dc=example,dc=com"

:wq (save and exit)

Step 6. Now copy the sample database file 
#cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG

You need to change owner and group ownership of this Database
#chown -R ldap:ldap /var/lib/ldap/

Now update the database

Step 7.  Configure OpenLDAP to listen on SSL/TLS 
#vim /etc/sysconfig/ldap 

SLAPD_LDAPS=yes #(default is no)

:wq (save and exit)

Step 8. Now you need to create a certificate for OpenLDAP Server. you can configure CA Server or something else, But in this example, I am creating a self sign certificate. 

# openssl req -new -x509 -nodes -out /etc/pki/tls/certs/example.pem -keyout /etc/pki/tls/certs/examplekey.pem -days 365

Country Name (2 letter code) [XX]:IN
State or Province Name (full name) []:Delhi
Locality Name (eg, city) [Default City]:New Delhi
Organization Name (eg, company) [Default Company Ltd]:Example, Inc.
Organizational Unit Name (eg, section) []:IT
Common Name (eg, your name or your server's hostname) []:ldap.example.com
Email Address []:root@ldap.example.com

Step 9. You need to change owner and group ownership of certificate and keyfile
#chown -Rf root:ldap /etc/pki/tls/certs/example.pem 
#chown -Rf root:ldap /etc/pki/tls/certs/examplekey.pem

You can also check, owner and group ownership changed or not
# ls -l /etc/pki/tls/certs/example*

Step 10. Start/Restart the service of OpenLDAP
# service slapd restart
#chkconfig slapd on

Step 11. Now you need to create base objects in OpenLDAP. 

NOTE: base objects means you have to create dn: for domain name, for OUs, so to creating dn:, you have to defining objectclass. 

there are two ways, (1). you can create it manually (2). you can use migration tools. In this example I am using migration tools. 

#yum install migrationtools 

# cd /usr/share/migrationtools/
# ls

You will see lot of files and scripts here. So you need to change some predefined values according to your domain name, for that do the following:

# vim migrate_common.ph

on the Line Number 61, change "ou=Groups" 
  $NAMINGCONTEXT{'group'}             = "ou=Groups";

 on the Line Number 71, change your domain name 
 $DEFAULT_MAIL_DOMAIN = "example.com";

on the line number 74, change your base name 
$DEFAULT_BASE = "dc=example,dc=com";

on the line number 90, change schema value

:wq (save and exit)

Now generate a base.ldif file for your Domain, use the following:
#./migrate_base.pl > /root/base.ldif

If you want to migrate your local users and groups on LDAP do the following:
first I am creating 5 local users and groups and then I will migrate to LDAP. 

#mkdir /home/guests
#useradd -d /home/guests/ldapuser1 ldapuser1
#useradd -d /home/guests/ldapuser2 ldapuser2
#useradd -d /home/guests/ldapuser3 ldapuser3
#useradd -d /home/guests/ldapuser4 ldapuser4
#useradd -d /home/guests/ldapuser5 ldapuser5

Now assign the password 
#passwd ldapuser1
#passwd ldapuser2
#passwd ldapuser3
#passwd ldapuser4
#passwd ldapuser5

Now you need to filter out these users from /etc/passwd to another file:
#getent passwd | tail -n 5 > /root/users

Now you need to filter out password information from /etc/shadow to another file:
# getent shadow | tail -n 5 > /root/passwords

Now you need to filter out user groups from /etc/group to another file:
# getent group | tail -n 5 > /root/groups

Now you have to generate ldif file of these filtered out files of users, passwords, and groups

So Open the following file to change the location of password file
# vim migrate_passwd.pl 

Inside this file search /etc/shadow and change it to /root/passwords and then save and exit

NOTE: "/etc/shadow" will be available approx the line number of 188. 

Now generate a ldif file for users 
# ./migrate_passwd.pl /root/users > /root/users.ldif

Now Generate a ldif file for groups 
# ./migrate_group.pl /root/groups > /root/groups.ldif

Step 12. Now it' time to upload these ldif file to LDAP Server 

#ldapadd -x -W -D "cn=Manager,dc=example,dc=com" -f /root/base.ldif 

# ldapadd -x -W -D "cn=Manager,dc=example,dc=com" -f /root/users.ldif

# ldapadd -x -W -D "cn=Manager,dc=example,dc=com" -f /root/groups.ldif 

NOTE: It will as a password of "Manager", you have to type the password which you generated in encrypted format. 

Now you can use "ldapsearch" command 

# ldapsearch -x -b "dc=example,dc=com"

Step 13. Now you need to share LDAP Users Home Directories via NFS they can mount the home directory on client machine. 

#vim /etc/exports 


:wq (save and exit)

# service nfs restart 
# chkconfig nfs on
# service iptables stop 
# chkconfig iptables off

Step 14. Now you need to copy your LDAP Server certificate in to /var/ftp/pub/. 
# cp -rvf /etc/pki/tls/certs/example.pem /var/ftp/pub/
# ln -s /var/ftp/pub/ /var/www/html/
# service vsftpd restart
# chkconfig vsftpd on
# service httpd restart 
# chkconfig httpd on

Now go to the Client Machine and configure it to use LDAP Server. 

# authconfig-gtk 

Click on "Identity & Authentication" Tab 
Click on drop down menu in "User Account Database" and Select "LDAP"
in LDAP Search Base DN: dc=example,dc=com
in LDAP Server: ldap://ldap.example.com
Select the check Box of "Use TLS to encrypt connections
Click "Download CA Certificate
In Certificate URL: type http://ldap.example.com/pub/example.pem
Click "OK"

# getent passwd ldapuser1

Now Configure your client machine to access the home directory as well 
# vim /etc/auto.master

create the following New Line 
/home/guests    /etc/auto.guests

:wq (save and exit)

# vim /etc/auto.guests
*       -rw     ldap.example.com:/home/guests/&

# service autofs reload

#su - ldapuser1

Friday, 17 June 2016

can't boot windows 8 after installing centos 7

The "/etc/grub2.cfg" is not updated even if it's detecting the windows partition at the terminal.

run the below command


check the section "### BEGIN /etc/grub.d/30_os-prober ###", and copied the menu entry from there in the terminal

add the menu entry to the grub2 config file "/etc/grub2.cfg" in the same section "### BEGIN /etc/grub.d/30_os-prober ###"

finally, boot to the windows os

If got a warning of my /boot partition is almost full

Remove the old kernels safely if you have.

Do the following to keep just the last 2 kernels on your system, to keep /boot clean

1 - Edit /etc/yum.conf and set the following parameter

#vim /etc/yum.conf


This will make your package manager keep just the 2 last kernels on your system(including the one that is running)

2 - Install yum-utils:

#yum install yum-utils

3- Make an oldkernel cleanup:

#package-cleanup --oldkernels --count=1

If you have more than one increase the count in above command.

Done. This will erase in a good fashion the old kernels.

Tuesday, 14 June 2016

How to Install And Configure PXE Server And Client On CentOS 6.5

About PXE Server

PXE Server, stands for preboot execution environment, is used to enable a network computer to boot only from a network interface card.

This method will be very helpful, if a System Administrator wants to install many systems which doesn’t have a CD/DVD device on the network.

PXE environment needs a DHCP server that distributes the IP addresses to the client systems, and a TFTP server that downloads the installation files to the PXE clients.

DHCP is used to find PXE servers and TFTP is used to download files to PXE client. These files are then stored into the client computer RAM memory and executed. PXE protocol client then boots independently of hard disks or operating systems.

PXE server will run on the same server as DHCP server.
You don’t need any CD/DVD or USB bootable drives to install client systems. Just, copy the ISO images on the PXE server and start installing your Linux clients via network using PXE server.

Requirements :-

DHCP Server
SELinux disabled on PXE server.
IP tables stopped on PXE server.
Network Card with PXE Option ROM (client). Client computers support booting over the network. You should check each computer's BIOS for this option.
You must a assign a static IP address to your DHCP server’s network interface card.
Install and Configure PXE Server!

1. Install the following packages for setting up PXE environment.
Install All Necessary Packages using yum :-
# yum install httpd xinetd syslinux tftp-server -y

2. Configure PXE Server

    Stop the firewall service.

    # service iptables stop

    Disable Selinux.
    # vim /etc/sysconfig/selinux

    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #     enforcing - SELinux security policy is enforced.
    #     permissive - SELinux prints warnings instead of enforcing.
    #     disabled - No SELinux policy is loaded.
    # SELINUXTYPE= can take one of these two values:
    #     targeted - Targeted processes are protected,
    #     mls - Multi Level Security protection.
    Now a reboot is required for selinux settings to  take effect.
    # reboot

    Copy the following TFTP configuration files to the /var/lib/tftpboot/ directory.

    # cd /usr/share/syslinux/
    # cp pxelinux.0 menu.c32 memdisk mboot.c32 chain.c32 /var/lib/tftpboot/
    # ll /var/lib/tftpboot/

    Edit file /etc/xinetd.d/tftp

    # vim /etc/xinetd.d/tftp
    Enable TFTP server. To d0 this, change “disable=yes” to “no”.

    # default: off
    # description: The tftp server serves files using the trivial file transfer
    # protocol.  The tftp protocol is often used to boot diskless
    # workstations, download configuration files to network-aware printers,
    # and to start the installation process for some operating systems.
    service tftp
             socket_type             = dgram
             protocol                   = udp
             wait                         = yes
             user                         = root
             server                      = /usr/sbin/in.tftpd
             server_args             = -s /var/lib/tftpboot
               isable                   = no
             per_source             = 11
             cps                         = 100 2
            flags                        = IPv4

    Next, create a directory to store CentOS installation ISO image. and mount the image to that     directory as shown below. I have CentOS 6.5 64bit ISO image on my /opt/mnt/Centos     directory.

    # mkdir /var/lib/tftpboot/Centos6_x86_64
    # ll /var/lib/tftpboot/Centos6_x86_64
    # mount -o loop /opt/CENTOS/CentOS-6.5-x86_64-bin-DVD1.iso /var/lib/tftpboot/Centos6_x86_64/
 # ll /var/lib/tftpboot/Centos6_x86_64/
    total 682
    -r--r--r-- 2 root root     14 Nov 29  2013 CentOS_BuildTag
    dr-xr-xr-x 3 root root   2048 Nov 29  2013 EFI
    -r--r--r-- 2 root root    212 Nov 28  2013 EULA
    -r--r--r-- 2 root root  18009 Nov 28  2013 GPL
    dr-xr-xr-x 3 root root   2048 Nov 29  2013 images
    dr-xr-xr-x 2 root root   2048 Nov 29  2013 isolinux
    dr-xr-xr-x 2 root root 655360 Nov 29  2013 Packages
    -r--r--r-- 2 root root   1354 Nov 28  2013 RELEASE-NOTES-en-US.html
    dr-xr-xr-x 2 root root   4096 Nov 29  2013 repodata
    -r--r--r-- 2 root root   1706 Nov 28  2013 RPM-GPG-KEY-CentOS-6
    -r--r--r-- 2 root root   1730 Nov 28  2013 RPM-GPG-KEY-CentOS-Debug-6
    -r--r--r-- 2 root root   1730 Nov 28  2013 RPM-GPG-KEY-CentOS-Security-6
    -r--r--r-- 2 root root   1734 Nov 28  2013 RPM-GPG-KEY-CentOS-Testing-6
    -r--r--r-- 1 root root   3380 Nov 29  2013 TRANS.TB

    Now, Create a apache configuration file for PXE server under /etc/httpd/conf.d/ directory:
    # vim /etc/httpd/conf.d/pxeboot.conf
    Add the following lines:

    Alias /Centos6_x86_64 /var/lib/tftpboot/Centos6_x86_64
    <Directory /var/lib/tftpboot/Centos6_x86_64>
    Options Indexes FollowSymLinks
    Order Deny,Allow
    Deny from all
    Allow from
    Save and close the file.

     Restart the httpd services

    # service httpd restart
    Stopping httpd:                                          [  OK  ]
    Starting httpd:                                            [  OK  ]

    Then, create a configuration directory for PXE server:
    # mkdir /var/lib/tftpboot/pxelinux.cfg

    Create a PXE server configuration file"default" under "/var/lib/tftpboot/pxelinux.cfg" and add     the below entry

    # vim /var/lib/tftpboot/pxelinux.cfg/default
    default menu.c32
    prompt 0
    timeout 300
    ONTIMEOUT local
    menu title ########## PXE Boot Menu ##########
    label 1
    menu label ^1) Install CentOS 6 x86_64 Edition
    kernel Centos6_x86_64/images/pxeboot/vmlinuz
    append initrd=centos6_x86_64/images/pxeboot/initrd.img             method=      Centos6_x86_64 devfs=nomount
    label 2
    menu label ^2) Boot from local drive localboot

     KERNEL - defines the location from where the PXELINUX bootloader will load.
     APPEND - defines the location for PXE initrd image file to load.

    Restart the relevant services.
    # service xinetd restart
    Stopping xinetd:                                           [  OK  ]
    Starting xinetd:                                           [  OK  ]

3. Now Install and Configure DHCP Server.
DHCP stands for Dynamic Host Configuration Protocol. DHCP is a standardized network     protocol used on Internet Protocol networks for dynamically distributing network configuration     parameters, such as IP addresses for interfaces and services. DHCP Server can be any server     (Linux or Windows) that is used to distribute IP addresses automatically to the clients in the     network. Since, DHCP Server assigns IP addresses automatically to all systems, a system or     Network administrator need not to assign IP addresses manually to every single machine in the     network. DHCP is opt for system or Network administrator who is managing thousands of     systems.

    A note of warning: Do not use two or more DHCP servers at the same time in your network.         The client systems might not be able to get IP addresses from the multiple DHCP servers and it     leads to IP address conflict issue. If your Router or Switch has DHCP feature enabled by     default, you need to turn it off too.
    You should Install and configure DHCP server on your PXE server. To install and configure     DHCP server, refer the following steps :-

    # yum install dhcp
 In CentOS 6.x systems, we have to assign which interface you want your DHCP server to run     on in /etc/sysconfig/dhcpd file. In my case, I have only one Interface on my system (eth0), so I     assigned eth0.
    Edit file /etc/sysconfig/dhcpd

    # vim /etc/sysconfig/dhcpd

    Assign the network interface:   

    Save and close the file.

    Now, edit dhcpd.conf file,

    # vim /etc/dhcp/dhcpd.conf

    Make the changes as shown below.
    option domain-name "setlabs.in";
    option domain-name-servers secondary.setlabs.org;
    default-lease-time 600;
    max-lease-time 7200;
    subnet netmask {
    range dynamic-bootp;
    option broadcast-address;
    option routers;

      allow booting;
           allow bootp;
       filename "pxelinux.0";

    Save and close the file.

{ Note :-
Set the domain name to setlabs.in and domain-name servers to secondary.setlabs.in.
If this DHCP server is the official DHCP server for the local network, add the following line: authoritative;
Define the sunbet, range of ip addresses, domain and domain name servers as shown :
    subnet netmask {
    range dynamic-bootp;
    option broadcast-address;
    option routers;
      allow booting;
           allow bootp;
    This declaration allows BOOTP clients to get dynamic addresses.
If you want to assign a fixed IP address to your client, you should enter it’s MAC id and the IP address in the following directive. For example, I want to assign a fixed IP address to my centos client, hence I modified the following directive as shown below.
    host centos-client {
     hardware ethernet 00:22:64:4f:e9:3a;

In your dhcp server make sure you add these lines.
       filename "pxelinux.0";
    as these define the address of your tftp server and the file to look for after getting the IP Address     from dhcp server.

    Now, restart the dhcp server.
    # service dhcpd start
    Starting dhcpd:                                            [  OK  ]

4. Restart all the services to complete the configuration.
    # service xinetd restart
    # service httpd restart
    # service dhcpd restart

    Make sure the services start after reboot
    # chkconfig httpd on
    # chkconfig xinetd on
    # chkconfig dhcpd on

5. PXE Client Configuration
The client may be any system that has network boot enabled option (PXE boot). You can enable this option in your Bios settings.Boot a machine and select the option of Network Boot from Bios. You should see Pxe Menu screen.

CentOS6.5: yum Error: rpmdb open failed

“yum update” took much time when processing “running transaction”, so I killed the process. After that I saw the following errors when issuing yum update.

 # yum update -y

rpmdb: Thread/process 21307/140433616029440 failed: Thread died in Berkeley DB library

error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery

error: cannot open Packages index using db3 -  (-30974)

error: cannot open Packages database in /var/lib/rpm


Error: rpmdb open failed

You could solve this by removing __db.* files under /var/lib/rpm directory.

# ls /var/lib/rpm/

Basenames     __db.002  Dirnames     Installtid    Packages        Pubkeys         Sha1header

Conflictname  __db.003  Filedigests  Name          Providename     Requirename     Sigmd5

__db.001      __db.004  Group        Obsoletename  Provideversion  Requireversion  Triggername

remove __db.* files

# rm /var/lib/rpm/__db.00*

get it fixed.

# yum update –y

Loaded plugins: fastestmirror, refresh-packagekit, security

Loading mirror speeds from cached hostfile

Wednesday, 1 June 2016

How to view password of wireless(Wi-fi) in D-link router

Select the password, Right click on it -> Inspect Element -> Double Click the type="password" -> Change the value "password" with "text" i.e., type="text" and click anywhere. Hooray! You can now view the password!

Thursday, 5 May 2016

Enabling Wake on LAN in ASUS Tek Motherboard (BIOS)

Go to Advanced --> APM --> Power on by PCIE/PCI [Disabled]

enable Power on by PCIE/PCI

Power on by PCIE/PCI [Enabled]

hit F10 to save and exit.

WOL Wake-on-lan Guide: Turn On Servers Remotely Without Physical Access

A) Description :-

Wakeonlan (wol) enables you to switch ON remote servers without physically accessing it. Wakeonlan sends magic packets to wake-on-LAN enabled ethernet adapters and motherboards to switch on remote computers.

B) Requirements :-

  • You can use Wakeonlan when a machine is connected to LAN, and you know the MAC address of that machine.
  • Your NIC should support wakeonlan feature, and it should be enabled before the
    shut down. In most cases, by default wakeonlan is enabled on the NIC.
  • You need to send the magic packet from another machine which is connected to the same network ( LAN ). You need root access to send magic packet.
  • Required packages:
ethtool on the machine you want to turn on(remote machine).
net-tools on the local machine you want to use to wake the remote machine.
plus, your network card MUST support Wake-on-LAN(wol).

C) Steps to be performed on the REMOTE MACHINE {to wake up} :-
  1. Enable "Wake on LAN" in the BIOS :-
{Go to BIOS -> Power -> Wake-on-lan -> Enable}
  1. Install the required packages :-
*By default, package ethtool is already installed with OS. Run the command “ethtool” to check whether the package is available or not, otherwise install them with following command.
# yum -y install ethtool
  1. Check whether wol is supported on the NIC :-
Execute the following ethtool command in the server which you want to switch ON from a remote place.
# ethtool eth0
Settings for eth0:
Supports Wake-on: pumbg [ Note: check whether flag g is present ]
Wake-on: d [ Note: g mean enabled. d means disabled ]

The 'g' in Supports Wake-on: pumbg indicates that wake-on-lan by using a 'magic packet' is supported.In addition, you need to tell your network card to enable wake-on-lan: g
  1. Enabling wol option on the Ethernet Card :-
By default the Wake-on will be set to g in most of the machines. If not, use ethtool to set the g flag to the wol option of the NIC card as shown below.
# ethtool -s eth0 wol g
Note: You should execute ethtool as root, else you may get following error message.
{ Optional in some cases :-
vim /etc/sysconfig/network-scripts/ifcfg-eth0
# add at the last line
  1. Note down the MAC address of the remote server
Note down the MAC address of the server that you wish to switch on remotely.
# ifconfig
eth0     Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX  [ Mac address ]
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::216:17ff:fe6b:289/64 Scope:Link
          RX packets:3179855 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2170162 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3832534893 (3.5 GB)  TX bytes:390304845 (372.2 MB)
C) Steps to be performed on the LOCAL MACHINE :-
  1. Install the required packages :-
*By default, package net-tools is already installed with OS. Run the command “ether-wake” to check whether the package is available or not, otherwise install them with following command.
# yum -y install net-tools
  1. Finally, Switch ON the machine remotely without physical access
When the server is not up, execute the following command from another machine which is connected to the same LAN. Once the magic packet is sent, the remote system will start to boot.
# ether-wake -i eth0 XX:XX:XX:XX:XX:XX [ Mac address ]
 Note :- ether-wake is a command to power on the system, -i is an interface option, eth0 is an interface of your local machine in which you are running ether-wake command and which will be used to power on the remote system having MAC as specified.

Tuesday, 3 May 2016

Configure PostgreSQL With Django Application

# su - postgres
# CREATE DATABASE projectdata;
#CREATE USER projectdatauser WITH PASSWORD ‘password’;
#ALTER ROLE projectdatauser SET client_encoding TO ‘utf8’;
#GRANT ALL PRIVILEGES ON DATABASE projectdata TO projectdatauser;
#django-admin.py startproject djangoproject
#vim djangoproject/djangoproject/settings.py
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'projectdata',                     
        'USER': 'projectdatauser',                     
        'PASSWORD': 'password',                 
        'HOST': 'localhost',                     
        'PORT': '5433',                     

save and exit
#cd  djangoproject
#./manage.py syncdb
#python manage.py runserver

Friday, 29 April 2016

create and mount ext4 filesystem


mkfs.ext4  "Device Name"


mke2fs -t ext4 "Device Name"

# mkfs.ext4 /dev/sda3

# mkdir /ext4_filesystem

# mount -t ext4 /dev/sda3  /ext4_filesystem

Burn CD or DVD from ISO file (CLI)

Assuming that you already have an ISO file and all you want to create CD based on the ISO 9660 standard. You can burn an ISO using below command,

# cdrecord -v -pad speed=1 dev=0,0,0 daddy-linux.iso
If you are not comfortable with the above mentioned process, follow below method.

First Identify CD ROM letter from /dev/

# ll /dev/ | grep -i cdrom
lrwxrwxrwx  1 root root
3 2010-09-30 15:13 cdrom -> sr0
lrwxrwxrwx  1 root root
3 2010-09-30 15:17 cdrom1 -> sr1

Here, sr0 is our first CD drive and you want to use same drive for burning,

# dd if=/root/Download/daddy-linux.iso of=/dev/sr0 bs=512
Here, if = Source place of an ISO file and of = Destination place or where to write.

Sunday, 24 April 2016

ImportError _psycopg.so: undefined symbol: lo_truncate64

If you are getting above error in psycopg2 , then for sure on loading an older libpq library is used than the one with which the psycopg2 was installed.

To identify which libpq is the psycopg.so is using issue below command, the output of command should point to right libpq.so file which is latest

ldd /path/to/venv/lib/python2.6/site-packages/psycopg2/_psycopg.so | grep libpq
libpq.so.5 => /usr/pgsql-9.4/lib/libpq.so.5 (0x00007f0d6c027000)

if above output is the correct .so file and you are still getting above error then, try to locate libpq.so in default libraries like /usr/lib64 (on centOS), For me it was below under /usr/lib64
lrwxrwxrwx.  1 root root       12 Mar 31 10:15 libpq.so.5 -> libpq.so.5.2
-rwxr-xr-x.  1 root root   162760 Feb 25  2014 libpq.so.5.2

As you can see the _psycopg.so for some reason is trying to load above libpq.so.5 which is an older one. So I removed this softlink file libpq.so.5 and created a new one which points to /usr/pgsql-9.4/lib/libpq.so.5 in /usr/lib64, by
issuing below commands
cd /usr/lib64
rm libpq.so.5
ln -s /usr/pgsql-9.4/lib/libpq.so.5 libpq.so.5

Above should fix the issue.