I've already outlined the naval gunnery strategy used during the age of sail, namely to concentrate the most firepower on a vessel without sinking it and then close on the enemy as close as possible with as many guns as possible. Ships would queue up in a line called a battle line in order to close with an enemy fleet and engage it.
For warships, this resulted in decks packed with guns. For instance British warships were rated according to the number of guns from first-rate to fourth-rate for ships of the line and from fifth-rate to sixth-rate for frigates. By the Napoleonic Wars, a first-rate ship of the line of some 2,500 tons with a crew of 850 men could have as many as 100 to 120 guns on three decks. The smaller vessels, a gun-brig or cutter of less than 220 tons with a crew of five to 20 men could have six to 14 guns.
Since merchantmen devoted much of its interior hull space to cargo, they had fewer cannon that were all situated on the outer deck. In the case of the larger East India men, while they did have cannon ports on more than one deck, the guns were often stowed away or completely assembled as in the cargo space.
Pirates rarely had the luxury of capturing a warship, so they modified whatever they captured for the optimum number of guns without greatly sacrificing speed and maneuverability. Pirate ship's carpenters and gunners would frequently gut ships to add additional decks or even cut out the forecastle and great cabin in order to gain more deck space for guns. These cannons came from captured vessels, salvaged shipwrecks, and shore fortifications.
In the early 18th century, the caliber of cannons were measured in the weight of their projectiles and not the cannon's bore. Merchantmen of around 200 tons might have four to six three-pounder guns. In theory you could get another four on board with two in stern and two in the bow. In practice, the superstructure of these vessels were not up to the weight..
During this time, English warships packed eight-pounders to twelve-pounders on their decks. Blackbeard's flagship the 300-ton Queen Anne's Revenge with a crew of approximately 160 men had thirty guns: four 12-pounders, 12-six pounders, six bronze eight-pounders, and eight four-pounders.
The variety of guns added a level of complexity for the gunner of the Queen Anne's Revenge. He and his mate had to prepackage powder charges for each of the different calibers. The charges were stored in the powder magazine and then passed out to young boys called "powder monkeys," who took the charges to the gun crews. Crew members passed the cannon shot from its storage area, which was called a "shot locker."
Cannon projectiles came a in a variety of types. Bar and chain projectiles had iron balls on either ends of chain or solid iron bars. These were used to attack rigging and sails, which offered a considerably large target. Solid show was used to punch holes in the vessel's hull, and thus had the potential to be used to sink the target vessel.
Cannister, grape, and langrage shot were used as short range anti-personnel ordinance. The cannister shot consisted of smaller projectiles inside a container. The grape shot consisted of grape-sized projectiles inside a canvas bag that disintegrated after the cannon fired. Langrage shot was simple anything at hand that could be crammed down the cannon's muzzle.
Gunpowder is a very, very touchy explosive. More than one fireworks factory has been leveled when a small static spark set off the powder dust. Since warships carried large quantities, special precautions had to be taken. The crew stored powder deep inside the ship in and area called the magazine. The magazine was separated from the rest of the ship and entry was allowed only through an airlock arrangement called a light room. Because gunpowder is very touchy stuff, crew could not handle gunpowder around open flames. Hence, the light room also provided illumination for the magazine through its glass paned walls.