In a test server I typed “sudo yum update”, it reported errors like:

$sudo yum update
Loaded plugins: branch, fastestmirror, security
Setting up Update Process
Bad id for repo: base.$releasever.x86_64, byte = $ 8
Bad id for repo: base.$releasever.noarch, byte = $ 8
Bad id for repo: ops.$releasever.x86_64, byte = $ 4
Bad id for repo: ops.$releasever.noarch, byte = $ 4
Loading mirror speeds from cached hostfile
http://mirrors.xxx.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again<

Then I found this web in google for introducing how to get the value of "$releasever", but it does not tell us how to set "$releasever" permanently. Therefore, I have to search word like "releasever" in the source code of 'yum':

rpm -ql yum|xargs sudo grep releasever * -rn

Finally the source code in '/usr/lib/python2.6/site-packages/yum/__init__.py' comes out:

releasever=self.conf.yumvar['releasever']

But where does 'self.conf.yumvar' get its values? The answer is '/etc/yum/vars/'. After

sudo bash -c "echo 6 > /etc/yum/vars/releasever"

My 'sudo yum update' works correctly now.