Hadoop和RDBMS(Hadoop and RDBMS)
Hadoop主要用于处理非结构化或半结构化数据。 我想使用Hadoop处理大量结构化数据。
尽管hadoop能够从数据库中读取(通过DBInputFormat),但它不被视为可扩展的方法,因为数据库连接的数量将受到限制。
有人用hadoop从RDBMS读取数据吗? 表现如何? 它可以支持多少个节点?
谢谢
Hadoop is mainly used to process unstructured or semi-structured data. I want to use Hadoop to process large amount of structured data.
Though hadoop is capable of reading from database (via DBInputFormat), it is not considered as a scalable approach as number of database connection would be limited.
Has anybody used hadoop to read data from RDBMS? What was the performance? How many nodes could it support?
Thanks
原文:https://stackoverflow.com/questions/8339491
最满意答案
当您启动子shell时,与反引号一样,bash自行分叉,然后执行您想要运行的命令。 然后你还运行一个管道,导致所有这些都在他们自己的子shell中运行,所以你最终得到了等待管道完成的脚本的“额外”副本,这样它就可以收集输出并将其返回给原始剧本。
我们将使用
(...)
在子shell中显式运行进程并使用pgrep
命令来做一些实验ps | grep "name" | grep -v grep
ps | grep "name" | grep -v grep
ps | grep "name" | grep -v grep
对我们来说,只是向我们展示了与我们的字符串匹配的进程:echo "Start" (pgrep test.sh) (pgrep test.sh) | wc -l (pgrep test.sh | wc -l) echo "end"
这对我来说就是产生输出:
Start 30885 1 2 end
所以我们可以看到,在子shell中运行
pgrep test.sh
只能找到test.sh的单个实例,即使该子shell是管道本身的一部分。 但是,如果子shell包含一个管道,那么我们会得到等待管道完成的脚本的分叉副本When you start a subshell, as with the backticks, bash forks itself, then executes the command you wanted to run. You then also run a pipeline which causes all of those to be run in their own subshells, so you end up with the "extra" copy of the script that's waiting for the pipeline to finish so it can gather up the output and return that to the original script.
We'll do a little expermiment using
(...)
to run processes explicitly in subshells and using thepgrep
command which doesps | grep "name" | grep -v grep
for us, just showing us the processes that match our string:echo "Start" (pgrep test.sh) (pgrep test.sh) | wc -l (pgrep test.sh | wc -l) echo "end"
which on a run for me produces the output:
Start 30885 1 2 end
So we can see that running
pgrep test.sh
in a subshell only finds the single instance of test.sh, even when that subshell is part of a pipeline itself. However, if the subshell contains a pipeline then we get the forked copy of the script waiting for the pipeline to finish
相关问答
更多-
根据你想做什么xargs也可以帮助(这里:用pdf2ps转换文件): cpus=$( ls -d /sys/devices/system/cpu/cpu[[:digit:]]* | wc -w ) find . -name \*.pdf | xargs --max-args=1 --max-procs=$cpus pdf2ps 从文档: --max-procs=max-procs -P max-procs Run up to max-procs processes at a time; ...
-
对任何shell脚本进行良好的健全性检查是在其上运行ShellCheck: Line 9: kill ${pids[@]} 1>/dev/null 2>&1 || true ^-- SC2145: Argument mixes string and array. Use * or separate argument. 事实上,你的xtrace在这一行上做了一些奇怪的事情: kill 31678' '32048 1>/dev/null 2>&1 || true ...
-
1,2。 使用pgrep 。 我不记得pgrep是否有-c参数,所以你可能需要将它传递给wc -l 。 3:该输出由shell的作业控件生成。 我认为如果你将其作为脚本运行(不在交互式shell中),则不应该有这样的输出。 对于交互式shell,有多少方法可以关闭它,但它们与shell有关,因此请参阅shell的手册。 1,2. Use pgrep. I don't remember off the top of my head whether pgrep has -c parameter, so you ...
-
如何使用Linux bash函数“并行触发两个进程”(How to use a Linux bash function to “trigger two processes in parallel”)[2024-02-22]
由于schemathings间接指示,您可能希望使用tasty_watch.sh将“&”字符附加到行的末尾。 (没有单引号)。 我没有看到任何理由使用'&'作为最终的watch命令,除非你在此之后添加更多命令。 unix命令行末尾的“&”表示“在后台运行”。 你可能想在调用fresh_watch之后插入一个sleep $ {someNumOfSecs},给它一些时间让CPU自己动手。 看到你提到xterm,你知道crontab工具,它允许你安排一个你想要的任何时间运行的工作,并且没有用户必须登录? (也许这 ... -
如何退出(bash脚本),如何监控两个进程并执行某些操作?(How do I monitor two processes & do something if one exits (bash scripting)?)[2024-01-21]
不要使用while循环。 只需阻止并等待SIGCHLD告诉您其中一个进程已终止。 在陷阱中,终止剩余的正在运行的进程。 例如: #!/bin/bash set -m trap 'list=$( jobs -rp ); test -n "$list" && kill $list' CHLD cmd1 & cmd2 & cmd3 & wait 这将运行3个命令。 当一个退出时,另外两个将被发送SIGTERM。 Do not use a while loop. Just block and wait for ... -
检查生成其他进程的bash脚本中的总内存使用情况(Checking for total memory usage in a bash script which spawns other processes)[2021-10-23]
如果子进程没有自己的子进程,那很容易: $ ps h --ppid "$PID" -o vsz | awk '{ SUM+=$0 }; END { print SUM }' 否则,您可能依赖于进程组ID(PGID),但是确保从脚本调用的程序不会设置自己的进程组是值得的。 $ ps h -e -o pgid,vsz | awk -v "PGID=$PID" '$1==PGID { SUM+=$2 }; END { print SUM }' 如果脚本的所有子节点都不属于同一个PGID,我们只能递归循环遍历进 ... -
当您启动子shell时,与反引号一样,bash自行分叉,然后执行您想要运行的命令。 然后你还运行一个管道,导致所有这些都在他们自己的子shell中运行,所以你最终得到了等待管道完成的脚本的“额外”副本,这样它就可以收集输出并将其返回给原始剧本。 我们将使用(...)在子shell中显式运行进程并使用pgrep命令来做一些实验ps | grep "name" | grep -v grep ps | grep "name" | grep -v grep ps | grep "name" | grep -v gr ...
-
如何检查启动4个不同后台进程的bash脚本的执行时间(How to check execution time of a bash script that starts background processes)[2022-04-30]
看看bash中的wait函数 。 它只是等待所有子进程完成。 然后您可以轻松计算经过的时间,例如使用SECONDS内部变量( 此处说明): SECONDS=0 declare -a arr=("seed_automation_data_1" "seed_automation_data_2" "seed_automation_data_3" "seed_automation_data_4") command="bundle exec rake db:seed:" for i in "${arr[@]}" d ... -
grep -vw将删除匹配正则表达式w (这只是包含字符串w任何东西)。 要运行命令,你必须这样说; 但正如在说明书中暗示的那样,您还需要使用cut来对输出进行后处理。 为了不完全给出答案,这里是粗略的伪代码。 w | cut something >tempfile ps -A | grep -Fvf tempfile 如果你可以在管道中传递w的后处理结果,但标准输入已经与ps -A绑定,那将会很好。 如果你有一个支持进程替换的shell,你可以使用它。 ps -A | grep -Fvf <(w | c ...
-
这些消息不是来自killall命令。 当它注意到它的一个后台子进程已经死亡时,它们就来自shell。 您可以通过在子shell中运行命令来防止这种情况: (phantomjs Lib/loadtester/runTests $TEST_COUNT $CLIENT_LIMIT $ACTION $PROFILE $TEST_SERVER $TEST_INCREMENT $DEBUG_MODE > "/tmp/"$TEST_COUNT"_log.txt" &) 后台进程现在是子shell的子进程,而不是原始脚本 ...