Thursday, May 24, 2012

Instead of Samba use Centrify

I've used samba for a long time and love it, but I ran into a product called Centrify that is so easy to setup and use for kerberos authentication against a Windows Active Directory that I don't think I'm going back to samba.

Here is a very brief explanation of how I set it up on my Linux Server.


Download Centrify Suite and the centrify samba package.

1. Uninstall your current ssh and samba.
2. Login as "root"
3. Extract the files.
4. Run "install-express.sh"
5. Answer all the questions.
6.  Reboot.
7.  Install the samba packages.


Make the following changes in /etc/centrify/centrifydc.conf file.
Change the shell from /bin/bash to /bin/ksh
Change the auto.schema.primary.gid: 100
Change the auto.schema.private.group: false

Create a group.ovr file in /etc/centrify/  Add the following line:
+domain users:users:::

Move MySQL to a different Directory


Steps I use to install MySQL to a different directory.   The truth is I just use the rpm and let it install in the default /var/lib/mysql on Redhat and then I do the following to move it to another directory.

After the install I setup my my.cnf file and then start MySQL.   I don't think it is necessary to start it, but I do so that the ib files can be created.  I then stop MySQL.   I cd to /var/lib and move the mysql directory to wherever I want.  In my case I move it to my /data directory which is on a different filesystem.

So I issued this command mv mysql /data
Then I create a symbolic link to my new mysql location by using this command:
ln -s /data/mysql mysql

Now under /var/lib/ I have a symbolic link that points to /data/mysql.   If I cd to /var/lib/mysql I will be in /data/mysql.

One reason I do this is I don't like to have data in my root partition in case I fill it up.  Also, in my setup I don't have enough room in my root partition to host mysql.

After making this change I started to get this error:
starting mysql.the server quit without updating pid file failed.   I've seen this error before and it is usually a permission issue.   I checked my permissions and the permissions were fine.  

The problem is selinux the iptables or firewall.
To check run this command:
semodule -l 

Check and see if mysql is in the list?

Now temporarily disable selinux with this command:

echo > 0 /selinux/enforce

or 

service iptables stop

Now try to start MySQL.  Did it start?  Mine Did.

Now you know the problem is with selinux.  You have a few chooses:

1. you can disable selinux by adding SELINUX=disabled in /etc/selinux/config.  The lease secure, but fastest fix.
2. You can disable the mysql module in selinux.  To disable mysql run this command:

semodule -v -d mysql  or semodule --disable=mysql

To re-enable module run this command:
semodule -v -e mysql or semodule --enable=mysql

The "-v" is verbose and is not necessary.

3. You can keep it enabled, but follow the information in this link:

Tuesday, May 22, 2012

LVM INACTIVE

After a reboot I noticed that my iSCSI LVM was missing.   I did an lvscan and it was listed, but as INACTIVE.

I ran lvchange -a y /dev/vg_nobakcup/lg_nobackup and the logical volume became active again.
I ran a lvscan to verify it was active.  
I then mounted the volume.
Upon reboot I had the same problem, so I added lvchange -a y /dev/vg_nobackup/lg_nobackup and rebooted again.   This time the volume was active and mounted.  PROBLEM SOLVED.

I believe the issue is this is an iSCSI Volume connecting to Microsoft's iSCSI Storage server.  I believe the connection just times out before connecting.  

Installing Redhat 6.2 & Linux Integration Services on Hyper-V

I installed Redhat 6.2 today.  I added Linux integration services 3.2 and after I added the service I no longer had a cdrom drive or my networks.   So this time I'm trying a little different approach.  I believe this is what I did the first time and it worked.
Before you install Redhat 6.2 add a legacy network card to your settings.   Redhat will recognized the legacy network adapter, but not the normal network adapter.

Once you have configured Redhat and it has rebooted you will have a desktop, but you won't be able to do anything with the desktop because you don't have mouse or keyboard control.  You need to install the Linux Integration Services.   Press "CTRL+ALT+F2" at the same time.   This will will give you a terminal window.  Login as root.

In Hyper-V go to Media under Virtual Machine Connection and attach the iso file as a DVD drive.

Once it is attached use the mount command on Linux to mount the DVD.

mount /dev/cdrom /media
cd to /media
run install.sh
reboot
After the reboot the clock will work, the mouse will work, the keyboard will work, the network adapter will work.   
Now you ready to use your new Redhat 6.2.
After Installing Linux Integration Services 3.2 you will no longer have a cdrom.
You will need to run this command:
insmod /lib/modules/$(uname -r)/kernel/drivers/ata/ata_piix.ko 
for the cdrom to mount.

Wednesday, May 16, 2012

Adding LVM from command line

This is how you setup a Physical Disk, Volume Group and a Logical Volume using the command line in Linux.

This example will be from a Redhat Enterprise 6.2 Installation.

So we will create a Physical Disk, Physical Volume, then a Volume Group, then a Logical Volume and then mount the volume.  Type only what is in "red".
 


Step #1 - Find out what device your new hard drive is assigned.

fdisk -l 

You should see all your disk including the one that you just added.  Here is the one that I just added.  

Disk /dev/sdb: 343.6 GB, 343597383680 bytes
255 heads, 63 sectors/track, 41773 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       41774   335544319+  8e  Linux LVM

Our new device is called "/dev/sdb1"

Step #2 - Partition the disk with fdisk. (Create Physical Disk)

fdisk /dev/sdb1
m - to see all the command options
n - to add the new partition
p - to make it a primary partition
1 - to make it the 1st partition
First cylinder (1-41773, default 1):  PRESS ENTER
Last cylinder, +cylinders or +size{K,M,G} (1-41773, default 41773): PRESS ENTER

***NOW WE NEED change the partition's system id
t - to change the partition's system type
L - to list all the system type
FOR LVM type 8e
8e - for LVM PRESS ENTER
w - to write table to disk and exit.

STEP #3 - Create a Physical Volume with pvcreate.

pvscan - will show you the physical volumes.
PV /dev/sda2   VG vg_redhat62   lvm2 [69.51 GiB / 0    free]
  Total: 1 [69.51 GiB] / in use: 1 [69.51 GiB] / in no VG: 0 [0   ]

As you can see our new physical disk does not show up.  It will show up after we create a physical volume.
pvcreate /dev/sdb1 - creates the physical volume.
 Writing physical volume data to disk "/dev/sdb1"
  Physical volume "/dev/sdb1" successfully created
pvscan - will now show our new physical volume
 PV /dev/sda2   VG vg_redhat62     lvm2 [69.51 GiB / 0    free]
  PV /dev/sdb1                      lvm2 [320.00 GiB]
  Total: 2 [389.51 GiB] / in use: 1 [69.51 GiB] / in no VG: 1 [320.00 GiB]

STEP #4 - Create the Volume Group
 vgcreate vg_data /dev/sdb1 - This creates the Volume Group.  give it a name and point it to your physical disk.
  Volume group "vg_data" successfully created
You can run either vgscan or vgdisplay to see your new Volume Group.

STEP #5 - Create a Logical Volume
lvcreate -l 100%FREE -n lg_data vg_data - This creates the Logical Volume.
  Logical volume "lg_data" created
The "-l 100%FREE" mean to use 100% of available space and "-n" is for naming.  So I called the new Logical Volume "lg_data" and pointed it to my new Volume Group "vg_data".

To check on the new Logical Volume run either lvscan or lvdisplay.
lvscan
  ACTIVE            '/dev/vg_data/lg_data' [320.00 GiB] inherit
  ACTIVE            '/dev/vg_redhat62/lv_root' [33.14 GiB] inherit
  ACTIVE            '/dev/vg_redhat62/lv_home' [28.67 GiB] inherit
  ACTIVE            '/dev/vg_redhat62/lv_swap' [7.70 GiB] inherit

STEP #6 - Format the new Logical Volume
 mkfs.ext4 -m 0 /dev/vg_data/lg_data - File type is ext4 the "-m 0" don't reserve disk space for superuser. It save 5%
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
20971520 inodes, 83885056 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
2560 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

STEP #7 - Mount the Logical Volume
Create a directory that you want to mount the volume to.
mkdir data
mount /dev/vg_data/lg_data /data

These steps created a physical disk, a physical volume, a Volume group, a Logical volume, formatted the volume and mounted it.
 df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_redhat62-lv_root
                       33G  2.5G   29G   9% /
tmpfs                 2.8G  272K  2.8G   1% /dev/shm
/dev/sda1             485M   53M  407M  12% /boot
/dev/mapper/vg_redhat62-lv_home
                       29G  174M   27G   1% /home
/dev/mapper/vg_data-lg_data
                      315G  195M  299G   1% /data

As you can see are new LVM is listed last and is mounted.