simple mysql slave

Simple mysql master->slave replication.

Assumptions:
The mysql/firewalls/etc are already setup, there are no writes going on to master during the setup (or there are provisions to take care of master/slave mismatch, like percona toolkit).

On master:
in /etc/mysql/my.cnf uncomment the following lines :

#server-id              = 1
#log_bin                        = /var/log/mysql/mysql-bin.log

And comment the following line:

bind-address            = 127.0.0.1

restart mysql:


service mysql restart

in mysql run following:

GRANT REPLICATION SLAVE ON *.* TO 'repl'@'{IP}' IDENTIFIED BY '{PASSWORD}';
FLUSH PRIVILEGES;
SHOW MASTER STATUS;

Where {IP} is the IP address of the slave and {PASSWORD} is the password of your choosing.
Note: username does not have to be ‘repl’.

The SHOW MASTER STATUS should return the following:

+------------------+----------+---
| File             | Position | 
+------------------+----------+---
| mysql-bin.000001 |      100 |
+------------------+----------+---

Record two this: File and Position (this will be used when setting up the slave).

On slave:
Dump the database(s) in question and import it into new slave, eg (for each database):

mysql -e "CREATE DATABSE {DB}"
mysqldump -h{MASTER_IP} -u{MASTER_USER} -p{MASTER_PASSWORD} {DB} | mysql {DB}

assuming the root user has no password locally on slave.

Uncomment and modify the following lines (make sure server-id is unique):

server-id              = 2
log_bin                        = /var/log/mysql/mysql-bin.log

And comment the following line (needed only if you need to access slaves remotely):

bind-address            = 127.0.0.1

restart mysql:

service mysql restart

In mysql, setup replication:

CHANGE MASTER TO MASTER_HOST='{MASTER_IP}',MASTER_USER='repl',MASTER_PASSWORD='{PASSWORD}', MASTER_LOG_FILE='{FILE_FROM_MASTER_STATUS}', MASTER_LOG_POS={POSITION_FROM_MASTER_STATUS};
START SLAVE;

Note: MASTER_LOG_POS is unquoted integer.

Check if replication is running:

SHOW SLAVE STATUS \G

NZ Police Speed Enforcement documents

A while ago (mid December 2014), I made an Official Information Act request to NZ Police regarding specs and other information of their speed measuring/enforcement equipment.

The reason behind such request was because I thought no speed limit tolerance (or 1km/h ?) was absurd, and bluntly put very stupid.

Here are the documents that I received:
1) Response letter with some answers to my questions (included in the letter in italic).
2) Speed_Detection_Equipment_Operators_Manual.
3) Stalker_Lidar_EU_Operators_Manual

Here is the equipment/accuracy table:

Accuracy_table

So basically they are stating that almost all their equipment is +/- 0.6km/h accurate, be that hand held LIDAR or vehicle mounted RADAR equipment.

I find it incredible that it is possible to go from +/- 3.2km/h accuracy (http://www.stalkerradar.com/law_dual.shtml see specifications tab) to 0.6km/h for Stalker Dual RADAR system. Especially considering they use RADAR to get ground speed and speed of the vehicle, which means each reading should have +/- 0.3km/h accuracy!!! But that is my speculation.

I found a few interesting things in the manuals, which opens a few possibilities when contesting unfair reading.

The radars are tested daily with tuning forks(*).

There should be a “Tracking history”.
What that means is that the police officer should identify your vehicle, ie: it cannot get a blind reading from radar! For example if they claim they have a reading while you where behind the corner, they cannot fine you.
They should get a clear Doppler audio feedback (although it will be hard to argue that).
They should have a ground speed estimation from the vehicle speedometer(**) if they are moving.

The LIDAR spread is is about 0.17 degrees, at ~800m (upper end of the working range) the “spot” is about 2.4m circle, at such distance it is possible to get the wrong reading if there are other cars in vicinity (ie partially covered by the laser spot).

Apparently the NZ LIDARs are “immune” to sweep effect (although how does it know the difference between officer tracking the car or officer sweeping the car?). I bet all it does is filters out jitter, but it is possible to sweep without creating jitter.

Interesting thing is that the headlights that emit a lot of infra-red light can interfere with the operation of the LIDAR.

The LIDARs can only be operated stationary.

With LIDARs officers must write down the speed locking distance on the ticket.

The officer must retain the locked values for viewing by the allegedly offending motorist. In addition the remotely operating officer (ie on overpass) should record the vehicle description, speed and distance reading.

All speed measuring devices used by Police to enforce speed limits should have a valid accuracy certificate not older than 12 months.
All police vehicles that are equipped by radar should have a valid speedometer certificate of accuracy not older than 12 months.

Every shift the unit must go through various test which should be recorded in the logbook.

In summary (direct extract from the document):

Documentary evidence

To comply with evidential requirements the operator will need:
* a copy of the speed detection device logbook relating to the day in question.
* a copy of the certificate of accuracy issued within a year of the date of the offence.
* a copy of the certificate of accuracy for the patrol vehicle used in the operation of the radar device or
* a copy of the certificate of accuracy for the patrol vehicle used for the weekly check in the case of a laser device.
* a copy of the operators Certificate of Proficiency for radar and laser devices.

Evidence in court

The operator must be able to give in evidence that:
* they are a certified speed detection equipment operator.
* they conducted the required tests for the unit and found it to be working correctly.
* a tracking history was established for the target vehicle.
* the code of operations was complied with.

There is interesting gotcha that makes 0.6km/h accuracy of the radar units meaningless:

Confirm patrol vehicle speed is consistent with the speed readout on the unit within +/- 3 km/h. This is achieved by travelling at a consistent speed, appropriate to the speed limit being operated in, and checking that the true speed(according to the certificate of accuracy) is the one displayed on the readout. Record the results in the logbook.

As far as I understand the document, what this test does is test that vehicle speedometer is within of +/- 3km/h of the RADAR grounds speed reading. This test never tests that the unit are within the specified accuracy, and might well be off by +/- { whatever is speedometer inaccuracy + 3km/h }.

The same applies to the laser units:

On a weekly basis the laser unit readout needs to be checked using a drive though by a patrol vehicle with a certified speedometer. This is carried out by having the driver of the vehicle drive at a steady speed towards the laser operation area. The speed will be relevant to the area of operation. The driver should flash their headlights or advise using the radio when the vehicle speed is steady and the laser operator will check the speed. The member using the laser will advise the vehicle driver of the results of the speed check, The driver will advise the speed they were travelling at after checking the certificate of accuracy to determine the true speed. Where the margin of error exceeds +/- 3 km/h the unit is to be withdrawn for servicing The results of the check must be recorded in the logbook (vehicle speed/checked speed). for example 64/65; 46/46; 75/75.

Since the daily test are only conducted to ensure that the LIDAR and RADAR units are within 3km/h + speedometer inaccuracy, then one would conclude that at the day the units in question are only good for +/- >3km/h. In reality because of the speedometer inaccuracy used by the police for testing it could be well over 6km/h!

* The tuning forks.. They are definitely temperature dependant devices, I am yet to find an accurate source, my initial research shows worse estimate of 1% change for every 5 degree Celsius or best estimate of ~0.07% change (that wildly differs for the material as well).

** The speedometer accuracy can also vary wildly, depending on tyre wear, temperature/tyre pressure. For example at the beginning of the life the tyre has about 8mm of usable thread.
Assuming the nominal diameter of 205/60/15 Tyre is 627mm at the beginning, after ~60% wear it is 617mm. That is roughly 1.6% change. Which would translate to 1.6% higher reading. At 90% wear it adds up to 2.4%. Combined with under inflation that can go over 5% easy.