How could cyanobacteria survive the anaerobic conditions of ancient earth?
The first cyanobacteria were probably anaerobic, and this matter seems to be a hot topic of contemporary research. A recently published studya that performed a phylogenetic analysis of various Cyanobacteria genomes states:


  The most parsimonious inference from these data is that the last
  common ancestor of the Cyanobacteria did not use oxygen and that the
  three classes [of Cyanobacteria] acquired aerobic respiration independently after their
  divergence. The absence of aerobic respiration in ancestral
  Cyanobacteria suggests that abiotic oxygen sources on early Earth were
  insufficient to allow for its evolution until after the appearance of
  oxygen produced by photosynthesis.


Reference

a Soo, Rochelle M., et al. "On the origins of oxygenic photosynthesis and aerobic respiration in Cyanobacteria." Science 355.6332 (2017): 1436-1440 (http://web.gps.caltech.edu/~wfischer/pubs/Sooetal2017.pdf)