Redhat offline installation of R and Rserve__redhat

Source: Internet
Author: User
Tags gz file prepare readline gfortran

0 Preface 1 System Information 2 installation package preparation 3RedHat installation JDK process 1 Check system with Java Environment 2 uninstall system with Java 3 install JDK 4 Configure environment variable 5 test 4RedHat install R process 1 Check GCC Environment 2 unpack R installation package 3 Configure R install package 4 compile R install Package 5 Installation R 6 configuration r environment variable 7 inspection r installation 5RedHat installation Rserve process 1Rserve installation 2Rserve Configuration 3 other Rserve related commands 31 view Rserve Status 32 view Rserve Access 33 End Rserve Process 6 closing

0 Preface

Recently, I learned about the R language and installed the RedHat6.5 system in the virtual machine to implement the R calculation by deploying R in the Redhat system, because the customer requires that the appropriate R program be installed offline, so you need to prepare the package in advance. The language of the call R is Java, and the next article describes how to use Java calls. 1 System Information

The following installation screenshot is the Redhat 6.5 installation process in the Win7 64-bit virtual machine VMware and is used by a non-root user with a username of 007.

The RedHat6.5 version information used is as follows, if you look for GCC to get content inconsistent with the following figure, such as no gcc-gfortran, please ignore:
2 installation package Preparation

The installation packages prepared here mainly include R installation, Rserve installation packages and possible dependency packs, which are primarily related to the GCC compiler, can be installed on the basis of missing content and then installed with R and Rserve if prompted for missing dependent packages during installation. R and Rserve installation packages (tar.gz files) can be downloaded directly from the official website, dependent packages (. rpm files) I was directly extracted from the packages folder of the Redhat system disk, and the JDK was also downloaded from the official website. The installation preparation package is shown in the following illustration:

Limited by the upload permission, had to do two download packages for everyone to download, respectively: R Related: jdk1.6:http:// 3RedHat installation JDK process

Redhat system with the Java environment, not recommended, especially OPENJDK content, it is recommended to uninstall the use of their own installed JDK, I use the official website download JDK1.6 version. 3.1 Check system with Java environment

Open a terminal window and enter the following command to see if Java is installed, as seen by Windows, as follows:


If a version number is displayed in the returned information, the Java environment is shown and needs to be uninstalled. 3.2 Uninstall system with Java

Look at your own Java environment, typically searching through the Java keyword to see what is installed for the following uninstall. Enter command:

Rpm-qa|grep Java

The results are as follows (depending on the system, the results are different):

# java-1.4.2-gcj-compat- 

You need to uninstall your own Java above, using the following command:

Rpm-e--nodeps java-1.4.2-gcj-compat- 
rpm-e--nodeps java-1.6.0-openjdk-

After uninstalling, use the java-version command to detect if there is no Java environment, if available, use the JDK and GCJ keyword to repeat 3.1-3.2 steps to find and remove, and ensure that the Java environment is cleaned up. 3.3 Installing JDK copy files
Install the jdk1.6 file downloaded from the official website, I downloaded the jdk-6u45-linux-x64.bin file, you need to copy the file to a directory, here is the/home/007/java directory, the following configuration needs to use the directory, Of course, you can also choose a different directory of your own. Performing the installation
Go to the/home/007/java directory to execute the installation command, as follows, waiting for execution to complete:

[007@localhost java]$./jdk-6u45-linux-x64.bin
3.4 Configuring environment Variables

After installing the JDK, you need to configure the environment variables for the user, and there are three different configurations of environment variables under Linux:
A. All users can use the environment variables, the next login can also be used;
B. The current user can use the environment variables, the next login can also be used;
C. Temporary environment variables that are no longer valid after exiting the login.

The second environment variable used here, for 007 users to configure the environment variables, and the next login to normal use, the first need root permissions, too high, or not to use for good; the third is that few people will use it in real system applications.

Configuring the current user environment variable needs to modify the. bash_profile file, which is located in the ~ directory, make sure to execute the Modify command after entering the ~ directory, or it will be invalid, execute the following command:

[007@localhost java]$ cd ~
[007@localhost ~]$ vi. Bash_profile

Edit the file through the VI editor, if you do not know how to use the VI editor, find the information yourself, here is not detailed, here only to tell you to enter the command, press the letter I into the insert mode, and then move the cursor up and down to the position to enter, and then change what you see to the following content:

#. Bash_profile  

# Get the aliases and functions  
if [-f ~/.BASHRC]; then  
       . ~/.bashrc  

# User Specif IC Environment and startup programs  
classpath=.: $JAVA _home/lib/dt.jar : $JAVA _home/lib/tools.jar  
path= $JAVA _home/bin: $PATH: 

No more explanations, input finished press the ESC key to exit Insert mode, enter the command mode, and then enter directly: X return (enter a colon and lowercase x to exit after saving).

After the configuration is complete, you need to take the configuration into effect, executing the following command:

[007@localhost ~]$ Source Bash_profile
3.5 Test

After you configure the Java environment variables, you need to test whether the Java environment variable settings are correct or not, often using java-version to see if you can get the correct JDK version information, personal advice to write a simple Java program to test the most reliable, believe me.
Find a place to create a Java program file, such as a new file under/home/007, you can use Gedit to edit this file, add the following code to save:

public class hellojava{public
    static void Main (string[] args) {
        System.out.println ("How Do I Do");

Enter the following command in the terminal:

[007@localhost ~]$ cd/home/007
[007@localhost ~]$ javac
[007@localhost ~]$ java Hellojava

If you can see how to print out how to do it? Description of the installation has been successful, the general second line of execution has not prompted anything to say OK, there is a problem, the second line of command execution will be an error, if there is a problem, please paste the error message to the full again to discuss, It is difficult to give a satisfactory answer without an error message. 4RedHat Installation R process

I use the R installation package for the official website to download the r_3.1.2.tar.gz file, can be downloaded from the official website or from the download file I uploaded to find. 4.1 Check GCC environment

R installation needs to use GCC and Gfortran commands, usually redhat with GCC, and gc++ and Gfortran are not installed, we have to check before the installation, of course, you directly execute the following command, according to the prompts to carry out the necessary dependency package installation is also possible.
The commands for viewing the GCC environment are as follows:

[007@localhost desktop]$ Rpm-qa | grep gcc

If the resulting results include the gcc-c++ and Gcc-gfortran files, congratulations you can continue with the installation below, if you get a result that contains only one GCC start, then you need to install gcc-c++ and Gcc-gfortran. The installation file is available in the download link I gave, after the download is unpacked, go into the folder and execute the following command.

Installation of the RPM package needs to go to the root user, and the installation of these two files also need to rely on the corresponding LIB file, before the installation needs to install their dependencies, Gfortran installation as an example. As shown in the following illustration:

The installation gc++ is the same as the command above, as long as the installation file is changed to the corresponding gc++. 4.2 Decompression R installation package

Download r-3.1.2.tar.gz can not be directly installed, you need to extract it to the specified directory, not necessarily the installation directory, such as I will extract it to the/home/007, my compression package is in the/home/007 directory, So I went into the directory and executed the following command to complete the decompression:

[007@localhost 007]$ tar–zvxf r-3.1.2.tar.gz

After the decompression is complete, the R-3.1.2 folder is established under/home/007. 4.3 configuration R installation package

Go to the R-3.1.2 folder and execute the following command:

[007@localhost r-3.1.2]$./configure--enable-r-shlib--prefix=/home/007/r3.1.2--with-x=no--with-readline=no

  The following parameters are very important, please be sure to understand
  –enable-r-shlib This parameter is particularly important, if you do not have this parameter, then you will not be able to use the following Rserve

  –prefix=/home/007/r3.1.2 This parameter is used to define the installation location of R, must ensure that the directory exists, if not the directory, please create this directory, do not specify this directory will be installed to the decompression directory that/home/007/ In R-3.1.2, this is not recommended, please specify an empty directory

  –with-x=no means that the x-windows system is not used, that is, the GUI of Unix-like operating systems, which is not normally used, but the default is yes, if you do not install LIBX, you will not be able to correct the error, so we directly set to No

  –with-readline=no indicates that the system's ReadLine library is not used, and if there is no libreadline on the system, this option fills in "No" and the default is yes, but the ReadLine library is not installed under my system. And I'm not going to write the R program on one line in the Redhat command terminal, I set it to no, the result is that we can not use the next key to find the use of the command, hehe, anyway, I will not write in the terminal write how many lines r command, if you want to use, It is recommended that you find out if the ReadLine is installed on your machine, if not, I will install the package, and then set it to Yes, and execute the above command.

A lot of times we have a problem executing this command, please make sure that the four articles I wrote above have already been understood, and then send the error of the prompt to the comments when I have any questions, I'll take a look at it. After the execution, you will be prompted for the following:
4.4 Compile R installation package

Configure after the completion of the need to execute the compilation command, the execution of the process is relatively long, please be patient. Also execute the following command under the uncompressed directory R-3.1.2:

[007@localhost r-3.1.2]$ make

After executing the prompt, only the last part is intercepted, as follows:
4.5 Installation R

Next execute the install command, or execute the following command under the uncompressed directory R-3.1.2:

[007@localhost r-3.1.2]$ make install

The prompt after execution is shown below (only the last part is intercepted):
4.6 Configure r environment variable

See the 3.4 content to modify the. bash_profile file to the following form:

Executes the source. bash_profile command after saving to make the configuration effective. 4.7 Inspection R Installation

After modifying the R environment variable and making it effective, you can enter the r command window in the terminal, as shown in the following figure:

When you enter r in the figure above, you will be prompted to install the R version along with some instructions, the last three lines are my test program, I entered a vector data, and then I looked at the vector.

Enter Q () to exit the R command line mode. 5RedHat Installation Rserve process 5.1Rserve installation

Because it is offline installation, so you need to prepare Rserve installation package, I use here is the rserve_1.8-1.tar.gz file, I provide the installation package also exists in this, please download or download from the website according to the actual situation.
In the terminal, execute the following command:

[007@localhost ~]$ R CMD install/home/007/rsrc/rserve_1.8-1.tar.gz

The installation process is smooth and quick, screenshots are as follows:

After the installation is successful, prompt as follows:

You can see the last hint of "done (Rserve)" indicates that the installation was successful.

  If there is a hint of a setup error, please make sure you read the meaning of the four parameters I wrote when you installed R .

The command to start Rserve is:

[007@localhost ~]$ R CMD rserve

Starting the Success console prompts "Rserv started in daemon mode." After the successful start of the interface prompts as shown in the following image:

You can use Rserve to call R at this point, but only local calls, external computers cannot be invoked, Rserve are not allowed under the default configuration, and the following configuration content can be ignored if external access is not required. 5.2Rserve Configuration

Use the following command to view the configuration information for Rserve:

[007@localhost ~]$ R CMD rserve--rs-settings

After completion, you will be prompted for Rserve configuration information, including the location of the configuration file, whether external access is allowed, and so on, and the default read profile is typically in the/etc/ In rserv.conf, although the default profile is listed, the default profile does not exist, only to tell the user that if they need to configure it, create a new one and then configure it in that configuration file.

Because I need to remotely invoke Redhat under the Rserve, so I need to turn on the remote Access feature, and the ETC folder under the new file is required root permissions, so I also need to switch to the root of the new rserv.conf file, and add a line of code, as follows:

Remote Enable

Add and save, then restart Rserve to complete the configuration. 5.3 Other Rserve related commands 5.3.1 view rserve status

[007@localhost ~]$ Ps-aux | grep rserve

All Rserve processes are listed, including process number 2766, as shown in the following illustration:
5.3.2 View Rserve access

[007@localhost ~]$ Netstat–ntlp|grep Rserve

The results are as follows: means that all can be accessed (after the remote access state is turned on), and indicates that only local access is allowed. The port number is 6311, the default port number. 5.3.3 End Rserve Process

[007@localhost ~]$ kill-pid 2766
6 Concluding remarks

After installing Rserve, when you need to call R through Rserve, you need to start the Rserve on the computer where the Rserve is installed to make the call.

In addition, if firewall policy is configured on the server where r is installed, you will need to modify the firewall, the specific configuration is no longer detailed, please refer to the relevant information.

The next section will specifically describe how to call R in the Java language.

Send a rose, hand fragrance, reproduced please indicate the source.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.