取经路上 2010-12-23
将公司的一款基于java的webgame从windows平台迁移至Linux平台,这套架构用了一个nginx做负载均衡,将不同应用的请求分发至2个tomcat中,第2个跑游戏的tomcat总是无法正常访问,从搭建环境到调试一直用了2天时间,最后才确定为机器配置太低无法加载游戏地图(更换高配的2U机器后一次性成功)。
找了一台2U的备机,登陆上去发现没装gcc,yum也因未注册无法正常使用,记录下解决方案,方便日后查看和遇到同样问题的童鞋。
1. 删除RHEL的默认yum
[root@localhost ~]# rpm -qa|grep yum
yum-updatesd-0.9-2.el5
yum-metadata-parser-1.1.2-2.el5
yum-rhn-plugin-0.5.3-30.el5
yum-3.2.19-18.el5
yum-security-1.1.16-13.el5
rpm –e yum* --nodeps
2. 下载并安装CentOS的yum
wget http://mirrors.sohu.com/centos/5.5/os/i386/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm
Wgethttp://mirrors.sohu.com/centos/5.5/os/i386/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm
wget http://mirrors.sohu.com/centos/5.5/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
[root@localhost ~]# rpm -ivh yum-3.2.22-26.el5.centos.noarch.rpmyum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
warning: yum-3.2.22-26.el5.centos.noarch.rpm: Header V3 DSA signature:NOKEY, key ID e8562897
Preparing... ########################################### [100%]
1:yum-metadata-parser ###########################################[ 33%]
2:yum-fastestmirror ########################################### [ 67%]
3:yum
3. 在/etc/yum.repos.d/rhel-debuginfo.repo中添加镜像
Vi /etc/yum.repos.d/rhel-debuginfo.repo
加入以下内容:
[base]
name=Red Hat Enterprise Linux $releasever -Base
baseurl=http://mirrors.sohu.com/centos/5.5/os/$basearch/
gpgcheck=1
[update]
name=Red Hat Enterprise Linux $releasever -Updates
baseurl=http://mirrors.sohu.com/centos/5.5/updates/$basearch/
gpgcheck=1
[extras]
name=Red Hat Enterprise Linux $releasever -Extras
baseurl=http://mirrors.sohu.com/centos/5.5/extras/$basearch/
gpgcheck=1
[addons]
name=Red Hat Enterprise Linux $releasever -Addons
baseurl=http://mirrors.sohu.com/centos/5.5/addons/$basearch/
gpgcheck=1
4. 下载并导入KEY
"/etc/yum.repos.d/rhel-debuginfo.repo" 16L, 518C written
[root@localhost ~]# cd /etc/pki/rpm-gpg/
[root@localhost rpm-gpg]# wget http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5
[root@localhost rpm-gpg]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
5. 这个时候就可以用yum安装gcc,然后编译nginx了
yum -y install gcc
yum -y install gcc-c++