Solved

Accessing mysql database

Posted on 2015-02-18
29
147 Views
Last Modified: 2015-04-13
I've booted into linux CentOS with a new insatll on a new drive.All I need is the mysql database on the raid drive.
How can I access this and copy to dev/sda1  

The mysql data is in /dev/mapper/VolGroup00-LogVol00
[root@a1 ~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                     232665848   2083956 218572420   1% /
/dev/sda1               101086     12446     83421  13% /boot
tmpfs                   968488         0    968488   0% /dev/shm
0
Comment
Question by:shaunwingin
  • 16
  • 8
  • 5
29 Comments
 
LVL 24

Expert Comment

by:Tomas Helgi Johannsson
ID: 40618412
Hi!

If you have mounted the drive and you can access the data on the drive by simply changing into the desired source directory then you simply issue (as root ) a copy command (cp ) from source to destination folder.
It seems that your /dev/sda1 is a /boot partition for your disk/system and I would not copy mysql folder to that partition.

Regards,
     Tomas Helgi
0
 

Author Comment

by:shaunwingin
ID: 40618520
Pls assist with mounting the drive - no idea how to.

[root@a1 ~]# fdisk -l

Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       30401   244091610   8e  Linux LVM

Disk /dev/sdb: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          13      104391   83  Linux
/dev/sdb2              14       30272   243055417+  8e  Linux LVM

Disk /dev/sdc: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1          13      104391   83  Linux
/dev/sdc2              14       30272   243055417+  8e  Linux LVM
[root@a1 ~]#
0
 

Author Comment

by:shaunwingin
ID: 40618542
[root@a1 /]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
[root@a1 /]#
0
 

Author Comment

by:shaunwingin
ID: 40618543
[root@a1 /]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                     232665848   2082652 218573724   1% /
/dev/sda1               101086     12446     83421  13% /boot
tmpfs                   968488         0    968488   0% /dev/shm
[root@a1 /]#
0
 
LVL 24

Expert Comment

by:Tomas Helgi Johannsson
ID: 40618559
Hi!

It is already mounted on the / (root directory) as I can tell from your post.
The mysql data directory is usually located in the directory-path /var/lib/mysql.

If you want to copy that directory to another then make sure your mysql server is down.

Regards,
     Tomas Helgi
0
 

Author Comment

by:shaunwingin
ID: 40618598
There are two hard disks - the sda1 which has a mysql directory.
I wish to access

/dev/mapper/VolGroup00-LogVol00
                     232665848   2082652 218573724   1%

This has the old my sql directory.
0
 
LVL 24

Expert Comment

by:Tomas Helgi Johannsson
ID: 40618675
Hi!

What does the command
fdisk -l
give you ?

Regards,
     Tomas Helgi
0
 

Author Comment

by:shaunwingin
ID: 40618749
0
 
LVL 24

Expert Comment

by:Tomas Helgi Johannsson
ID: 40618752
Hi!

You should be able to do
cd /var/lib/mysql
and you are in your old mysql directory.

Regards,
     Tomas Helgi
0
 

Author Comment

by:shaunwingin
ID: 40618755
I go to the new one with above.
How would I get to the new mysql - its the same path...
0
 

Author Comment

by:shaunwingin
ID: 40618791
In Webmin I can see 2 logical volumes:

/dev/mapper/VolGroup00-LogVol00

and

/dev/mapper/VolGroup00-LogVol01

seems the 1st is available from  /
How to I access 2nd?
0
 
LVL 24

Expert Comment

by:Tomas Helgi Johannsson
ID: 40618830
Hi!

Issue the command
lvscan
then you should see both volume groups.

Take the inactive volume group
and issue
lvdisplay <inactive volume group>
look for LV NAME
issue activate on the Logical  Volume  name
lvchange -a y logicalvolname
and issue mount on LV NAME path

https://www.centos.org/docs/5/html/Cluster_Logical_Volume_Manager/active_mount_ex3.html
http://linuxers.org/howto/how-mount-linux-lvm-volume-partitions-linux

Regards,
    Tomas Helgi
0
 
LVL 76

Assisted Solution

by:arnold
arnold earned 500 total points
ID: 40619390
Here is what you need to do:
lvmdiskscan
you've already ran fdisk -l parted -l
pvdisplay
vgdisplay
lvdisplay

/dev/sda1 is your boot partition of size  100 MB there is no space there to move or have mysql .....


Unless you have the LVM handle the RAID, I do not see a raid drive
None of the filesystems reported in the fdisk -l have linux RAID

Though puzzling you are thinking of setting up the data on RAID but not the /boot

It too can be on a raid volume
though the raid volume can not be of LVM type.

Once you post the output from the above commands, it will be clearer what your system's setup is.
0
 

Author Comment

by:shaunwingin
ID: 40621015
Tx.

To recap - 2 Drives are in Mirror 1 and controlled by a "Bios RAID" - type of software RAID. On this RAID is the MySQL database I wish to retrieve.

I've installed a fresh copy of CentOS on a 3rd Dis and booted of this. I can get to the mysql directory on this drive but not to that on the "RAID" drive.

lvmdiskscan
  /dev/ramdisk                 [       16.00 MB]
  /dev/root                    [      229.06 GB]
  /dev/ram                     [       16.00 MB]
  /dev/sda1                    [      101.94 MB]
  /dev/VolGroup00/LogVol01     [        3.72 GB]
  /dev/ram2                    [       16.00 MB]
  /dev/sda2                    [      232.78 GB] LVM physical volume
  /dev/mapper/pdc_ecgdbbhfgj   [      231.90 GB]
  /dev/ram3                    [       16.00 MB]
  /dev/mapper/pdc_ecgdbbhfgjp1 [      101.94 MB]
  /dev/ram4                    [       16.00 MB]
  /dev/mapper/pdc_ecgdbbhfgjp2 [      231.80 GB] LVM physical volume
  /dev/ram5                    [       16.00 MB]
  /dev/ram6                    [       16.00 MB]
  /dev/ram7                    [       16.00 MB]
  /dev/ram8                    [       16.00 MB]
  /dev/ram9                    [       16.00 MB]
  /dev/ram10                   [       16.00 MB]
  /dev/ram11                   [       16.00 MB]
  /dev/ram12                   [       16.00 MB]
  /dev/ram13                   [       16.00 MB]
  /dev/ram14                   [       16.00 MB]
  /dev/ram15                   [       16.00 MB]
  /dev/sdb1                    [      101.94 MB]
  /dev/sdb2                    [      231.80 GB]
  /dev/sdc1                    [      101.94 MB]
  /dev/sdc2                    [      231.80 GB]
  4 disks
  21 partitions
  0 LVM physical volume whole disks
  2 LVM physical volumes
You have new mail in /var/spool/mail/root
[root@a1 mnt]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/mapper/pdc_ecgdbbhfgjp2
  VG Name               VolGroup00
  PV Size               231.80 GB / not usable 14.81 MB
  Allocatable           yes (but full)
  PE Size (KByte)       32768
  Total PE              7417
  Free PE               0
  Allocated PE          7417
  PV UUID               j3jNjX-SbV2-AcW7-w6Tm-JMVi-rBfc-V1iXPb

  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               VolGroup00
  PV Size               232.78 GB / not usable 2.71 MB
  Allocatable           yes (but full)
  PE Size (KByte)       32768
  Total PE              7449
  Free PE               0
  Allocated PE          7449
  PV UUID               i8IKuu-k30p-jqoO-yRV0-QfqH-8cyi-SK4n1I

[root@a1 mnt]# vgdisplay
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               231.78 GB
  PE Size               32.00 MB
  Total PE              7417
  Alloc PE / Size       7417 / 231.78 GB
  Free  PE / Size       0 / 0
  VG UUID               AFzr9J-YbQ0-pD1u-JKfj-hasE-LuNx-vnOxIO

  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               232.78 GB
  PE Size               32.00 MB
  Total PE              7449
  Alloc PE / Size       7449 / 232.78 GB
  Free  PE / Size       0 / 0
  VG UUID               TWiCip-q5Vt-6BE2-WCWz-KmGn-pDTp-kMrXgQ

[root@a1 mnt]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                OfNYTY-T0RM-d8Bx-9GM3-y3E2-z2lh-6bWGau
  LV Write Access        read/write
  LV Status              NOT available
  LV Size                228.06 GB
  Current LE             7298
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                e9c2oV-oGVm-EpYZ-VDNM-babQ-PTr1-D232Pe
  LV Write Access        read/write
  LV Status              NOT available
  LV Size                3.72 GB
  Current LE             119
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 76

Accepted Solution

by:
arnold earned 500 total points
ID: 40621252
your disolay appears strange where you have an LVM volume  added as a physical volume..

The other part is you have the two physical saying that each instead of extending a single VolGroup00 is each belongs to a VolGroup.

I do not see from your output where your data might be. You may have Los that are similarly named to the existing one. You would need to rename one in order to be able to accessthr other.

The volgroup00 whose LVs are not seen has the UUID ends in kMrXgQ based on the sum of disk space of the LVs 271.78.

The issue is that /dev/sda1 is the drive from which the system boots.

Not sure how your wound up here.
It looks as though the lv that you have mounted is on /dev/sda.

One option is to boot the system using a liveCD while /dev/sda is not connected, and rename the VolGroup00 to VolGroup01 at which point when the /dev/sda is reconnected and e system is booted, you should have two volumegroup a and four lv volumes.
0
 

Author Comment

by:shaunwingin
ID: 40623447
I suspect the naming is a result of the fact that both sets of hard disks have been installed with the same CenTOS installation disk - to be exact Elastix CD.

I've booted with Ubuntu Live CD.
In terminal please give instrucitons to
1. mount the Raid volume
2. to rename the volume

I can easily boot with only RAID volume active and copy the data off the Raid volume to a USB stick.
0
 
LVL 76

Assisted Solution

by:arnold
arnold earned 500 total points
ID: 40623660
Confirm that with only the /dev/sda connected, that the system boots and runs.
Make sure you have the /dev/sda data backed up.

With /dev/sda disconnected, boot live cd,

Makesure if there is data in the raid volume, not to proceed as it is not clear from here (not certain) the first checks/validates.
Vgrename  (UUID from the VolGroup00 where open LV is zero vnOxIO) VolGroup01

And that should also adjust the logical volume names to now be part of the correct volume group.
You can change with either and if it fails to boot, using liveCD edit the lv based /etc/fstab
/boot/grub/grub.conf can be used to see the UUid referenced as the / volume,
Make sure you have the data on /dev/sda backed up.

Were you planning on transition the system from booting of one drive /dev/sda to the raid volume?

Using Linux software raid might have been preferred to the SATA fakeraid given the linux based gives you more control than available with the sata Raid built into the MB controller.
0
 

Author Comment

by:shaunwingin
ID: 40623957
Tx - all I want is the mysql directory - then plan to format the RAID - and definitely not planning on using the fake raid again!

Pls expand on my instructions  e.g :
 lv based /etc/fstab
/boot/grub/grub.conf

I wouldn't know what to edit....

PS would booting into Windows 7 help - can it read the drives - just want the data...
0
 
LVL 76

Assisted Solution

by:arnold
arnold earned 500 total points
ID: 40624306
no, windows 7 to read the drives will need to install a utility that can read ext* not sure it can read LVs.

in your fstab you have
/dev/mapper/VolGroup00-LogVolume00 ext* /
If you rename the wrong group such that the above no longer exists but /dev/mapper/VolGroup01-LogVolue00 does, you would change the reference there.
Another option is to duplicate the entry in grub.conf
one boots using the /dev/mapper/VolGroup00-LogVol00
the other use /dev/mapper/VolGroup01-LogVol00

I am still puzzled where the data you are after is.  

This UUID for VolGroup00 AFzr9J-YbQ0-pD1u-JKfj-hasE-LuNx-vnOxIO has no accessed LVM
you could while the system is booted rerun vgdisplay and make sure the above UUID still reflects 2 LV but 0 open LVs.
and then run vgchange AFzr9J-YbQ0-pD1u-JKfj-hasE-LuNx-vnOxIO VolGroup01
then you would need to rerun pvscan, vgscan, lvscan (you might want to do it now just to see whether you would get an error giving notice that you have lvs with the same name.)

once you change the VolumeGroup that it no longer matches. run pvdisplay and you should see each PV attached to a different VolGroup.

Unfortunately, nothing always goes as planned, so plan for the worst case.... make sure you backup your data.
0
 

Author Comment

by:shaunwingin
ID: 40627560
Tx - but really looks involved - If I break the RAID - I only leave 1 disk active or better still change the Bios back from Raid and boot in Live CD - can I access the mysql directory simpler this way - without changing the fstab folder.... ?

All I'm after is the mysql directory... How can I access it simply?
0
 
LVL 76

Expert Comment

by:arnold
ID: 40627576
There is no need to break the raid, your data seems to be on /dev/sda but your existing setup boots from sda while mounts / the data off the raid.

Breaking the raid will likely not alter the existance of two PVs that reference the same VolGroup and co agin the same logVols.
0
 

Author Comment

by:shaunwingin
ID: 40627694
Data is not found on a mounted drive - if was - would be solved.
Please see previous request again.
0
 
LVL 76

Expert Comment

by:arnold
ID: 40628240
The difficult part is that it is not clear which drives are part of the raid. Can you check the raid config of which are part of the raid, detach the one that is not to make sure the system can boot.  Then take note of the vgdisplay to identify which is loaded.  Then reattach and boot renaming the group that was not seen.

The puzzling is that fdisk sees three drives.

Breaking the raid might be more risky.
0
 

Author Comment

by:shaunwingin
ID: 40630041
System won't boot if remove the single disk I installed CentOS on ie if try boot off Raid drives. Its logical to me that sda would be this disk as its in the 1st slot out of 4. The Raid drives are in slots 3 & 4.

all I want is to get the single directory off the Raid drives - I'm ready to format the whole lot after that. Can't imagine its so difficult to get to this data.....??
0
 
LVL 76

Expert Comment

by:arnold
ID: 40630345
It is not difficult to get to the data, one has to be extremely careful when this issue comes up.  With /dev/sda disconnected, boot with a liveCd and use the vgchange to rename VolGroup00 from the raid to VolGroup01
Poweroff, reattach /dev/sda and boot the system.
You should then have all your LVs separately accessible.

Did you go throu installing twice? Or did you install when both sda and the raid drives were attached?  Trying to figure out how you got to this point I.e. At what time and how the RAID drives were handled.

See if you have system-config-lvm installed, if not use yum system-config-lvm
This is a graphical lvm management interface.
0
 

Author Comment

by:shaunwingin
ID: 40630355
Tx.
Did you go throu installing twice? Or did you install when both sda and the raid drives were attached?
Went through install twice.

PS Is there a way I can reinstall the CentOS CD over the RAID install and preserve the mysql directory? This way I will  have hte rAID back....

I think because all 3 drives identical size and same install disks makes it hard to differentiate. The Bios is set to RAID and it may also treat the single disk as a RAID Volume...
0
 
LVL 76

Expert Comment

by:arnold
ID: 40630398
No do not go through the install again as the risk to data loss is a single typo away.

So the situation is as follows:
/dev/sda1 is the boot device
the raided /dev/mapper/VolGroup00-LogVol00 is likely on the RAID volume

taking a look at the output of lvdiskscan along side with fdisk -l, I am uncertain you actually have a RAID. You have /dev/sda2, /dev/mapper/pdc_ecgdbbhfgjp2 and /dev/mapper/pdc_ecgdbbhfgj (does the bios actually reflect a raid Volume, or you have your SATA labeled as RAID? ...

One option is to go through the prior suggestion and while the 3/4 drives are disconnected, boot using LIVECD and get the data off the /dev/sda (backup)
rename the VolGroup00 to VolGroup01. Reattach the BioS RAID drives, and boot the system. now you should within pvdisplay/vgdisplay have VolGroup00 and Volgroup01 and within the lvdisplay have four LVs two for VolGroup00 and two For VolGroup01.
with this you can mount /dev/mapper/VolGroup01-LogVol00 and then copy the mysql data.

The other option after you backed up the data, is to go through reinstalling with just the RAIDed drives attached, and using the OS to RAID/configure the drives rather than the BIOS.

creating a raid 500MB on each drive, then groupping the two into a single raid device of type extx. mounted as /boot (md0)
then partitioning the remaining space as a single raid volume on each. then grouping the two partitions into a second raid device (md1) of type auto-lvm making it a pv, then Volume Group. Then you partition the LVM either as a single / or into multipe logical volumes ( a single volume runs into an issue of running out of space because of a typo/error where logs of a service/application are not properly managed/rotated)
To mitigate that, using a logical volume as a partition of 2GB for /var/log/ will isolate the system from ....
0
 

Author Comment

by:shaunwingin
ID: 40632574
I'm quite happy to take the risk of re-installing .... can you give details - it uses a GUI when installing but seems that only  3 options require either to use existing space, format drive and a 3rd option which if I recall was also destructive,,, how would one reinstalll? I would be happy to break the RAID - and this way I have 2 changes to get it right. I don't want a raid install - just a straight install to get the data. Then I format and install a software RAID from scratch as part of install process.
0
 

Author Comment

by:shaunwingin
ID: 40672246
I've brocken the Raid drives and booting in Knoppix Live CD, I've inserted a single disk.
If I run LVM commands - tells me no Volumes found.

fdisk -l shows me
sda1- this is the boot partition and mounted
sda2 Linux Extended (The data I want to browse)

When attempting to mount get error:
mount: unknown filesystem type 'promise_fasttrack_raid_member'

Please help.... !
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now