Categories

Tuesday, 25 March 2014

psql: FATAL: parameter "listen_addresses" cannot be changed without restarting the server

Hi,

We faced an issue on one of the machine, where the postgresql commands are not runnning as root. Always getting the below error while executing any psql command

psql: FATAL:  parameter "listen_addresses" cannot be changed without restarting the server.

Initially I thought it was some thing to do with the settings on the pg_hba.conf file and postgresql.conf file where the variable listen_address is specified .The variable listen_adresses has been changed on postgresql.conf from

listen_addresses = '*'

to

listen_addresses = '10.11.16.112'

Then restarted the postgresql service. But still got the same error. One of the strange thing is that I am able to connect to postgresql command line from another machine to the machine having issue, but not from with in the machine as root.

Finally On checking, I found that there was a variable named PGOPTIONS was the issue.  Below is the steps I had done to resolve it.

Find the value of variable PGOPTIONS on the command line using the command

echo $PGOPTIONS
-i

SO I found out that the variable was defined in the server some where . I found out the variable on the environment file /etc/environment.

I changed the value from -i to Null value on /etc/environment

vi /etc/environment
PGOPTIONS=""


 Now the command echo $PGOPTIONS showed the null value

And now I am able to execute any psql command operations like pg_dump.

Regards
Syamkumar.M




Monday, 24 March 2014

/etc/rc.local not running on the boot

Hi,

   /etc/rc.local is the file which runs once the system boots up. If we need to run few commands immediately once the system starts up, we can do it by adding those commands in /etc/rc.local.

Last week I faced an issue in which the commands inside the rc.local was not working, once the system boot.  I tried starting and stopping the systems so many times and tried to change the settings of /etc/rc.local, but still it was not working.  Then I read in one of the Centos Forums that it was some issue with the first boot.

In my machine firstboot got hanged and init was not able to execute the content inside /etc/rc.local. Below is the steps to resolve it

check to see if firstboot is still running and kill it:


ps ax |grep firstboot
killall firstboot


This will kill the first boot .

Then switch the firstboot permenantly using chkconfig

chkconfig firstboot off


The first boot issue was caused by some of the software installations which may confuse the firstboot.

Regards
Syamkumar.M
 

Tuesday, 18 March 2014

How to change ulimit values permanently for a user in Centos

Hi,

ulimit is the parameter which defines the limits a process can use on a linux system.  It will provide control over the resources a user or a process in a shell can use.  You can list the current setting of ulimit values by login as your user and type the following commands

# ulimit -Hn
# ulimit -Sn


Default values should be 4096 and 1024 respectively.
 

So it will also determine the number of open files a user can open or edit. For increasing the ulimit, you need to change those paramentes in a configuration file called

/etc/security/limits.conf

If I need to change the ulimit value for my user on  a linux system. Then you should login to machine as root.

Open the above file in editor and then add the following content to it.

syam        soft nofile 9000
syam        hard nofile 65000



Now you should see the changes to the ulimit value for a user when you switch user from the root. But still the limit won't get reflected when user login as ssh with the password. We need to add the following steps to get the changes reflected for the user upon ssh login as user .


  1. In /etc/pam.d/sshd added the line
session required pam_limits.so
  1. In /etc/pam.d/login added the line
session required pam_limits.so
  1. In /etc/ssh/sshd_config added
UsePAM yes

Now restart the sshd service

4. /etc/init.d/sshd restart

Now the ulimit values will be changed permenantly and you can see the values once you ssh into the machine as user.


ulimit -Hn
65000

ulimit -Sn

9000

Regards
Syamkumar.M




Tuesday, 11 March 2014

How to Delete a line from gz file having huge size

Hi,

We got a task to delete a specific line from a 6Gb gzip file. Below is the steps followed to delete the line.

1)Use zgrep to search through the gzip files

zgrep is used to search a line or pattern from the gzipped file. The output will be same as that of grep command on a normal file. Here we use the command as below. There is a specific pattern on that line through which we need to find the line number and then delete the line from that file using sed.

zgrep -in pattern test1.gz

2)From the above command we got the line number which we need to delete. It is 5344402. Then we need to use sed command to delete line on that line number. But we can't use sed on a gzipped file. So we need to unzip the file

unzip test.gzsya

3)Now we can use sed command to delete that line from the test file

sed -i '5344402d' test

Above command will delete the line on that line number of the file.

4)Again zip the file

zip test






Thats all
Thanks

Monday, 3 March 2014

Switch off redirection from http to https in DirectAdmin

Hi,

Below is the steps to disable redirection from http to https in the direct admin Login page. Default Direct admin Login URL is http://domainname:2222, where 2222 is the port used by Direct admin.

The DirectAdmin configuration file is

/usr/local/directadmin/conf/directadmin.conf

Open it in a text editor like vi to view its content

It contains all the default configuration for the directadmin like port and ssl.

Search for ssl in the file

SSL=1
cacert=/usr/local/directadmin/conf/cacert.pem
cakey=/usr/local/directadmin/conf/cakey.pem


You will get the result as above which contains certificate file location for the self signed certificate the directadmin is using.

You can turn the ssl off so that it will no longer redirect from http to https.

 SSL=0

Save the file and exit

Similarly if you need to change another port for directadmin Admin url you can change it in the above  configuration file.


Regards
Syamkumar.M




Ad