Categories

Thursday 3 October 2013

Change Postgresql Data Directory

Hi,

Currently there was some disk issue on our server in which some script is importing huge amount of data on the postgresql datbases which filled up the disk space on the machine and stopped all the services .

/ had only 20 GB of disk space .

Postgresql is installed in the directory  /var/lib/pgsql/9.3/data for the postgresql version9.3 . The configuration file of postgresql is postgresql.conf, log files and all other important files are located in that directory

As /var is not a seperate partition, the data directory got filled and which inturn filled up the / partition.

So we need to either change the data directory to /attached which had almost 5 TB of disk space.

Changing the data directory of postgresql seems to be tedious task.

One work around for that issue is to move the data directory /var/lib/pgsql/9.3/data to /data and then create a symlink to /attached/data.

Below is the procedure for it

1) First stop the postgresql service
2)move the data directory to /attached by using the command

mv /var/lib/pgsql/9.3/data /attached

3)now create a sym link to /attached/data from /var/lib/pgsql/9.3/

ln -s /attached/data /var/lib/pgsql/9.3/data

So now the postgresql will check the configuration files and datas inside the same folder /var/lib/pgsql/9.3/data , but it is symlinked to /attached/data. So the actual files will store in /attached/data and won't fill  up /.

4)Restart the postgresql service

/etc/init.d/postgresql-9.3 start

5)Test if it is working perfectly.

su - postgres
-bash-4.1$ ll
total 4
drwx------. 3 postgres postgres 4096 Oct  3 04:31 9.3
-bash-4.1$ psql
psql (9.3rc1)
Type "help" for help.

postgres=# show data_directory ;
     data_directory    
-------------------------
 /var/lib/pgsql/9.3/data
(1 row)

postgres=#



Cheers
Syamkumar.M


Tuesday 1 October 2013

MTS Data Card Installation in ubuntu 12.04

Hi,

For configuring the MTS Mblaze Datacard on ubuntu, Please do the following steps.

1)First install the service wvdial.

sudo apt-get install wvdial


2) Then create a configuration file /etc/wvdial.conf and add the following configurations on it.

[Dialer mts]
Stupid Mode = 1 
Inherits = Modem0 
Password = mts 
Username = internet@internet.mtsindia.in 
Phone = #777 
[Modem0] 
Init1 = ATZ 
SetVolume = 0 
Modem = /dev/ttyUSB0 
Baud = 115200 
FlowControl = Hardware (CRTSCTS) 
Dial Command = ATDT 
  
3) After this just plugin the the MTS data card on the ubuntu machine. The data card will be automatically detected on the ubuntu machine.

After this run the following command

  sudo wvdial mts


 --> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ
OK
--> Modem initialized.
--> Sending: ATDT#777
--> Waiting for carrier.
ATDT#777
CONNECT 3100000
--> Carrier detected.  Starting PPP immediately.
--> Starting pppd at Tue Oct  1 21:21:48 2013
--> Pid of pppd: 8718
--> Using interface ppp0
--> local  IP address 116.202.128.90
--> remote IP address 10.228.138.3
--> primary   DNS address 10.228.129.113
--> secondary DNS address 10.228.129.114








Now you will be able to connect to the machine.



Also you can configure it on the Network Manager. For this do the following steps.

1)Click on the Connections Tab on the right side of your desktop.
2)Click on Edit Connections on the bottom
3)Go to the Mobile Broad Band Tab
4)Click on Add connections and give the necessary details 
5)Select the provider as MTS Mblaze and then add
6)Give any connection name

Then on the Mobile Broad Band settings Add the following

Number - #777
username - internet@internet.mtsindia.in
password - mts

Save it and then connect it after you plugged in the Data Card





.

Unable to connect to remote host: No route to host for postgresql

Hi,

When trying to connect to an postgresql database from outside, you may get the error as below " Unable to connect to remote host: No route to host for postgresql"

Here Iam using the postgresql version 9.3
Steps to check

1) First check the iptables rules on the server. If there is any unusual logs then flush it or try after stopping the iptables service using the command

/etc/init.d/iptables stop

2)Even after this if you are still unable to connect to the postgresql server, then do check the following

The postgresql default data directory in linux is   /var/lib/pgsql/9.3/data/

The configuration file for the service is postgresql.conf.

Open that file and search for the option  listen_addresses and make it to listen on all of the interfaces or IPs on that machine as below.

 listen_addresses = '*'

Now exit the configuration file after saving it.

3)Then go the configuration file  pg_hba.conf in the data directory /var/lib/pgsql/9.3/data/

This file controls the connection information of postgresql.

Open that file  and edit the configuration options as below

# IPv4 local connections:
host    all         all         127.0.0.1/32          trust
host    all             all             192.168.0.0/16            trust
# IPv6 local connections:

Above configuration will make the postgresql to listen on all hosts with the subnet range 192.168.0.0/16 . So add it based on your requirement.

Now save the file and then restart the postgresql database using the below command.

/etc/init.d/postgresql restart

Now try to connect to the database.

Also check for any startup errors on the log file /var/lib/pgsql/9.3/pgstartup.log


Regards
Syamkumar.M




Ad