[66] | 1 | #!/bin/sh |
---|
| 2 | |
---|
| 3 | echo "$1" |
---|
| 4 | |
---|
| 5 | if [ "$1" != configure ] |
---|
| 6 | then |
---|
| 7 | exit 0 |
---|
| 8 | fi |
---|
| 9 | |
---|
| 10 | setup_hdfsadm_user() { |
---|
| 11 | if ! getent passwd hdfsadm >/dev/null; then |
---|
| 12 | useradd hdfsadm |
---|
| 13 | mkdir -p /home/hdfsadm/.ssh |
---|
| 14 | mkdir -p /var/log/nutch |
---|
| 15 | ssh-keygen -t rsa -q -f /home/hdfsadm/.ssh/id_rsa -N "" |
---|
| 16 | cp /home/hdfsadm/.ssh/id_rsa.pub /home/hdfsadm/.ssh/authorized_keys |
---|
| 17 | chown hdfsadm:hdfsadm /var/log/nutch |
---|
| 18 | chown -R hdfsadm:hdfsadm /opt/nutch |
---|
| 19 | chown -R hdfsadm:hdfsadm /home/hdfsadm |
---|
| 20 | fi |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | check_root() { |
---|
| 24 | if ! test -e /root/.ssh/id_rsa ; then |
---|
| 25 | ssh-keygen -t rsa -q -f /root/.ssh/id_rsa -N "" |
---|
| 26 | fi |
---|
| 27 | if test -e /root/.ssh/id_rsa.pub ; then |
---|
| 28 | if ! test -e /root/.ssh/authorized_keys ; then |
---|
| 29 | cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys |
---|
| 30 | fi |
---|
| 31 | else |
---|
| 32 | ssh-keygen -t rsa -q -f /root/.ssh/id_rsa -N "" |
---|
| 33 | cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys |
---|
| 34 | fi |
---|
| 35 | |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | start_hadoop() { |
---|
| 39 | if getent passwd hdfsadm >/dev/null; then |
---|
| 40 | su -c "/opt/nutch/bin/hadoop namenode -format" hdfsadm - |
---|
| 41 | su -c "/opt/nutch/bin/start-all.sh" hdfsadm - |
---|
| 42 | else |
---|
| 43 | /opt/nutch/conf/hadoop-env.sh |
---|
| 44 | /opt/nutch/bin/hadoop namenode -format |
---|
| 45 | /opt/nutch/bin/start-all.sh |
---|
| 46 | fi |
---|
| 47 | } |
---|
| 48 | show_message() { |
---|
| 49 | echo "You can quickly start by following ways [in /opt/nutch/ with root privilege]:" |
---|
| 50 | echo "(1) Modify the urls/urls.txt file with indicate urls, one site one line." |
---|
| 51 | echo "(2) Use this instruction \"bin/nutch crawl urls -dir search -depth 4 -topN 50\" to crawl web" |
---|
| 52 | echo "(3) Type \" tomcat/bin/startup.sh \" and use browser to check the result in http://localhost:8080/" |
---|
| 53 | echo "Enjoy !" |
---|
| 54 | } |
---|
| 55 | #setup_hdfsadm_user |
---|
| 56 | #check_root |
---|
| 57 | #start_hadoop |
---|
| 58 | show_message |
---|