The stochastic gravitational-wave background is a superposition of sources that are either too weak or too numerous to detect individually. In this study, we present the results from a cross-correlation analysis on data from Advanced LIGO's second observing run (O2), which we combine with the results of the first observing run (O1). We do not find evidence for a stochastic background, so we place upper limits on the normalized energy density in gravitational waves at the 95% credible level of ωGW<6.0×10-8 for a frequency-independent (flat) background and ωGW<4.8×10-8 at 25 Hz for a background of compact binary coalescences. The upper limit improves over the O1 result by a factor of 2.8. Additionally, we place upper limits on the energy density in an isotropic background of scalar- and vector-polarized gravitational waves, and we discuss the implication of these results for models of compact binaries and cosmic string backgrounds. Finally, we present a conservative estimate of the correlated broadband noise due to the magnetic Schumann resonances in O2, based on magnetometer measurements at both the LIGO Hanford and LIGO Livingston observatories. We find that correlated noise is well below the O2 sensitivity. © 2019 American Physical Society. American Physical Society.