At least 22 people were killed in the province of Nova Scotia before police shot the gunman dead.