Wikipedia ["Galvanic anode"]: The arrangement of the anodes is then planned so as to provide an even distribution of current over the whole structure. For example, if a particular design shows that a pipeline 10 kilometres (6.2 mi) long needs 10 anodes, then approximately one anode per kilometere would be more effective than putting all 10 anodes at one end or in the centre.
"They are made from a metal alloy with a more "active" voltage (more negative reduction potential / more positive electrochemical potential) than the metal of the structure. The difference in potential between the two metals means that the galvanic anode corrodes, so that the anode material is consumed in preference to the structure." https://en.wikipedia.org/wiki/Galvanic_anode
The trouble was that they're pretty expensive, and zinc has a great resale value - so we had to do extra watches around the lower decks with rigged firehoses to try and stop local divers stealing them who knew we'd just come out of drydock. (This was in the Philippines). We lost several that way.