您的位置:首页 > 运维架构 > Linux

rhel6.3红帽Linux 64位系统安装R语言全解析

2014-08-09 03:22 357 查看
日期:20140809,由于r和Linux以及相关镜像的升级地址会改变,这里表述的是目前的状态

系统:VMware Workstation10 + Red Hat Enterprise Linux 6 64 位 ( red red )

环境:R-3.1.1.tar.gz

路径:装的位置为: /home/red/R

这里都是在线安装的过程,可以保存下yum的包,以后就不用在线安装了

在线装好后会有一段时间的404,等一会网络好了就没事了

重要:

http://mirrors.163.com/centos/

http://cran.r-project.org/

第一、R的安装过程

R语言是主要用于统计分析、绘图的语言和操作环境。

官方网站:
http://www.r-project.org/
Windows下面有直接的安装包,直接下载安装很方便,但是对于刚出的CentOS6.0上不能直接通过yum 安装R,需要自己编译。

下载页面:
http://ftp.ctex.org/mirrors/CRAN/
在编译R之前,需要通过yum安装以下几个程序:

(这之前或者有:yum install gcc)

#yum install gcc-gfortran #否则报”configure: error: No F77 compiler found”错误

#yum install gcc gcc-c++ #否则报”configure: error: C++ preprocessor “/lib/cpp” fails sanity check”错误

#yum install readline-devel #否则报”–with-readline=yes (default) and headers/libs are not available”错误

#yum install libXt-devel #否则报”configure: error: –with-x=yes (default) and X11 headers/libs are not available”错误

然后下载源代码,编译

#cd

#wget http://ftp.ctex.org/mirrors/CRAN/src/base/R-3/R-3.1.1.tar.gz
#tar zxvf R-3.1.1.tar.gz

#cd R--3.1.1

#./configure



可能以后用到:

如果使用rJava需要加上 --enable-R-shlib

./configure --enable-R-shlib --prefix=/usr/R-3.0.1



#make

#make install

即可完成编译安装。

#配置环境变量

vi .bash_profile

PATH=/home/red/R/R-3.1.1/bin

#两个测试:这里目录是原址,仅供参考

1.测试:创建脚本(t.R)

cd /opt/script/R

vim t.R

#!/path/to/Rscript #第一行

x<-c(1,2,3) #R语言代码

y<-c(102,299,301)

model<-lm(y~x)

summary(model)

2.测试:执行脚本

R CMD BATCH --args /opt/script/R/t.R

more /opt/script/R/t.Rout #查看执行的结果

或者第二种方式

Rscript /opt/script/R/test.R #结果直接输出到终端

from:

1.http://blog.csdn.net/qibaoyuan/article/details/6827352

2.http://blog.itpub.net/21711990/viewspace-1114418/

3.http://www.myexception.cn/linux-unix/680876.html

4.http://blog.sina.com.cn/s/blog_6dd65c6f0100y793.html

第二、问题来了 yum 不管用!咋办?

#简单的过程

1、删除原有的yum:

rpm -aq | grep yum | xargs rpm -e –nodeps

2、安装新的yum

《1》rpm –ivh http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
注:python-iniparse-0.3.1-2.1.el6.noarch.rpm这个版本可能随着包的更新导致在这个地址上不一定存在,可输入http://mirrors.163.com/centos/6/os/x86_64/Packages(CentOS6),这个页上面有具体包列表,查找python-iniparse的包,修改为正确的地址即可。下面几步和这一步相似。

《2》 rpm -ivh http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
《3》 rpm -ivh http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

注:这是两个rpm包

《4》cd /etc/yum.repos.d/

#这里需要清空yum仓库

《5》wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
《6》sed -i "s/\$releasever/6/" CentOS6-Base-163.repo

#这个语法指的是把文件CentOS6-Base-163.repo(下载下来是个模板)里面所有的$releasever全部替换为你得版本号即:6,注意空格

《7》yum makecache

#详细的解答,这里的路径是不准确的参照上方即可

1.删除redhat 原有的yum

rpm -aq|grep yum|xargs rpm -e --nodeps

2.下载yum 安装文件

Wget -c http://mirrors.163.com/centos/6.4/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
wget -c http://mirrors.163.com/centos/6.4/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
wget -c http://mirrors.163.com/centos/6.4/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget -c http://mirrors.163.com/centos/6.4/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
3.安装yum 软件包

(1)rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm

(2)rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

(3) 两个一起安装先后顺序不要乱(中间50%正常)

rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

4、更改yum源 #我们使用网易的CentOS镜像源

(1)清空yum仓库

# cd /etc/yum.repos.d/

#rm -rf *

(2)设置源

# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
# vi CentOS6-Base-163.repo

编辑文件,把文件里面所有的$releasever全部替换为你得版本号,即6.4 最后保存!或者直接把下面的内存拷贝到CentOS6-Base-163.repo文件中即可(已经修改好)

#################################################################

# CentOS-Base.repo

#

# The mirrorsystem uses the connecting IP address of the client and the

# update status ofeach mirror to pick mirrors that are updated to and

# geographicallyclose to the client. You should use thisfor CentOS updates

# unless you aremanually picking other mirrors.

#

# If the mirrorlist=does not work for you, as a fall back you can try the

# remarked outbaseurl= line instead.

#

[base]

name=CentOS-6.4 -Base - 163.com

baseurl=http://mirrors.163.com/centos/6.4/os/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=6.4&arch=$basearch&repo=os

gpgcheck=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates

[updates]

name=CentOS-6.4 -Updates - 163.com

baseurl=http://mirrors.163.com/centos/6.4/updates/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=6.4&arch=$basearch&repo=updates

gpgcheck=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additionalpackages that may be useful

[extras]

name=CentOS-6.4 -Extras - 163.com

baseurl=http://mirrors.163.com/centos/6.4/extras/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=6.4&arch=$basearch&repo=extras

gpgcheck=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additionalpackages that extend functionality of existing packages

[centosplus]

name=CentOS-6.4 -Plus - 163.com

baseurl=http://mirrors.163.com/centos/6.4/centosplus/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=6.4&arch=$basearch&repo=centosplus

gpgcheck=1

enabled=0

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib -packages by Centos Users

[contrib]

name=CentOS-6.4 -Contrib - 163.com

baseurl=http://mirrors.163.com/centos/6.4/contrib/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=6.4&arch=$basearch&repo=contrib

gpgcheck=1

enabled=0

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#####################################################################

5、清理yum缓存

# yum clean all

# yum makecache #将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度

# yum installvim* #测试域名是否可用

构建数据源基本资料

yum repolist all

(如果这时运行正常,且enabld字段为1,那么表示yum源配置成功了)
至此,Redhat6可以使用CentOS的yum源在线安装软件了!

6.使用 # yum update

或 # yum upgrade 升级系统

注:两个命令区别:

# yum update

升级所有包,改变软件设置和系统设置,系统版本内核都升级

# yum -y upgrade

升级所有包,不改变软件设置和系统设置,系统版本升级,内核不改变

from:

1.http://www.2cto.com/os/201304/205588.html

2.http://www.2cto.com/os/201312/265042.html

3.http://www.cnblogs.com/mailingfeng/archive/2012/09/01/2666745.html

4.http://zhidao.baidu.com/link?url=hDZVtr-icKFpg7Jfi84I1Lwf67EQn258fvwMnO_RQa_i_voYkd8b7iA1WmwUkNG5mKWiJdZUTsxeOpBatMFBua

#其他安装注意:

1.替换yum数据源的过程中/etc/yum.repos.d/:

首先备份/etc/yum.repos.d/CentOS-Base.repo

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份)

CentOS5
CentOS6

运行以下命令生成缓存
yum clean all
    yum makecache

2.


Linux中“is not in the sudoers file”解决方法



其实就是没有权限进行sudo,解决方法如下(这里假设用户名是cuser):

1.切换到超级用户:$ su

2.打开/etc/sudoers文件:$vi /etc/sudoers

3.修改文件内容:按 “i” 进去编辑状态

找到“root ALL=(ALL) ALL”一行,在下面插入新的一行,内容是“xxx ALL=(ALL) ALL”,然后按“Esc”,按”:“,滞后键入命令“wq!”保存并退出。

注:这个文件是只读的,不加“!”保存会失败。

4.退出超级用户:$ exit

5.可以尽情使用sudo了。
3.can't create transaction lock on /var/lib/rpm/.rpm.lock 错误

错误原因:权限问题

解决方法:在终端输入“su”和密码,登录root,以root身份登录就不会有提示

4.


更改CentOS yum 源为163的源中使用

移动文件或目录,或是更改其名称使用:mv

from:

1.http://mirrors.163.com/.help/centos.html

2.http://blog.csdn.net/inkfish/article/details/5168676

2.2 http://www.2cto.com/os/201302/189692.html
3.http://blog.csdn.net/leeafu/article/details/7449353

4.http://blog.csdn.net/fengyifei11228/article/details/8499932

#理解入门的过程

摘要:如果我们刚刚安装了RedHat系统,当我们安装软件源或者进行更新的时候,将会出现如下提示:“Unable to read consumer identity”。很显然,这个提示告诉你,yum没有读取到你的用户id。如果想使用redhat同时不想花费几千元注册系统,我们可以使用CentOS的源来替代。

1.注册系统给我们提供了什么?

如果我们点击系统的RHN,会提示注册系统的种种好处:

1)从官方获得软件源

2)免费或者系统的安装镜像和升级

3)系统故障以后,有专门的维护人员来协同我们处理

对于大部分人员,我们往往只关系,系统能否正常安装软件就够了。而redhat上yum的机理是这样的,通过yum读取配置文件/etc/yum.repos.d/file.repo,通过里面提供的网址,到相应站点下载rpm软件包,然后调用底层的rpm程序进行安装。其中,在下载环节,需要提供consumer id。从理论上说,只要我们不到官方网站上下载软件,就能够避免注册问题。

2.一个可以替代的站点:centos

我们都知道,redhat是一个商用的OS,但是它是开放源代码的。所以,社区会将redhat的源代码进行重新编译,然后去掉redhat的商标,进行发布,这就是centos。对于一般用户而言,可以认为:centos和redhat是相同的。因此,我们可以到centos对应的站点来下载软件源。国内一些网站,比如网易163提供一些开源软件的下载地址,我们可以将软件源改成国内的。

进入到 /etc/yum.repos.d, 其中有个rhel-source.repo, 先改名为rhel-source.repo.bak,做个备份

然后新建个 rhel-source.repo

内容如下:~~

from:

1.http://www.linuxidc.com/Linux/2013-12/93375.htm

2.http://www.linuxidc.com/Linux/2010-12/30773.htm

待续:


保留 yum 下载的软件包

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: