Friday, 12 December 2014

FIX: master and slave have equal MySQL server UUIDs

Newer versions of mysql use a unique UUID to do what the server variable server-id used to do.

That means if you need to do master/slave db replication each server will need its own UUID.

If the two servers have the same UUID, you will receive an error when attempting to sync the slave to the master:

master and slave have equal MySQL server UUIDs


If you are creating servers those servers from a virtual machine template then you will need to clear the UUID on each copy you make.

To do this, stop the mysql server and simply remove the file that contains the UUID

rm /var/lib/mysql/auto.cnf  


When you start the server again it will generate a new one automatically.

Tuesday, 7 October 2014

nvidia optimus

Trying to setup Mint Debian on a laptop with nvidia "optimus" is a bit different than the normal routine.

If you just install the nvidia-driver package and do nvidia-xconfig then when you try and reboot X will fail to start with;

"(EE) No Screens Found(EE)"

The reason for this is that the dual video card arrangement that Optimus provides is not supported "out of the box". You need to do a bit of extra work to get it working.

I am assuming that you have already installed the nvidia-drivers and linux kernel headers at this stage.

Next thing to do is make sure you remove /etc/X11/xorg.conf if you already have created that by using nvidia-xconfig. In fact at this point I recommend you remove nvidia-xconfig from your system entirely.

Next install some packages;

apt-get install bumblebee bumblebee-nvidia primus

Now, it would be nice to think that would be it but we do need to edit a file to get things working;


vi /etc/bumblebee/bumblebee.conf

Towards the bottom of the file in the [driver-nvidia] section change this line to look like this;


KernelDriver=nvidia-current

Reboot and you should be good to go.

You can test this by running this command;

optirun glxgears




Thursday, 2 October 2014

Windows 7 refuses to reconnect to Samba after reboot

Faaaaaark! I have been fighting this off and on now for weeks.

The scenario is this:

The network is a Windows domain. Let's call the domain "WINDOZESUX"

I have a Linux host running Samba that is not a domain member. Let's call it "sambaserver"

sambaserver is configured with:

workgroup = WINDOZESUX

Result: Windows 7 client can successfully mount \\sambaserver\share

That's cool.

Move forward until one of the Windows 7 clients reboots.

Result: Windows 7 client cannot reconnect to the samba share "The user name is not found"

Solution: Delete the saved credentials on the Windows client

Result: Windows 7 client can successfully mount \\sambaserver\share

Rinse, lather repeat.

Much troubleshooting follows. Eventually I had a dim recollection that I had "fixed" this once before by using an IP address instead of DNS

Solution: Use an IP address in the UNC path

Result: Windows 7 client can successfully mount \\1.2.3.4\share

Reboot and the share connects automatically without trouble. yay

Now, I was going to leave it at that (and I have for a while) but I really don't want to hard configure IP addresses all over the place because it can become a management disaster for the future.

Now, I have spent hours googling, found thousands of posts for basic errors such as noobs who just didn't have their DNS configured properly at, also a bunch of other posts suggesting that the share was trying to reconnect before the network adapter had come up which plainly was not the case because it worked fine with an IP address. No it was something do with DNS or WINS resolution. Or so I thought.

Suffice to say I spent a lot of time mucking about with WINS, DNS and SAMBA configurations and nothing made a lick of difference.

Eventually while clutching at straws I changed the sambaserver configuration to:

workgroup = LINUXROX

Went through the rinse, lather and repeat process and still it behaved in the same infuriating fashion.

Then while I was poking around in the Windows credential manager, about to delete the credential for the hundredth time, I clicked on "Edit credential"

Lo and behold, the username in the credential manager was shown as WINDOZESUX\username where I am sure the last time I had connected to the share it was using LINUXROX\username

Hmmm. So I changed the entry in the credential manager to the correct LINUXROX\username and rebooted again.

Result: Windows 7 client successfully remounts \\sambaserver\share

FFS. So it appears Windows has a bug (which knowing Microsoft may in fact be a feature) where when you connect to a non domain share from a domain member it does it correctly but when it saves the credentials it goes and changes the goddamned domain from the one you had specified to the domain that the client is on. But it only does that when you use a DNS name. When you use an IP address it works fine. Who knows why? Will Microsoft fix it? Why would they. They might however put up a technet article one day suggesting the solution is to buy a windows server you smelly Linux user.

God I hate Microsoft crap.

In other news, Bordlerlands 2 was just released on SteamOS/Linux!

Thursday, 28 August 2014

Recovering a deleted file that is still held open

I accidentally deleted the disk image file for a running virtual machine. oopsy!

Luckily, there is an easy way to undo that using the lsof command!

lsof | grep /home/qemu/images/my-disk-image.qcow2

This produces output like this;

qemu-kvm  24816      root    9u      REG              253,2 214781394944   21102665 /home/qemu/images/my-disk-image.qcow2 (deleted)

Take note of the first two numbers, which in my case are 24816 and 9 (Note: you must strip the trailing char from the second number)

Pause the VM  (don't stop it!) so that the disk is not being written to while we do the next step.

Now you just need to copy the deleted file back to somewhere safe;

[root@devkvm03 images]# cp /proc/24816/fd/9 my-disk-image.qcow2





Tuesday, 22 July 2014

Using docker on Linux Mint Debian Edition


Installing Docker on LMDE takes a few steps and will require that we add a third-party repository.

Note: We will be logged in as root to issue these commands. Also, I am by no means an expert on this, I am learning this as I go on.

So, with that out of the way let's add the key for the get.docker.io repository;

# apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9

Next add the repository to your apt sources;

# echo "deb http://get.docker.io/ubuntu docker main" > /etc/apt/sources.list.d/docker.list

Update apt;

# apt-get update

Install docker;

# apt-get install lxc-docker

Verify that it has worked by downloading and running the ubuntu container;

# docker run -i -t ubuntu /bin/bash
Unable to find image 'ubuntu' locally
Pulling repository ubuntu
e54ca5efa2e9: Download complete
511136ea3c5a: Download complete
d7ac5e4f1812: Download complete
2f4b4d6a4a06: Download complete
83ff768040a0: Download complete
6c37f792ddac: Download complete
root@46ec4b13f756:/#

Congratulations you are sitting in bash inside your ubuntu container. Type 'exit' or use ctrl-d to exit.

Note: It is important to understand that once you exit a container it ceases to run unless you specifically tell it not to (see below). It is not like a normal virtual machine that keeps on running in the background until you shut it down. To exit a container and have it remain running, use ctrl-p followed by crtl-q.

You probably dont want to be the root user every time you use docker. In that case simply add your user to the docker group;

# usermod -a -G docker myusername

You can list all the running containers with the 'docker ps' command. Add '-a to see the stopped ones as well.

Note: The containers that you create are kept in '/var/lib/docker/containers'

That's the basics of docker. The next thing to learn more about is using docker files to build containers.

Wednesday, 2 July 2014

Libvirt/qemu/kvm as non-root user

Prerequisites:

A server with KVM

I'm going to use the qemu user that is created when you install KVM but you could use any user you like.

First, your user should belong to the kvm group:

grep kvm /etc/group kvm:x:36:qemu

Create a libvirtd group and add your user to it

groupadd libvirt
usermod -a -G libvirt qemu


Create a new policykit config to allow access to libvirtd using your user account via ssh

vi /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla

Add the following content:

[Remote libvirt SSH access]
Identity=unix-group:libvirt
Identity=unix-user:qemu
Action=org.libvirt.unix.manage
ResultAny=yes
ResultInactive=yes
ResultActive=yes


Restart libvirt

service libvirtd restart