Cheerios is getting a Chex mate.

General Mills Inc., the nation's No. 2 cereal manufacturer and the maker of Cheerios and Wheaties, said yesterday that it will buy the Ralston Foods cereal brands, including Chex and Cookie Crisp, from Ralcorp Holdings Inc.

The deal, valued at $570 million, makes General Mills a stronger player in the increasingly combative cereal industry, where the biggest companies recently have been slashing prices to increase market share.

The purchase of Ralcorp's cereal and snack brand lines, which has been approved by the companies' boards but still must undergo federal regulatory review, involves an exchange of $330 million to $360 million in General Mills common stock and the assumption of $210 million to $240 million in Ralcorp debt.

Ralcorp, a relatively small player in the cereal industry, will continue to produce private label cereals, including products that go head-to-head with Chex. Private labels are products that resemble major brands but are produced under store names, and St. Louis-based Ralcorp is the largest producer of private label cereals.

Ralcorp's shareholders will receive shares of General Mills stock and stock in a newly created spin-off company that will include the private label cereal business, Beech-Nut baby food and other interests.

The acquisition comes when cereal manufacturers are being caught in a squeeze between rising costs and lower prices, said David Callahan, editor of Food World magazine.

"For years cereal was one of the highest margin areas in the supermarket, but this year we have seen essentially a price war," he said.

The price war started when the third-largest manufacturer, Kraft General Foods Inc., makers of Post cereals, lowered its prices and was matched by No. 1 Kellogg Co. and General Mills.

Since then, grain prices have risen as a result of bad weather in many parts of the country, Callahan noted.

The acquisition of the Ralston brands by General Mills "definitely protects their No. 2 position in the industry," said an industry analyst, who requested anonymity. "It gives them a very stand-alone marketable name with very little overlap in terms of competitive products."

Kellogg produces a product, Crispix, which is similar to Chex, but General Mills has offered nothing along those lines, General Mills spokesman Austin Sullivan said.

General Mills' U.S. cereal sales totaled $2.2 billion, and its sales of snacks, which include Bugles, were about $660 million for the fiscal year ended May 26.

Ralcorp's cereal and snack brand products had sales of more than $400 million for the 12 months ending June 1996.

Ralcorp's sale of its cereal brands follows a sale last month of its Colorado ski resorts to Vail Resorts Inc. for about $310 million in cash and stock. Both transactions were designed to improve shareholder value, Ralcorp President Richard A. Pearce said.

The reorganized company that will result from the General Mills transaction will emerge with almost no debt and will be tightly focused on businesses in which the company is strong.

Ralcorp stock closed at $22.50 yesterday, up $2.50 on volume of 2.3 million shares. General Mills stock closed at $55.12 1/2, down 25 cents, with 459,800 shares trading. THE CEREAL MIX

With its purchase of Ralcorp's branded cereals, General Mills will move about 3 percentage points closer to Kellogg's share of the cereal market. These figures are for the four weeks ended July 28: Kellogg 33% General Mills 25% Kraft Foods/Post-Nabisco 17% Ralcorp 9%* Quaker 9% Other 7% *Figure is total for Ralcorp's cereals; its branded cereals account for about a third of all its cereals. SOURCES: Information Resources Inc., Ralcorp