This study measured the $^{10}\mathrm{Be}$ and $^{26}\mathrm{Al}$ production cross sections of muon-induced long-lived radionuclides to investigate the long-term variations in high-energy cosmic ray muon yields and high-energy galactic cosmic rays over a few million years. We exposed targets consisting of synthetic silica plates and quartz samples in a 1-m-long granite core to a beam containing $8.79\ifmmode\times\else\texttimes\fi{}{10}^{12}$ positive muons over $\ensuremath{\sim}120\text{ }\text{ }\mathrm{days}$ with an energy of 160 GeV extracted at the COMPASS experiment line at CERN-SPS. The experiment revealed the $^{10}\mathrm{Be}$ and $^{26}\mathrm{Al}$ production rates in the synthetic silica plates as $(1.8\ifmmode\pm\else\textpm\fi{}0.1)\ifmmode\times\else\texttimes\fi{}{10}^{\ensuremath{-}7}$ and $(1.3\ifmmode\pm\else\textpm\fi{}0.08)\ifmmode\times\else\texttimes\fi{}{10}^{\ensuremath{-}6}\text{ }\text{ }\text{atoms}/\mathrm{muon}/({\mathrm{g}}_{\mathrm{SiO}2}/{\mathrm{cm}}^{2})$, respectively. In addition, we obtained the production rates in the granite core as approximately $(4.1\ifmmode\pm\else\textpm\fi{}0.2)\ifmmode\times\else\texttimes\fi{}{10}^{\ensuremath{-}7}$ and $(4.0\ifmmode\pm\else\textpm\fi{}0.3)\ifmmode\times\else\texttimes\fi{}{10}^{\ensuremath{-}6}\text{ }\text{ }\mathrm{atoms}/\mathrm{muon}/\phantom{\rule{0ex}{0ex}}({\mathrm{g}}_{\text{quartz}}/{\text{cm}}^{2})$ for $^{10}\mathrm{Be}$ and $^{26}\mathrm{Al}$, respectively, although those rates varied with location. Furthermore, we performed full muon exposure simulations for the identical experimental setup using two simulators, phits and fluka, to examine the $^{10}\mathrm{Be}$ and $^{26}\mathrm{Al}$ production rates obtained in the muon beam experiment. The experimental rates are approximately 2--3 times higher than the simulated ones. Although the simulations are complex and depend on many models. Additionally, the phits and fluka analysis of the particle contributions to the $^{10}\mathrm{Be}$ and $^{26}\mathrm{Al}$ production rates indicated that the positive muons and secondary particles produce those nuclides at a constant rate and an increasing rate with respect to granite core location, respectively, suggesting direct muon-induced spallation and secondary particle-induced spallation. The experimental production ratio $^{26}\mathrm{A}\mathrm{l}/^{10}\mathrm{B}\mathrm{e}$ also exhibited characteristics of both spallation types. We conclude that the production cross sections of $^{10}\mathrm{Be}$ and $^{26}\mathrm{Al}$ for the target atoms of oxygen and silicon were $9.2\ifmmode\pm\else\textpm\fi{}0.6\text{ }\text{ }\mathrm{\ensuremath{\mu}}\mathrm{b}$ and $132.3\ifmmode\pm\else\textpm\fi{}7.7\text{ }\text{ }\mathrm{\ensuremath{\mu}}\mathrm{b}$ via direct muon-induced spallation in the synthetic silica, and $27.2\ifmmode\pm\else\textpm\fi{}1.9\text{ }\text{ }\mathrm{\ensuremath{\mu}}\mathrm{b}$ and $486\ifmmode\pm\else\textpm\fi{}44\text{ }\text{ }\mathrm{\ensuremath{\mu}}\mathrm{b}$ including secondary particle-induced spallation in the granite quartz, respectively. Additionally, the depth profiles of $^{10}\mathrm{Be}$ and $^{26}\mathrm{Al}$ concentrations in rocks estimated from the known total muon flux deep underground and this study's cross sections were comparable to those of the concentrations measured at depths greater than $5000\text{ }\text{ }{\mathrm{g}/\mathrm{cm}}^{2}$. Overall, our study showed that these cross sections revealed by the high-energy muon beam experiment are a valuable tool for estimating variations in high-energy galactic cosmic rays over a few million years using in situ rocks and simulators.