Notice: register_sidebar was called incorrectly. No id was set in the arguments array for the "Sidebar 1" sidebar. Defaulting to "sidebar-1". Manually set the id to "sidebar-1" to silence this notice and keep existing sidebar content. Please see Debugging in WordPress for more information. (This message was added in version 4.2.0.) in /usr/share/wordpress/wp-includes/functions.php on line 4139 Tech Notes » 2010 » November

Twice is a Bug

Uncategorized No Comments »

If a problem happens once, it’s (un)lucky: things just happen, some things are very rare, and fixing them is not economically viable.

If it happens twice, it’s a bug, be it hardware, software, or meatware (users / processes).

Dishonourable mention for the bugs that rarely happen, but require a 5-alarm firedrill to diagnose, and makes a company look really, really bad 🙁

If you consider it, even the Software Architect who never talks to customers until their environment is very stable, he’d have to agree: if something happens twice, even if I’m a genius and it never happens to me, it must be more possible than alignment of the planets, so should be considered. If users keep doing the same problem, maybe they have other habits than what I have, and maybe should be considered worthy of helping rather than ignoring.

If the glorified calculators on our desks are more capable of checking for that error, then why aren’t they? (That’s a key tenet behind the Smallfoot project: use the software to do what software’s good at).

I just saw a bug in a release of our product, I think it’s handled in some of the work on the later major revision, but I’m not sure. I don’t want to file until I know, as that wastes developer resources to tell me I’m an idiot (I’ve been an idiot many times, but developer resources are quite valuable in my books). I don’t want to forget to check, but damn, there’s a lot of stuff that happens in my workday, and my memory is fairly sketchy (poor-quality meatware).

Maybe it’ll happen a third time. Thrice is definitely a bug.

NetFlix Outside USA: AppleTV VPN

Uncategorized No Comments »

Put a VPN on your AppleTV to make it connect from an apparently-USA IP address to get full access to your Netflix subscription.

This is what I said as a solution to the problem of traveling in other countries, taking your new AppleTV with you (let’s not ask why you’d pack that over, say, a helmet, or a SCUBA reg), and accessing the full line of USA Netflix content. This is all with the intention of getting access to the USA content on Netflix (with a proper, USA paid subscription) while traveling.

So I said “put a VPN on your AppleTV, and connect through there to stream content”. This also requires that the system you’re streaming through has sufficient bandwidth to both send and receive a copy of the streamed packets. I would not recommend streaming from a residential gateway on the end of a cablemodem, for example, because of the asymmetric inbalance in upstream/downstream data rates and latencies.

So we’re mostly following the FireCore Newbie Procedure:

  1. Download the latest Pwnage (v4.1.2)
  2. Download a compatible AppleTV version 2 image (v4.1 4M89)
  3. Create a jailbroken image, which should offer ssh access
  4. Use ssh to configure the stripped-down OSX on the AppleTV to connect VPN

This is very much like streaming the UK BBC Player to watch soccer outside the UK — because when you travel, you want/need/must have access to your soccer. Yes, I’m talking about you, Cannoli.

MySQL Replication Walkthru: Activate Secondary

dataflow, howto No Comments »

After Enabling Replication and Making a Remote Backup), we can activate the secondary server.

Already, our Primary has been returned to service, and we don’t really need to alter it from this point forward; all our work after enabling replication has been on the Secondary. We’ve saved our remote backup on Secondary’s disk, but not yet started the secondary server.

We will:

  1. start the Secondary (skip-start-slaves is still in the config file)
  2. Configure the replication
  3. Import the backup file
  4. Start the Replication process on the Secondary
  5. Configure the Secondary so that it will always start the Replication automatically

Our servers:

Primary: Sleepy (192.168.44.3)
Secondary: Doc (192.168.44.4)
MySQL: 5.1.41-enterprise-commercial-pro
OS: Windows 2008R2

Start the Secondary
We still have the option “skip-start-slaves” in our my.ini (my.cnf), and now we’re going to start the server; this is as simple as using the Windows services.msc to start the MySQL service.

On a Unix-like server, /sbin/init would start the service, or if you’re in the SysVinit-monstrosity, /etc/init.d/mysql* start or something similar would start the service. We can discuss why a script would reside in /etc/ some other time when the SystemV documents and the Linux FSH are both present (hint: violates both; config files only)

Configure the Replication
Replication can also be configured using the config file, but I did it using the CLI, as follows:

(On Doc/Secondary)

mysql.exe -u root mysql
mysql> CHANGE MASTER TO MASTER_HOST=’sleepy.example.com’, MASTER_USER=’repl’, MASTER_PASSWORD=’R3plPassw0rd’;
secondary:mysql> SHOW SLAVE STATUS;

(On Doc/Secondary)

mysql.exe -u root mysql
mysql> CHANGE MASTER TO MASTER_HOST=’sleepy.example.com’, MASTER_USER=’repl’, MASTER_PASSWORD=’R3plPassw0rd’;
secondary:mysql> SHOW SLAVE STATUS;

The output of “SHOW SLAVE STATUS” should have a proper Host, user, and pass, but the logfile and log position will be fairly incorrect.

Import the Backup File

We stored the backup file we made as repldbdump.db. We should already have a user on the local server that can insert and import (by default, “root” can do this), and we’ll import it using:

(On Secondary/Doc)

mysql.exe -u root < repldbdump.db

Another benefit of storing this backup/dump with the “master” options is that it will correct the laster log file and master log position for us. A repeat of “SHOW SLAVE STATUS” should show that the MASTER_LOG_FILE and MASTER_LOG_POS in the repldbdump.db has set things right.

Start the Replication process on the Secondary

We have the data loaded from the Primary, and we have our replication configured. The import has configured our replication binlog files and positions, so we’re ready to start.

(On Doc/Secondary)

mysql.exe -u root mysql
mysql> START SLAVE;

Configure the Secondary so that it will always start the Replication automatically

Finally, we can remove the config entry we put into our Secondary so that it would start with a crippled Replication config; comment out the skip-slave-start in your my.ini (my.cnf):

(Secondary/Doc)

[mysqld]
...
server-id=2
#skip-slave-start

There’s no need to restart the Secondary, but if it does restart, it will automatically get back into replication.

MySQL Replication Walkthru: Making a Remote Backup

dataflow, howto No Comments »

After Enabling Replication (or if you are not using replication, then right after Enabling Network Access), we can use this config to make a remote backup of the database.

Our servers:

Primary: Sleepy (192.168.44.3)
Secondary: Doc (192.168.44.4)
MySQL: 5.1.41-enterprise-commercial-pro
OS: Windows 2008R2

Use Remote Access to Pull a Remote Backup

By this point, you can connect to your server remotely to make queries; now we want to pull a backup.

(on Secondary/Doc)

mysqldump.exe –u repl -h 192.168.44.3 --password=R3plPassw0rd –add-drop-table –all-databases > repldbdump.db

In you’re setting up replication, then you’ll want the additional replication content provided by using this command instead:

(on Secondary/Doc)

mysqldump.exe –u repl -h 192.168.44.3 --password=R3plPassw0rd –add-drop-table –all-databases  –master-data –host=vi-sleepy.vi.local > repldbdump.db

The benefit of this additional data is that it sets the replication master file and log position for when you continue to Activate the Secondary

MySQL Replication Walkthru: Enable Replication

dataflow, howto 2 Comments »

After Enabling Network Access, we can Enable Replication before Making a Remote Backup of the Database. If you’re reading this to simply make recurring backups of your MySQL remotely, then you can ignore this step.

In this step, we’ll

  1. assign IDs to the Primary and Secondary
  2. restart the primary
  3. proceed to backup the database before starting the Secondary

Primary: Sleepy (ID = 1)
Secondary: Doc (ID = 2)
MySQL: 5.1.41-enterprise-commercial-pro
OS: Windows 2008R2

Assign ID to the Primary
While assigning a replication ID, we can also define the binary log for replication; I did this using two parameters into the my.ini (my.cnf) file:

(Primary/Sleepy)

[mysqld]
...
#bind-address=127.0.0.1 # commented to bind to all interfaces
log-bin=”E:\Data\repl-bin”
binlog=format=ROW
server-id=1

(Secondary/Doc)

[mysqld]
...
server-id=2
skip-slave-start

Start the Primary server, but don’t start the secondary yet. Note that “skip-slave-start” is there as opposed to running the Secondary with the option “–skip-slave-start”, which is difficult to do using Windows’ service stop/start. This option is only there for the first run of the Secondary.

(On Sleepy/Primary)

mysql.exe -u root mysql
mysql> GRANT REPLICATION SLAVE ON *.* TO ‘repl’@'%’;
mysql> FLUSH PRIVILEGES;

You should notice that when the Primary server starts up again, it begins creating E:Datarepl-bin.index and E:Datarepl-bin.000001 files

MySQL Replication Walkthru: Enable Network Access

dataflow, howto 1 Comment »

In my replication setup, I needed to make a backup, and I needed to enable TCP/IP access eventually, so I did them as a single step.

Primary: Sleepy
Secondary: Doc
MySQL: 5.1.41-enterprise-commercial-pro
OS: Windows 2008R2

In order to allow Doc (Secondary) access into Sleepy (Primary), Sleepy had to accept remote TCP clients. The process for that was:

  1. create a username/password pair for a new remote user (wildcard host, or a specific host)
  2. configure MySQL to accept remote client access

Create a User/Pass Pair

I wanted to ensure I could access the server’s authentication, so I restarted with “–skip-grant-tables”. In my case, I added this to the WINDOWSmy.ini, but Linux and Unix-like users (including BSD) might find /etc/my.cnf or /etc/inet/my.cnf. My config looked like:

(On Sleepy/Primary)

[mysqld]
...
...
skip-grant-tables
...

Restart the server.

Next, I connected and ran a GRANT command:

(On Sleepy/Primary)

mysql.exe -u root mysql
mysql> CREATE USER 'repl'@'%' IDENTIFIED BY 'R3plPassw0rd';
mysql> GRANT SELECT ON *.* TO 'repl'@'%';
mysql> FLUSH PRIVILEGES;

Note: “mysql.exe” is obviously “mysql” on Unix-like systems. “%” is a wildcard in MySQL’s world.

The FLUSH PRIVILEGES is not quite necessary because in our next step, we’ll be restarting the database anyhow.

If you cannot connect, check that the unix-socket is present, and check for socket configs in the my.ini (my.cnf).

Configure MySQL to Accept Remote Client Access
In order to open up the external port (which might already be open, depending on your configuration), I commented out the bind-address in my my.ini (my.cnf) config file:

(On Sleepy/Primary)

[mysqld]
...
...
#bind-address=127.0.0.1
skip-grant-tables
...

After I restarted, I noticed that I could connect using “-h 127.0.0.1” (as I could before) but also using the external address (192.168.44.3):

(On Sleepy/Primary)

mysql.exe -u root -h 127.0.0.1 mysql
mysql> exit
mysql.exe -u repl --password=R3plPassw0rd -h 127.0.0.1 mysql
mysql> exit
mysql.exe -u root -h 127.0.0.1 mysql
(fails, as expected)
mysql.exe -u repl --password=R3plPassw0rd -h 192.168.44.3 mysql
mysql> exit

(On Doc/Secondary)

mysql.exe -u repl --password=R3plPassw0rd -h 192.168.44.3 mysql
mysql> exit

If you cannot connect with “-h 127.0.0.1”, check that the “bind-address” is defined properly or absent completely from the my.ini (my.cnf) file, and that you have restarted the server since you made that change. “netstat -n” would confirm whether mysql is listening on port 3306. “telnet 127.0.0.1 3306” or “nc 127.0.0.1 3306” would confirm whether MySQL is available on that port (or something else is).

If you cannot connect with your external IP address, check that you have the right address, and confirm (using telnet or nc) that you have a service responding there.

If that works fine, comment out your “skip-grant” and restart, then recheck with the same OS-level mysql(.exe) statements as above. Connectivity should work and fail as above.

(On Sleepy/Primary)

[mysqld]
...
#bind-address=127.0.0.1
#skip-grant-tables
...

MySQL Replication Walkthru

dataflow, howto No Comments »

This walkthru shows my steps to configure trivial replication using MySQL’s standard capability on a pair of servers.

Replication and HA are often difficult to configure and maintain in the little nuances and corner-cases. It’s so easy to make a mistake that doesn’t show until it’s time ot bring the backup online, or until a logfile slowly fills up the disk and chokes the server 212 days later. That said, parallel servers bring in a complexity of ACID/idempotent actions, split-brain issues, load-balancing, and at the core, one server remains the “master” for a very small delta between “master” and “subordinate”.

The problem with active/passive is that you can only reap 50% of your investment costs, and the service retains a limitation in overall throughput. Eventually — even through organic growth — the service will be unable to maintain the same responsiveness to queries while handing the continual updates and inserts. At some point, there needs to be a split.

As opposed to going back to parallelism, a PRM/SRM relationship can be used. A “Primary Replication Manager” (PRM, we used to call it “master”) is used to accept updates and offer serialized (ie: logical clock, ordered, not as in “Java Serialization”, “persistence”, and “hibernation”) updates to a number of “Secondary Replication Managers” (SRM). This is a process exploited in DNS most commonly, but I’ve configured 8 SRMs on a single LDAP PRM (Hi, Phorm), 4 Backup Domain Controllers in a single (hidden) Primary Domain Controllers on Windows NT-3.51, and my own NIS secondaries from a MySQL-fed NIS primary at Connected Networks, an ISP we used to own. The complexity is shifted from the maintenance to a the initial setup, which (in MySQL, LDAP, and NIS) can be done as a “smart postinstall trigger” approach to reduce the risk of human error.

The MySQL case is a bit more difficult, so here’s my walkthru, mostly to remind myself, but maybe someone else will benefit.

In my case, I wanted to evaluate the feasibility and difference in performance — in very crude numbers — when replication is configured.

My walkthru features the following players:

PRM: Sleepy
SRM: Doc
MySQL: 5.1.41-enterprise-commercial-pro
OS: WIndows 2008R2

I’ve cut this into separate articles not because I have some advertising quota to make, simply because that makes it bite-sized actions that a SysAdmin can take while fighting fires and repairing the Dell Retractible Drink Holder labeled “DVD” on some desktop systems.

  1. Enable Network Access
  2. Enable Replication on the Primary
  3. Make a Remote Backup
  4. ), we can activate the secondary server.
  5. Activate the Secondary Server

For a detailed example for the Replication Eval done in Scotts Valley on 2010-10-08, the example walkthru is online on the VI blog.

AppleTV and Firefly Media Server

dataflow No Comments »

The new AppleTV does not work with the iTunes Server on many purpose-built NAS devices simply because the underlying technology (Firefly Media Server) cannot authenticate with Apple Home Sharing. The Second-Gen AppleTV requires Home Sharing to work.

Update 2010-12-13:James Danylik reports that it’s possible to replace firefly with forked-daapd, which is a rewrite/fork of mt-daapd, which is how firefly started. …so there’s a rewrite in progress, the dependencies are problematic, but it shouldn’t be long before it’s fully-baked.

Update 2011-06-09:Additional work has been done on metadata. Haven’t found an upgrade path yet. Scratch my own itch?

CSV Isn't Versioned — Risk Being Incompatible With Yourself

dataflow No Comments »

Consider a simple example:

(example-2.0.1.csv)

Bloggins, Scott, "+1-212-555-1212", Engineer, 95060
Clark, Allan, "+1-424-242-2668", FAE, 98107

OK, so that’s fine. Obviously, we wanted a name, number, job code, and zipcode, and when we parse that, we simply say:
lastname = $1
firstname = $2
phone = $3
Job = $4
zipcode = $5

…but shoot, in version 2.0.2, we needed to paste the street address (because we’ll use zipcode to figure out the city/state). Simple enough, we’ll just stick that in:

(example-2.0.2.csv)

Bloggins, Scott, "+1-212-555-1212", Engineer, 100 Enterprise Way, 95060
Clark, Allan, "+1-HA-HA-HA-Boot", FAE, 2237 Starbucks Street, 98107

That’s fine, but now the parsing is broken — for example, Scott Bloggins:
Job = Engineer
zipcode = “100 Enterprise Way”

waitaminute. That got all screwed up, and CSV cannot indicate its version number (yes, a commented pre-amble has been discussed, and has screwed up parsers already — abandon all hope yet who there enters)

OK, now we’ll get around that by saying “well, if there are six entries, we’ll treat it like v2.0.2, but 5 entries, v2.0.1”:

Job = $4
if (NF > 5); then
  address = (null)
  zipcode = $5
else
  address = $5
  zipcode = $6
endif

Tell me that doesn’t get cumbersome soon; besides, it ignores optional content, so if anything is skipped, you eventually have:

Bloggins, Scott,,,,,,96050

Sounding a bit like Clint Eastwood: “Did I type 12, or 17 commas? Do you feel lucky, punk? Do ya?”

This is why XML was invented, has version numbers, optional content, and rock-solid parsing. There’s libraries for this, and the schema is obvious when reading it, plus it still compresses nicely (plaintext with repeated syntactical sugar).

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in