Tuesday, March 19, 2013

Pulseaudio woes

I have an ASRock 890FX Delux4 motherboard that I was having a damned of a time getting the audio to work on in Ubuntu 12.10.

The solution turned out to be that pulseaudio didn't have the device selected as the output, but that was completely not discoverable via the UI.

I had to install an extra program to tell pulse to use an output channel other then what it was using by default.

sudo apt-get install pavucontrol

 This was the ticket I needed, selected the correct output for sound and viola! magic.

Percona/MariaDB libmysqlclient18 dependency snafu

Sometimes the efficiencies of the apt tools in Ubuntu amaze me. There I was running along happily with MariaDB and decided to do a sudo apt-get dist-upgrade, the command has never failed me in the past, so I was confident that Ubuntu would figure out the "correct" thing to do and I blindly confirmed the recommendation without reading what apt was going to do. BAM! A few seconds later MariaDB is successfully uninstalled *blink* what? No problem a simple reinstall should fix that, easy peasy. Well you see the thing is that now there is this dependency problem with libmysqlclient18 and Ubuntu can't figure out how to resolve that so... no db for you!.



I guess what happens is the MariaDB (and Percona too I found out) repositories package a different version of the libmysqlclient18 in thier repective repositories. Sometimes Oracle (The owner of MySQL) releases a newer version of libmysqlclient18 without much notice. Apt thinks the new version is the hot ticket to install and installs it, but the DB in question still need the old version of the package, since it isn't installed anymore they are removed.

There are a few solutions.

  1. Don't do a dist-upgrade, instead do an upgrade... this should prevent the upgrade that removes maria/percona. 
  2. Create a preference file for your repository of choice that tells Ubuntu that, use the version of packages from the DB repository, not your own standard repsitory. 
I struggled to find any great documentation on how to create the preference file to pin the db packages so they come from the repository, so here is the shortcut version.

The big help for me was this post that details how to install percona on Ubuntu 12.10. http://ubuntuforums.org/showthread.php?t=2116360

You need to create a file in /etc/apt/preferences.d/yourFileName.pref

This is what I put in mine:
Package: *
Pin: release o=Percona Development Team
Pin-Priority: 1001

This tells apt to give preference to any package that is contained in the Percona repo. You can replace the * with a specific package, which will only impact that one package. You can also have different levels of preferences by adjusting the Pin-Priority attribute for more preference (higher number) or less preference (lower number).

In order to find the info for the o= switch. I pointed my browser to the address that is listed in /etc/apt/sources.list for that repo, then navigate to the conf/distributions file. The entry you are looking for is the Origin line, that is what you put on the Pin: release o=<put the info from the distributions file, origin line>

For Percona this is the file: http://repo.percona.com/apt/conf/distributions
For MariaDB this is the file(i use the OSU OSL repo, so adjust for yourself): http://ftp.osuosl.org/pub/mariadb/repo/5.5/ubuntu/conf/distributions

Once I did this and apt-get update I was able to install just like normal.

Saturday, March 2, 2013

Percona database won't start

I just finished a long hair pulling session trying to get Percona 5.5 installed on Ubuntu 12.10. What was happening is I would install from the percona repositories and everything would seem to go fine. I would attempt to move the data and log files away from the default location so that I could serve them from my ZFS pool and when I would put in the change into the my.cnf file the database would no longer come back up. It seemed like it was still starting, as I was seeing process running, but just one when I should have seen 12 or so.

This case was particularly frustrating because the my.cnf file I was using was generated by the Percona Configuration Wizard (https://tools.percona.com/wizard). The Configuration Wizard is a really great tool that takes some input from you about your server and intended use and outputs a config file for Percona. I assumed the configs generated from here would just work, but they don't.

What I figured out in the end is the /etc/init.d/mysql script uses the /etc/mysql/debian.cnf file settings to check if the mysqld server is up or not by pinging on the socket located at /var/run/mysqld/mysqld.sock the config file puts the socket by default into your data directory (on my zfs pool).

Two possible solutions, one verified, one should work in theory:

  1. Change the config generated from the wizzard to put the socket at the location that debian.cnf expects it. (/var/run/mysqld/mysqld.sock). This is what I ended up doing and it worked very well. 
  2. create a symbolic link between where you socket is, and where the startup script thinks it should be. e.g. sudo ln -s /path/to/your/actual/file/mysqld.sock /var/run/mysqld . This should work in theory and the reason I didn't do it this way is I'm not sure if there is special syntax for creating a symlink to a socket, or if there were any special considerations for reboot scenarios. 

Wednesday, February 27, 2013

View DNSMasq Leases

Use this command to view the current DHCP leases handed out by DNSMasq:

 cat /var/lib/misc/dnsmasq.leases  

SSH and remote administration. Not just for the command line.

Having the ability to remotely access a network is a great benefit for someone who does remote maintenance or troubleshooting. My tool of choice for this is SSH because:
  • Fairly Secure
  • Less hassel then a full VPN 
  • Installed by default on most Linux installations. 
  • Very flexible. 
SSH stands for Secure SHell and that is exactly what you get with the basic invocation of SSH:

 ssh plecebo@my.example.com   

The first time you execute this command your SSH client will ask you if you want to accept the certificate of the machine you are connecting to. Usually this is a fairly safe practice, but for those who strive for excellent security practices it is usually best to not accept this certificate but obtain it through some verifiable means (physically copy from the remote server and add it on your local machine). That being said I usually accept the certificate.

Once this command executes you will have a terminal open on the remote machine. This is exactly like the terminal you had open on your local machine.

Sometimes working in the terminal can be a real pain in the ass. Especially if there are good alternatives such as a web interface. You may want to connect to a remote network and use and application (web browser) as if you were sitting on site. SSH can help with that using Dynamic Port Forwarding.

 ssh plecebo@my.example.com -D 1234 -N  

This creates a Dynamic forward (SOCKS Proxy) from your computer to the remote computer on port 1234. The -N option keeps sneaky stuff from being executed on the remote machine. It is not required but recommended.

Now configure your application to use the proxy (localhost:1234) and all proxy traffic goes through to the remote computer and appears to come from that network. Most browsers have proxy settings you can configure. Here is a screen shot of Firefox configured for the above proxy.


What if you want to use an application to connect to a private resource on the remote network? For example you want to Remote Desktop into a windows XP machine on the remote network. SSH has you covered.

 ssh plecebo@my.example.com -L3388:192.168.1.100:3389 

This creates a tunnel through the remote computer to the resource behind the firewall. After you execute this command you simply use the address 127.0.0.1:3388 in your application and you will be connected to the resource on the remote network at 192.168.1.100:3389 (3389 is the remote desktop port).




There are also many Remote desktop clients that will connect via SSH for you. I like to use Remmina (http://remmina.sourceforge.net/) since it comes installed by default in Ubuntu and it suits my needs very well.

Sunday, December 16, 2012

Recover a dead hard drive with ddrescue

I use Ubuntu, so this is geared towards using that OS, but gddrescue (ddrescue) should be available on most Linux distributions.

I got most of this info from: https://help.ubuntu.com/community/DataRecovery

Install with:
sudo apt-get install gddrescue

Find the disk to rescue with:
sudo fdisk -l

Then run the command using a command like this:
sudo ddrescue -r 5 /dev/sdf /tank/Backup/image /tank/Backup/logfile

In this case 5 is the number of retries attempted to read the data before giving up, /dev/sdf is the path to the device that you found via fdisk -l /tank/Backup/image is the image file that will be written. /tank/Backup/logfile is a logfile that is kept of the recovery.

If the backup is interrupted or you want to run it for another pass with hopes of recovering more information use a command like this:
sudo ddrescue -r 5 -C /dev/sdf /tank/Backup/image /tank/Backup/logfile

Note the -C which tells ddrescue to pickup where it left off, or try to fill in the blocks that are missing

Monday, November 26, 2012

Obtaining Nexus 4

It sounds like some elusive artifact and in some ways it is. Google's new Google phone has been notoriously difficult to purchase since its release November 13th. In events that were surprising to me, but probably not to those who suffered through the Nexus 7 release of a few months ago, the launch was pretty painful.

Firstly I think Google severely underestimated the desirability of the phone since the order page was reporting sold out within 30 minutes of the phone being available, globally.

Second, the play store was unable to handle the load of everyone wanting Google stuff like right now. This is embarrassing for Google in my opinion, the company that can serve you search results to anyplace on the planet in under a second and has so much computing power at their disposal to allow such a service to crash is just bad form.

Third, there has been an extensive communication breakdown along the whole process. Starting from Google selling more of the Nexus 4 then they had current stock to cover, a problem probably related to the play store crashing. Continuing with people who now have the phone backordered and have no good ideas when they will be getting the phone. Culminating with people who were wanting a phone and didn't get a chance getting some idea when more stock will be made available. The backorder group have it the worst, being left completely in the lurch on a purchase they had rightfully made. Compensation for them is "free shipping" when the device becomes available again, not insignificant, but not much in the way of an apology from Google either.

The group eagerly awaiting the opportunity to throw their money at Google, of which I am one, are often obsessively visiting the play store to check availability, hoping that by lucky chance they will see that aqua "Add to Cart" button and be allowed to purchase. In my case the obsession occasionally borders on unhealthy, giving rise to the enrollment in various mechanisms that promise a prompt notification of availability, sometimes at the cost of real american dollars. My skepticism of the reliability and/or timeliness of these various services is evident in my continued search for more of their brothers. The latest and hopefully final incarnation being a paid ($1.02) app for my current Google phone that will check availability with frequencies as low as once per minute and upon discovery, notify me through some alert.

Why such a rush to buy another phone when I have a phone that is fairly new as it is you may ask? Simple, the sooner I switch from my current provider (Verizon) to T-Mobile the more money I will save over the next year. Each month that I have to wait is about $40 less in savings over the year, so I'm motivated.

Not to mention I'm very excited for the new tech. The biggest thing that kills me about my current phone (Samsung Galaxy Nexus) is that despite being branded as a Google phone the is upgraded processes are very much governed by Verizon's slow to push updates mentality. Not to mention the inclusion/exclusion of certain apps on the stock images make the phone a Google phone in name only, and not in reality. Its like I have the bastard brother of the Nexus line, last for updates and the one who the carriers have the most control over.

There are rumors that more stock will be coming into the store tomorrow, but there are still people with unfulfilled backorders so that would surprise me. *fingers crossed*