San Pedro cactus
The San Pedro cactus (Echinopsis pachanoi, syn. Trichocereus pachanoi), is a fast-growing columnar cactus native to the Andes of Peru and Ecuador. Known to contain the psychedelic phenethylamine mescaline (lesser than with peyote), it is used mainly as an entheogen, as traditional medicine, and as an ornamental cactus.  It has been used for healing and religious divination in the Andes Mountains region for over 3000 years.  It is sometimes confused with its close relative, the Peruvian Torch cactus.
The plant is light to dark green, sometimes glaucous, and having 4-8 (usually 5-7) ribs.  Groups of 1-4 small, yellow to light brown, spines are located at the nodes which are spaced evenly (approximately 2 cm apart) along the ribs. San Pedro can grow up to 5 meters tall and have multiple branches, usually extending from the base.

# Alkaloids
San Pedro contains a number of psychoactive alkaloids, including the well-studied chemical mescaline (0.21 - 1.8%), and also 3,4-dimethoxyphenethylamine, 4-hydroxy-3-methoxyphenethylamine, 3-hydroxy-4,5-dimethoxyphenethylamine, 4-hydroxy-3,5-dimethoxyphenethylamine, anhalonidine, anhalinine, hordenine, tyramine, and 3-methoxytyramine.
Mescaline (3,4,5-trimethoxyphenethylamine) is a psychedelic drug and entheogen), which is also found in some other species of genus Echinopsis (i.e. Echinopsis lageniformis, Echinopsis peruviana, and Echinopsis scopulicola) and the species Lophophora williamsii (peyote).
Anecdotal evidence suggests that the highest concentrations of active substances are found in the layer of green photosynthetic tissue just beneath the skin. The darker green the cactus, the better the alkaloid content, which can be caused by such ways as growing/ stressing it with reduced sunlight indoors or in shade and/or leaving a cut section indoors for 6+ weeks, water starving, and injections of dopamine or a mixture of tyrosine and dopa over the body.
There are various mescaline extraction techniques, simple (boiling in water 5 to 7 hours) and complex (such as an acid-base extraction), the latter technique yielding a material with a significantly higher concentration of mescaline - this is probably the most common source of (black market) mescaline.

# Cultivation
San Pedro is very easy to grow in most areas.  Because it grows naturally in the high altitude, high rainfall areas of the Andes, it can withstand temperatures far below that of many other cacti.  In fact, its cultivation requirements are really more like 'normal' plants than most other cacti.  San Pedro requires fertile, free-draining soil.  They are susceptible to fungal diseases if over-watered, but are not nearly as sensitive as many other cacti, especially in warm weather.  They can be sunburned and display a yellowing chlorotic reaction to overexposure to sunlight.  In warm areas it is best to keep them out of direct sun in mid-summer.
In winter, plants will etiolate, or become thin, due to lower levels of light.  This may be problematic if the etiolated zone is not sufficiently strong to support future growth as the cactus may break in strong winds.  Some people also find it visually undesirable.  If you wish to avoid etiolation when temperatures drop and growth rates slow, encourage it to enter winter dormancy by withholding water and fertilizer from it over the winter.
The seeds are quite easy to germinate and grow. Their main requirements consist of high humidity levels, free-draining soil mix, and enough (but not too much) water, light, and nutrition. There are a number of commonly used methods that satisfy these requirements and the choice of a particular method depends mainly on the scale of the cultivation operation.
For soil, use coarse sharp sand (sieved river sand).  Some people also find coir or peat, or mixtures, to be effective.  The soil can be sterilized by cooking it in an oven on high for 1-2 hours.  Sterilization will be most effective if the sand is moist. If one is available, an autoclave would also be useful at this point. Some people find sterilization to be unnecessary.  This may depend on other factors.  The soil is placed into trays (which can be sanitized with bleach beforehand if desired) and the seeds planted into it (when the soil has cooled).  The seeds should be only just below the surface (i.e. two or three sand grains over them). The trays now need to be kept in a humid environment.  This may be achieved by the use of plastic bags, glass plates, or greenhouses, depending on scale. Seeds usually germinate within two weeks to a month, but sometimes come up after several months.
The seedlings stay in the humid environment for several months.  During this time they must be continually checked for water and nutrient requirements, and fungal pathogens. Ensure the soil stays moist, but not overly wet. Nutrients can be provided with a liquid fertilizer at 1/8th strength whenever growth rate slows down. Fungi can be killed with a sulfur or copper-based fungicide. There have been some reports of seedlings responding negatively to these treatments so be very cautious with the amount you use. There is some evidence that garlic is also an effective fungicide.
If germinating your seeds in cold weather, a heat mat and fluorescent light can be used. These should be set on a timer to mimic normal diurnal temperature cycles for germination but can be left on permanently for faster growth once all the seeds have sprouted. One good method for growing cacti seedlings using this setup is to germinate them in late winter and have them ready to go outside by spring as temperatures and light levels are increasing.

# Consumption
The most common form of preparation is to cut the cactus into slices, boil it for over 7 hours and juice it into a green liquid preparation that is then drunk during the ceremony which usually happens at night.
Another simple and effective method is to start by cutting the pricks out of the cut specimen being used first and then slice it (the darker green the cactus,  the better the alkaloid content, which can be caused by growing/ stressing it with reduced sunlight indoors or in shade and/or leaving a cut section indoors for 6+ weeks) down in between each of it's few columns, deep enough to cut the skin so to peel the tough skin off with tweezers. One can cut the trunk into more sections to make it easier to work around for de-pricking and peeling. Peel the skin from it's tips. Cut off only the darker green, most outer layer of each column that's just under the skin and looks like the tip of a stars' sections shape.  Only use this outer layer of the peeled cactus for consumption as it has the highest alkaloid content. This process may take 2-3+ hours, mainly depending on how quickly the skin is pilled. A way to break up the plant matter more finely, though not too significant of a step depending on the quality of cactus, is to take the chunks before blending them (or using a food processor which is better) and place them in a freezer until frozen. Thaw them out in order to aide in the breaking down of the cactus's cell wall. One should repeat the freezing-thawing process once or twice again, and this will further help turn it into a more fragment like material that's easier to break up by a blender or food processor. Quick absorption in the stomach is the key for enough of the mescaline to build up in the brain at once for a trip, and the more broken up it is the more rapidly it's digested. This is why it's best to take it on an empty stomach, so food doesn't get in the way and stomach acids build up that increase absorption. Place the material, whether it's been through a food processor or not, in a blender (unless the food processor is able to hold all) with lemonade or limeade, mainly for their effect on taste from high levels of citrus acid, and add more lemon or lime juice to help bring the alkaloid pH balance to a more even, acidic level so to neutralize the very bitter alkaloid heavy taste. Other citrus juice containing drinks could work, but those of lemon and lime are arguably the best combination of citrus acid level and common taste. Also, add sugar to help improve the taste. Once the material is as blended as possible, add some ice cubes to form a cold (so the taste is more suspended) slush like drink. Swallowing it is a hard part for most, and this method, aside from chemical extraction and powderizing it into capsules, may be the best for avoiding the problems of ingesting it. Erowid.com has some other methods for extraction. For cactus quality in general, don't use more than a 12" x 3" section of San Pedro with first time experiments, which can be a high dose for even someone well experienced, and use at least a 4" x 3" section to perceive threshold effects. One can use a small dose the first time to gauge the potency of the cactus, as it varies dramatically, and then wait at least a few days for a real experiment. Meditation/ prayer before and after ingesting it can help ease the discomfort of potential nausea and anxiety of the bitter, foreign material and improve the trip.
Should not be taken by people with a history of liver disorders or hepatitis. Should not be taken by pregnant women due to uterine contraction which can lead to miscarriage. Individuals with a history of cardiovascular problems (heart attack, blood clot, and stroke) or a family history of such problems, and the elderly should avoid consuming due to its vasoconstrictive effects.

# Medical Use
Echinopsis pachanoi is used to treat nervous conditions, cardiac disease, high blood pressure, and it has unique antimicrobial properties.
As mentioned earlier, Echinopsis pachanoi contains hordenine and ". . .it has been shown that hordenine, N, N-Dimethyl-hydroxyphenylethylamine, exhibits an inhibitory action against at least 18 strains of penicillin resistant Staphylococcus bacteria."

# Legality
In the US mescaline was made illegal in 1970 by the Comprehensive Drug Abuse Prevention and Control Act. It was prohibited internationally by the 1971 Convention on Psychotropic Substances and is categorized as a Schedule I hallucinogen by the CSA. Mescaline is only legal for certain natives (such as those involved in the Native American Church). "Mescaline is a controlled substance, U.S. code of Federal Regulations, title 21 part 1308.11(1987)."  Penalties for manufacture or sale can be as high as five years in jail and a fine of $15,000, with a penalty of up to one year and fine of $5000 for possession.
In most countries it is legal to cultivate San Pedro, but in countries where possession of mescaline and related compounds is illegal and highly penalized, cultivation for the purposes of consumption is most likely illegal and also highly penalized. This is the case in the USA, Australia, Canada, Sweden, Germany, and the UK, where it is currently legal to cultivate San Pedro for gardening and ornamental purposes, but not for consumption.
It is sold in "head shops" in Ireland.