Advertisement
Guest User

spark setup

a guest
Jan 22nd, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ### paste this file to user data field as text
  4.  
  5. ### make sure to replace <master-private-ip> and <worker-private-ip1> with your own IP addresses. Replace <id_rsa.pub> with your own as well
  6.  
  7. ### it works best when you launch a master first and configure it and then launch 1 slave with the id_rsa of the master. You can create an image of the slave and apply that image to as many slaves as needed. make sure to add slave private IPs to spark configuration
  8.  
  9. apt-get update
  10.  
  11. #apt-get install nano
  12.  
  13. apt-get -y install apt install openjdk-8-jre-headless
  14.  
  15. apt-get -y install scala
  16.  
  17. apt-get -y install python3-pip
  18.  
  19. apt-get -y install openssh-server openssh-client
  20.  
  21. apt-get -y install curl
  22.  
  23. curl -O http://www.gtlib.gatech.edu/pub/apache/spark/spark-3.0.0-preview2/spark-3.0.0-preview2-bin-hadoop2.7.tgz
  24.  
  25. tar xvf spark-3.0.0-preview2-bin-hadoop2.7.tgz
  26.  
  27. mv "/spark-3.0.0-preview2-bin-hadoop2.7/" /usr/local/spark
  28.  
  29. ###master
  30.  
  31. #echo "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/" | sudo tee /usr/local/spark/conf/spark-env.sh
  32.  
  33.  
  34. ###slaves
  35. echo '<id_rsa.pub>' | sudo tee -a ~/.ssh/authorized_keys
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. ###Do this manually after EC2 instance is finished installing
  43.  
  44. echo 'export PATH=/usr/local/spark/bin:$PATH' >> ~/.bash_profile
  45.  
  46. source ~/.bash_profile
  47.  
  48. ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
  49.  
  50. ###Master only:
  51. ###copy and paste the output to a text doc and save for slaves
  52. cat ~/.ssh/id_rsa.pub
  53.  
  54. ###Master only:duplicate this line with as many slaves as needed
  55. sudo chmod -R a+rwx /usr/local/spark
  56. echo 'export SPARK_MASTER_HOST=<master-private-ip>' | sudo tee -a /usr/local/spark/conf/spark-env.sh
  57. echo '<worker-private-ip1>'' | sudo tee -a /usr/local/spark/conf/slaves
  58.  
  59.  
  60.  
  61.  
  62. ###Checks on master
  63.  
  64. ### be able to connect to slaves
  65. #ssh -i ~/.ssh/id_rsa ubuntu@<worker-private-ip1>
  66.  
  67. ### launch spark
  68. ### sudo sh /usr/local/spark/sbin/start-all.sh
  69.  
  70. ### get the port for your security settings
  71. #ps aux|grep -i spark
  72.  
  73. ### spark UI
  74. #publicDNS (IPv4):8080
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement