sandip's blog

Resetting WordPress admin password

Here is the sql to reset admin password for wordpress:

update wp_users set user_pass=md5("NEWPASS") where ID=1;

Even if the passwords are salted, you can still replace the password with an MD5 hash.

Install yum from centos vault

I had to update an old release of CentOS-5.5 on an OpenVZ container where yum was not available.

The below script should automatically download and install the required rpms from "vault.centos.org".

#!/bin/bash
# install_yum.sh
rpms="
        rpm-libs-4.4.2.3-18.el5.x86_64.rpm
        popt-1.10.2.3-18.el5.x86_64.rpm
        rpm-4.4.2.3-18.el5.x86_64.rpm
        python-elementtree-1.2.6-5.x86_64.rpm
        python-iniparse-0.2.3-4.el5.noarch.rpm
        python-sqlite-1.1.7-1.2.1.x86_64.rpm
        rpm-python-4.4.2.3-18.el5.x86_64.rpm
        python-urlgrabber-3.1.0-5.el5.noarch.rpm
        yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm
        yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm
        yum-3.2.22-26.el5.centos.noarch.rpm
"
for rpm in $rpms
do
rpm -Uvh --nodeps http://vault.centos.org/5.5/os/x86_64/CentOS/${rpm};
done

Disabling IDLE in courier-imap

Apple and BlackBerry email clients has a configurable setting to use the IMAP IDLE functionality to stay logged in, periodically checking email. This causes imapd to run out of daemons and stop responding. One solution is to raise MAXDAEMONS in /etc/courier-imap/imapd, but will eventually cause high loads on the server.

The better solution is to disable IDLE entirely in /etc/courier-imap/imapd by removing "IDLE" option from "IMAP_CAPABILITY".

Change:

IMAP_CAPABILITY="IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE"

To:

IMAP_CAPABILITY="IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA"

Upon courier-imap restart, this should prevent connections from persisting.

Telnet to imap port 143 to verify that the IDLE option is not present anymore in CAPABILITY response from the server.

My IP


IP Address: 54.166.250.213



force qmail to process mail queue

Use qmail-qstat or qmail-qread to check the messages in queue.

Run qmail-tcpok to clear out the TCP timeout table.

After that, send the "ALRM " signal to the "qmail-send" process, and Qmail will process all messages in the queue immediately:

kill -ALRM `ps ax | grep [q]mail-send | awk '{print $1}'`

monitor and kill long running mysql select statements

Below script checks and kills any sql SELECT statements that has been running for more than 60 seconds. The script can be added to a cron task to be run periodically. Make sure to check the log file it creates to keep an eye on the long running sql statements and tune it.

#!/bin/bash

LOG=/tmp/kill_mysql.log
SECONDS=60

echo "####" `date` "####" >>${LOG}
PIDS=$(mysql -t -e 'show full processlist' | awk -F'|' -v seconds="$SECONDS" '$7 > seconds  && toupper($9) ~ /^ SELECT/ {print $0}' | tee -a $LOG | awk -F'|' '{print $2}')
[ -n "$PIDS" ] && mysqladmin kill `echo $PIDS | tr ' ' ','`

Prior to running it, setup the root login in "~/.my.cnf" file with the login credentials:

[client]
user=root
password=xxxxxxxx

Install ImageMagick with PHP imagick extension on CentOS-5.8

You can easily install ImageMagick and PHP imagick extension from remi repository. There are some dependencies from epel repository too.

yum --enablerepo=remi,epel install ImageMagick.x86_64 php-pecl-imagick.x86_64

Wireless Ad-Hoc connection sharing in Ubuntu 10.10

  • dnsmasq-base has to be installed:

    sudo apt-get install dnsmasq-base

  • Remove dnsmasq because it conflicts with NetworkManager:

    sudo apt-get remove dnsmasq

  • Restart NetworkManager:

    sudo /etc/init.d/network-manager restart

  • Add a new wireless network with NetworkManager (left-click on NetworkManager icon, then select "Create New Wireless Network").
  • Set encryption to WEP 40/128-bit Key with a 13 characters key. (Note: You may have to experiment here according to what type of encryption with ad-hoc the device supports. WPA is not supported).
  • NetworkManager now should connect to itself (which means it creates the ad-hoc wireless network and routes any Internet traffic to your wired network interface). Now, connect with the client(s), and you should have a working Internet connection.
  • You have to make sure that this connection is shared to other computers and devices (clients). Make sure that the Connect automatically check-box is selected and on the IPv4 Settings tab make sure that the Method option is set to "Shared to other computers".

Updating OpenVZ vzctl on CentOS-5.8

While updating vzctl to latest on CentOS-5.8, I was getting the below error:

# yum update vzctl
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* openvz-kernel-rhel5: mirror.fdcservers.net
* openvz-utils: mirror.fdcservers.net
Excluding Packages in global exclude list
Finished
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package vzctl.x86_64 0:4.1-1 set to be updated
--> Processing Dependency: vzctl-core = 4.1-1 for package: vzctl
--> Processing Dependency: libvzctl-4.1.so()(64bit) for package: vzctl
--> Processing Dependency: libcgroup.so.1()(64bit) for package: vzctl
--> Running transaction check
---> Package libcgroup.x86_64 0:0.37-4 set to be updated
---> Package vzctl-core.x86_64 0:4.1-1 set to be updated
--> Processing Conflict: vzctl conflicts ploop-lib < 1.5-1
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package ploop-lib.x86_64 0:1.5-1 set to be updated
--> Processing Conflict: ploop-lib conflicts vzkernel < 2.6.32-042stab061.1
--> Processing Conflict: ploop-lib conflicts vzkernel < 2.6.32-042stab061.1
--> Processing Conflict: ploop-lib conflicts vzkernel < 2.6.32-042stab061.1
--> Processing Conflict: ploop-lib conflicts vzkernel < 2.6.32-042stab061.1
--> Finished Dependency Resolution
ploop-lib-1.5-1.x86_64 from openvz-utils has depsolving problems
  --> ploop-lib conflicts with ovzkernel
Error: ploop-lib conflicts with ovzkernel
You could try using --skip-broken to work around the problem
You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest
The program package-cleanup is found in the yum-utils package.

Turns out that ploop is no longer required for vzctl on CentOS-5.8 and can be removed:

yum update problem on CentOS 5.8 server

"Since you have RHEL5-based kernel that do not require ploop, you can remove ploop when installing vzctl-4.0. I have made vzctl not requiring ploop by dynamically loading it when it's available. Note that vzctl is not requiring ploop anymore, it just conflicts with the old version of it."

The solution was to remove ploop in single transaction as mentioned:

# yum shell
> update vzctl
> remove ploop\*
> run
> quit

iscsi notes

iscsi target

  • Install iscsi utils:
    yum install scsi-target-utils
  • Bring up tgtd:
    chkconfig tgtd on
    service tgtd start
  • Define an iscsi target name:
    # tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2012-10.com.linuxweblog.srv01:lv1_iscsi0
  • Delete specific iscsi target:
    # tgtadm --lld iscsi --op delete --mode target --tid 1
  • Add a logical unit to the target:
    # tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/vg1/lv1_iscsi0
  • Delete logical unit:
    # tgtadm --lld iscsi --op delete --mode logicalunit --tid 1 --lun 1
  • Enable the target to accept any initiators:
    # tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
  • View configuration:
    # tgtadm --lld iscsi --op show --mode target
  • Save the tgt conf:
    # tgt-admin --dump >/etc/tgt/targets.conf

iscsi initiator

  • install the initiator client:
    # yum install iscsi-initiator-utils
  • startup the iscsi daemon so all kernel modules get loaded:
    # chkconfig iscsid on
    # chkconfig iscsi on
    # service iscsid start
  • Discover targets:
    # iscsiadm --mode discovery --type sendtargets --portal 192.168.1.11
  • Login to target:
    # service iscsi restart
  • To manually login:
    # iscsiadm --mode node --targetname iqn.2012-10.com.linuxweblog.srv01:lv1_iscsi0 --portal 192.168.1.11 --login
  • To manually logout:
    # iscsiadm --mode node --targetname iqn.2012-10.com.linuxweblog.srv01:lv1_iscsi0 --portal 192.168.1.11 --logout
  • To delete targets:
    # iscsiadm --mode node --targetname iqn.2012-10.com.linuxweblog.srv01:lv1_iscsi0 --portal 192.168.1.11 -o delete
  • List sessions:
    # iscsiadm -m session
  • List nodes:
    # iscsiadm -m node

Syndicate content
Comment