Use PHP and Shell to write Hadoop MapReduce programs. So that any executable program supporting standard I/O (stdin, stdout) can become hadoop er or reducer. For example, copy the code as follows: hadoopjarhadoop-streaming.jar-input makes any executable program that supports standard IO (stdin, stdout) become hadoop ma
Introduction to some common commands in hadoop. Assume that the Hadoop installation directory HADOOP_HOME is homeadminhadoop. Start and close Hadoop1. open the HADOOP_HOME directory. 2. run the shbinstart-all.sh to close Hadoop1. go to HADOOP_HOM. suppose Hadoop's installation directory HADOOP_HOME is/home/admin/hadoop
/ci_cuser_20141231141853691/* ' >ci_cusere_20141231141853691.csv echo $?~/.bash_profile: Each user can use this file to enter shell information dedicated to their own use, when the user logs on, theThe file is only executed once! By default, he sets some environment variables to execute the user's. bashrc file.Hadoop fs-cat ' $1$2/* ' >$3.csvMV $3.csv/home/ocdc/cocString command = "CD" + Ciftpinfo.getftppath () + "" +hadooppath+ "
()ThrowsIOException;
All three methods mean that they are actually DF and DU classes. They occasionally execute system commands through the runComamnd method of the Shell class, to get the df of the current directory,DuValue.
However, an interesting thing happened during the execution process. I have 13 partitions and there are more than 0.14 million blocks in total,
The average execution time of Df and d
Note and execute shell commands for Mysql queries. mysql executes shell commands.
Mysql query notes
1. when querying mysql, you must add the database prefix before the table. Otherwise, the database is the current database by default (when multiple databases are queried, duplicate queries may occur to the same table
follows:Hadoop fs-put *. Txt/tmp/input
Execute PHP mapreduce program in streaming mode
Copy the Code code as follows: Hadoop jar Hadoop-0.20.2-streaming.jar-input/tmp/input-output/tmp/output-mapper wc_ Absolute path of the mapper.php-reducer wc_reducer.php Absolute PathAttention:
The input and output directories are the paths on the HDFs
Mapper and Reducer is the path of the local machine, be sure to write
PHP used Thrift to upload local files to Hadoop's hdfs by calling SHELL, but the upload efficiency was low. another user pointed out that he had to use other methods .? Environment: The php runtime environment is nginx + php-fpm? Because hadoop enables permission control, PHP calls SHELL to upload local files to Hadoop
Hadoop
Upload sample text for StatisticsCopy codeThe Code is as follows:Hadoop fs-put *. TXT/tmp/input
Execute PHP mapreduce program in Streaming mode
Copy codeCode: hadoop jar hadoop-0.20.2-streaming.jar-input/tmp/input-output/tmp/output-mapper wc_mapper.php absolute path-reducer wc_reducer.php absolute pathNote:
The input and output directories are on hdfs.
Ma
job1. Enter the Hadoop_home directory.2. Execute SH bin/hadoop jar/home/admin/hadoop/job.jar [jobmainclass] [Jobargs]
Kill a running jobSuppose job_id is: job_201005310937_00531. Enter the Hadoop_home directory.2. Execute SH bin/hadoop job-kill job_201005310937_0053
more commands for HadoopThe operations
This article provides a detailed analysis of some commonly used commands in hadoop. For more information, see Hadoop installation directory HADOOP_HOME:/home/admin/hadoop.
Start and closeStart Hadoop1. go to the HADOOP_HOME directory.
2. execute sh bin/start-all.sh
Disable Hadoop1. go to the HADOOP_HOME directory.2.
Common commands and statements for Shell programming (SCRIPT) and Common commands for shellSome common Shell programming (SCRIPT) commands and statements can meet general requirements.Command Parameters received:
Number of parameters:
$ #
Parameter value:
Command itself
$value\n";
}
The gist of this code is to count how many times each word appears, and to "Hello 2World 1″Such a form of output.
Four, run with Hadoop
Upload the sample text to be counted
Copy Code code as follows:
Hadoop fs-put *. Txt/tmp/input
Execute PHP mapreduce program in streaming way
Copy Code code as follows:
H
Summary of common shell commands and common shell commands
Umask
Set the default mode when creating a file. For a file, the maximum value is 6, and for a directory, the maximum value is 7.The system does not allow the creation of a text file to grant the executable permission, and the corresponding directory bit indi
8. find in shell commands and find in shell commands
The find command, which is commonly used like cd. however, most of the time, one or two parameters are enough. or, barely enough. however, when we take the initiative to look at the find manual, we will find that the more practical functions are not used.
This articl
Hadoop reading Notes (i) Introduction to Hadoop: http://blog.csdn.net/caicongyang/article/details/398986291.shell operation1.1 All HDFs shell operation naming can be obtained through Hadoop FS:[[email protected] ~]# Hadoop FSUsage
/hadoop jar/home/admin/hadoop/job. jar [jobMainClass] [jobArgs]
Killing a running JobAssume that Job_Id is job_20100531_37_0053.1. Go to the HADOOP_HOME directory.2. Execute sh bin/hadoop job-kill job_20100531_37_0053
More Hadoop commandsThe Hadoop operation
Hadoop-0.22.0.The value of this parameter is that the DN calls the fsdatasetinterface interface method during the organization heartbeat packet. For details, refer to the methods in the fsdatasetmbean interface:
/** * Returns the total space (in bytes) used by dfs datanode * @return the total space used by dfs datanode * @throws IOException */ public long getDfsUsed() throws IOException; /** * Returns total capacity (in bytes) of s
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:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.