Thursday, August 30, 2012

Disabling virbr0

I notice there is virbr0 interface on my CentOS Machine. There is no kvm running on this machine so I guess there is no need for this interface.
virbr0    Link encap:Ethernet  HWaddr 52:54:00:56:BD:B2
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:55 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:9410 (9.1 KiB)
To disable, just do the following:
[root@centosprod1 iptables-1.4.7]# virsh net-list
Name                 State      Autostart
-----------------------------------------
default              active     yes

[root@centosprod1 iptables-1.4.7]# virsh net-destroy default
Network default destroyed

[root@centosprod1 iptables-1.4.7]# virsh net-undefine default
Network default has been undefined

[root@centosprod1 iptables-1.4.7]# service libvirtd restart
Stopping libvirtd daemon:                                  [  OK  ]
Starting libvirtd daemon: 16:46:33.012: 2051: info : libvirt version: 0.9.4, package: 23.el6 (CentOS BuildSystem , 2011-12-08-01:26:50, c6b18n3.bsys.dev.centos.org)
16:46:33.012: 2051: warning : virGetHostname:1884 : getaddrinfo failed for 'centosprod1': Name or service not known
                                                           [  OK  ]
virbr0 is now gone. Verify it by running ifconfig -a
[root@centosprod1 iptables-1.4.7]# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:80:8D:19
          inet addr:10.0.1.101  Bcast:10.0.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe80:8d19/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:743 errors:0 dropped:0 overruns:0 frame:0
          TX packets:708 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:71738 (70.0 KiB)  TX bytes:111377 (108.7 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:78 errors:0 dropped:0 overruns:0 frame:0
          TX packets:78 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:6054 (5.9 KiB)  TX bytes:6054 (5.9 KiB)

[root@centosprod1 iptables-1.4.7]# virsh net-list
Name                 State      Autostart
-----------------------------------------

Monday, August 27, 2012

apu library not found

I'm compiling mod_security to patch with apache. However, I encountered the following when patching mod_security with the command apxs on the apache.
checking for libapu config script... no
configure: *** apu library not found.
configure: error: apu library is required
Solution:
Install apr-util-devel. I install it via yum and this resolves the error.
yum -y install apr-util-devel

Sunday, June 17, 2012

bind mysql port to an ip address

I've been setting up servers for so many times and it was been my habit that all my applications/services should be listening on one of server's ip address. I just installed MySQL and by default, it listen to 0.0.0.0. Server's ip address is 10.0.1.101 and I would like to listen it to that ip address instead of 0.0.0.0. To change this, you should have an entry bind-address on your /etc/my.cnf.
bind-address=10.0.1.101
You should restart mysqld. Reloading mysqld would not work. I tried it but it didn't work I guess I need to stop also all applications writing to the database.
[root@centosprod1 ~]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 10.0.1.101:22               0.0.0.0:*                   LISTEN      21154/sshd
tcp        0      0 127.0.0.1:32000             0.0.0.0:*                   LISTEN      18834/veaintf
tcp        0      0 0.0.0.0:5634                0.0.0.0:*                   LISTEN      17820/xprtld
tcp        0      0 10.0.1.101:3306             0.0.0.0:*                   LISTEN      21376/mysqld
tcp        0      0 :::5634                     :::*                        LISTEN      17820/xprtld
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               1092/dhclient

Wednesday, May 16, 2012

VxVM not mounting on boot up

I notice that the Volume I have created under Veritas doesn't mount on boot even though it was on /etc/fstab. I'm using CentOS 6. Below is my entry on /etc/fstab
/dev/vx/dsk/datadg/datavol /file ext4 defaults,_netdev 0 0
I found out that it requires netfs so I add it on boot and it was now mounting after the reboot
[root@centosprod1 ~]# chkconfig --list | grep 3:on | grep netfs
netfs           0:off   1:off   2:on    3:on    4:on    5:on    6:off

Monday, May 14, 2012

How to add device in LVM

My current setup is Raid5 with 2 Device. I decided to add a new disk so I need to configure Raid5 with 3 device. Below are the procedures that I did.

Record first your existing setup
[root@centosprod1 ~]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdf1[2] sdg1[3]
      1043968 blocks super 1.2 level 5, 512k chunk, algorithm 2 [2/2] [UU]

unused devices: 
[root@centosprod1 ~]# mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Mon May  7 14:35:19 2012
     Raid Level : raid5
     Array Size : 1043968 (1019.67 MiB 1069.02 MB)
  Used Dev Size : 1043968 (1019.67 MiB 1069.02 MB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Mon May 14 12:52:21 2012
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

           Name : centosprod1:0  (local to host centosprod1)
           UUID : f443db62:a4ff36fd:ab0706e4:d9e299cc
         Events : 104

    Number   Major   Minor   RaidDevice State
       3       8       97        0      active sync   /dev/sdg1
       2       8       81        1      active sync   /dev/sdf1
We will now add the new device /dev/sde1
[root@centosprod1 ~]# mdadm --add /dev/md0 /dev/sde1
mdadm: added /dev/sde1
[root@centosprod1 ~]# mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Mon May  7 14:35:19 2012
     Raid Level : raid5
     Array Size : 1043968 (1019.67 MiB 1069.02 MB)
  Used Dev Size : 1043968 (1019.67 MiB 1069.02 MB)
   Raid Devices : 2
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Mon May 14 13:02:13 2012
          State : clean
 Active Devices : 2
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 1

         Layout : left-symmetric
     Chunk Size : 512K

           Name : centosprod1:0  (local to host centosprod1)
           UUID : f443db62:a4ff36fd:ab0706e4:d9e299cc
         Events : 105

    Number   Major   Minor   RaidDevice State
       3       8       97        0      active sync   /dev/sdg1
       2       8       81        1      active sync   /dev/sdf1

       4       8       65        -      spare   /dev/sde1
The disk has been added but you would notice that it is still spare. We will now set our raid array to have 3 devices
[root@centosprod1 ~]# mdadm --grow /dev/md0 --raid-devices=3
mdadm: Need to backup 1024K of critical section..
[root@centosprod1 ~]# mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Mon May  7 14:35:19 2012
     Raid Level : raid5
     Array Size : 1043968 (1019.67 MiB 1069.02 MB)
  Used Dev Size : 1043968 (1019.67 MiB 1069.02 MB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Mon May 14 13:03:28 2012
          State : clean, reshaping
 Active Devices : 3
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

 Reshape Status : 8% complete
  Delta Devices : 1, (2->3)

           Name : centosprod1:0  (local to host centosprod1)
           UUID : f443db62:a4ff36fd:ab0706e4:d9e299cc
         Events : 120

    Number   Major   Minor   RaidDevice State
       3       8       97        0      active sync   /dev/sdg1
       2       8       81        1      active sync   /dev/sdf1
       4       8       65        2      active sync   /dev/sde1
The new disk has successfully added.
[root@centosprod1 ~]# mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Mon May  7 14:35:19 2012
     Raid Level : raid5
     Array Size : 1043968 (1019.67 MiB 1069.02 MB)
  Used Dev Size : 1043968 (1019.67 MiB 1069.02 MB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Mon May 14 13:10:00 2012
          State : clean, reshaping
 Active Devices : 3
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

 Reshape Status : 63% complete
  Delta Devices : 1, (2->3)

           Name : centosprod1:0  (local to host centosprod1)
           UUID : f443db62:a4ff36fd:ab0706e4:d9e299cc
         Events : 157

    Number   Major   Minor   RaidDevice State
       3       8       97        0      active sync   /dev/sdg1
       2       8       81        1      active sync   /dev/sdf1
       4       8       65        2      active sync   /dev/sde1

Saturday, May 5, 2012

How to convert Putty's ppk to be compatible with SecureCRT

I'm using Putty to connect to my server. However, it is much comfortable to use SecureCRT. I have .ppk use in my Putty to connect to some of our server. Since I'll be using SecureCRT, I have to convert into a format SecureCRT will understand.

To convert .ppk to .pub, do the ff:

1. Run "puttygen.exe". The "PuTTY Key Generator" dialog will appear.

2. Use the "Load" button to load the .ppk file that contains your private key. If your private key file is protected with a passphrase, you will be prompted to supply the passphrase in order to complete the loading of the private key.

3. Once the private key has been loaded properly, choose "Export OpenSSH key" from the main "Conversions" pull-down menu that is part of the "PuTTY Key Generator" window.

4. When the "Save private key as:" window appears, specify a filename for the private key file such as "Identity" and choose "Save".

NOTE: The private key file name should not have any extension associated with it. For example, if SecureCRT is configured to use a public key named "Identity.pub", it expects to find the private key in the same folder as the public key file, with the name of "Identity".

Similarly, if SecureCRT is confgured to use a private key named "Identity", it expects to find a the public key in a file named "Identity.pub" located in the same folder as the private key file.

Now you will need to export the public key to a file format that follows the IETF SecSH internet-draft.

5. Choose "Save public key". When the "Save public key as:" window appears, specify a filename for the public key file, such as "Identity.pub", and choose "Save".

NOTE: It is important for use with VanDyke Software products that the public and private key files both share the same basename. For example, if you named your private key file "Identity" as suggested in step 4 above, the public key file should be saved as "Identity.pub".

Once you have completed the steps outlined above, you will be able to use your Identity and Identity.pub files with VanDyke Software products.

How to convert .crt to .pem

If you'll be converting .crt to .pem, you may use the ff commands
openssl x509 -in server.crt -out server.der -outform DER
openssl x509 -in server.der -inform DER -out server.pem -outform PEM
Verify first if your key is in PEM format. Mostly, they begin in --BEGIN and can read with a text editor. If you'll be converting .key to .pem, just replace openssl x509 with openssl rsa. Normally, server.key is your private key and server.crt is your signed or returned certificate.