There is a growing need to connect renewable energy systems (REs), such as photovoltaic systems (PVs), to the power grid for solving environmental problems such as global warming. However, an electricity grid with RE is vulnerable to problems of power shortage and surplus owing to the uncertainty of RE outputs and grid failures. Energy storage systems (ESSs) can be used to solve supply reliability problems, but their installation should be minimized considering their high costs. This study proposes a method to optimize the allocations of PVs and ESSs based on vulnerability analysis, and utilizes our proposed concept of "slow" and "fast" ESSs, which can reflect the influences of both uncertainties: PV outputs and grid failures. Accordingly, this paper demonstrates an optimal allocation of PVs and ESSs that minimizes the amount of ESSs while satisfying the PV installation target and the constraints on supply reliability indices for power shortage and power surplus in the event of a grid failure.