####################################################################################################################################### ####################################################################################################################################### ## THIS SCRIPT CUSTOMIZES THE DSVM BY ADDING HADOOP AND YARN, INSTALLING R-PACKAGES, AND DOWNLOADING DATA-SETS FOR STRATA ## SAN JOSE 2017 EXERCISES. ####################################################################################################################################### ####################################################################################################################################### #!/bin/bash source /etc/profile.d/hadoop.sh #PATH=paste0(Sys.getenv("PATH"),":/opt/hadoop/current/bin:/dsvm/tools/spark/current/bin") ####################################################################################################################################### ## Setup autossh for hadoop service account ####################################################################################################################################### #cat /opt/hadoop/.ssh/id_rsa.pub >> /opt/hadoop/.ssh/authorized_keys #chmod 0600 /opt/hadoop/.ssh/authorized_keys #chown hadoop /opt/hadoop/.ssh/authorized_keys echo -e 'y\n' | ssh-keygen -t rsa -P '' -f ~hadoop/.ssh/id_rsa cat ~hadoop/.ssh/id_rsa.pub >> ~hadoop/.ssh/authorized_keys chmod 0600 ~hadoop/.ssh/authorized_keys chown hadoop:hadoop ~hadoop/.ssh/id_rsa chown hadoop:hadoop ~hadoop/.ssh/id_rsa.pub chown hadoop:hadoop ~hadoop/.ssh/authorized_keys ####################################################################################################################################### ## Start up several services, yarn, hadoop, rstudio server ####################################################################################################################################### systemctl start hadoop-namenode hadoop-datanode hadoop-yarn rstudio-server ####################################################################################################################################### ## MRS Deploy Setup ####################################################################################################################################### cd /home/remoteuser wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Scripts/backend_appsettings.json wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Scripts/webapi_appsettings.json mv backend_appsettings.json /usr/lib64/microsoft-deployr/9.0.1/Microsoft.DeployR.Server.BackEnd/appsettings.json mv webapi_appsettings.json /usr/lib64/microsoft-deployr/9.0.1/Microsoft.DeployR.Server.WebAPI/appsettings.json cp /usr/lib64/microsoft-deployr/9.0.1/Microsoft.DeployR.Server.WebAPI/autoStartScriptsLinux/* /etc/systemd/system/. cp /usr/lib64/microsoft-deployr/9.0.1/Microsoft.DeployR.Server.BackEnd/autoStartScriptsLinux/* /etc/systemd/system/. systemctl enable frontend systemctl enable rserve systemctl enable backend systemctl start frontend systemctl start rserve systemctl start backend ####################################################################################################################################### # Copy data and code to VM ####################################################################################################################################### # Copy Spark configuration files & shell script cd /home/remoteuser wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Scripts/spark-defaults.conf mv spark-defaults.conf /dsvm/tools/spark/current/conf wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Scripts/log4j.properties mv log4j.properties /dsvm/tools/spark/current/conf wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Scripts/DSVM_Customization_Script.sh ## DOWNLOAD ALL CODE FILES cd /home/remoteuser mkdir Data Code mkdir Code/MRS Code/sparklyr Code/SparkR Code/bigmemory Code/ff Code/UseCaseHTS Code/UseCaseLearningCurves cd /home/remoteuser cd Code/MRS wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/MRS/1-Clean-Join-Subset.r wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/MRS/2-Train-Test-Subset.r wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/MRS/3-Deploy-Score-mrsdeploy.r wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/MRS/SetComputeContext.r wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/MRS/logitModelSubset.RData cd /home/remoteuser cd Code/SparkR wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/SparkR/SparkR_NYCTaxi_forDSVM.Rmd wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/SparkR/SparkR_NYCTaxi_forDSVM.html wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/SparkR/Operationalization_RemoteAccessAPI_forDSVM.R wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/SparkR/SparkR_GLM_Operationalization_forDSVM.R cd /home/remoteuser cd Code/sparklyr wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/sparklyr/sparklyr_NYCTaxi_forDSVM.Rmd wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/sparklyr/sparklyr_NYCTaxi_forDSVM.html cd /home/remoteuser cd Code/bigmemory wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/bigmemory/bigmemory.R cd /home/remoteuser cd Code/ff wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/ff/ff.R cd /home/remoteuser cd Code/UseCaseHTS wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/UseCaseHTS/sample_demo.R wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/UseCaseHTS/sample_demo.Rmd wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/UseCaseHTS/aust_hierarchy.png cd /home/remoteuser cd Code/UseCaseLearningCurves wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/UseCaseLearningCurves/high_cardinality_learning_curves_demo.Rmd wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Code/UseCaseLearningCurves/learning_curve_lib.R ## DOWNLOAD ALL DATA FILES # NYC Taxi data cd /home/remoteuser cd Data wget http://cdspsparksamples.blob.core.windows.net/data/NYCTaxi/KDD2016/trip_fare_12.csv wget http://cdspsparksamples.blob.core.windows.net/data/NYCTaxi/KDD2016/trip_data_12.csv wget http://cdspsparksamples.blob.core.windows.net/data/NYCTaxi/KDD2016/JoinedParquetSampledFile.tar.gz gunzip JoinedParquetSampledFile.tar.gz tar -xvf JoinedParquetSampledFile.tar mv JoinedParquetSampledFile NYCjoinedParquetSubset rm JoinedParquetSampledFile.tar wget http://cdspsparksamples.blob.core.windows.net/data/NYCTaxi/FareData2013DecParquet.tar wget http://cdspsparksamples.blob.core.windows.net/data/NYCTaxi/TripData2013DecParquet.tar tar -xvf FareData2013DecParquet.tar tar -xvf TripData2013DecParquet.tar rm FareData2013DecParquet.tar rm TripData2013DecParquet.tar # Airline data wget http://cdspsparksamples.blob.core.windows.net/data/Airline/WeatherSubsetCsv.tar.gz wget http://cdspsparksamples.blob.core.windows.net/data/Airline/AirlineSubsetCsv.tar.gz gunzip WeatherSubsetCsv.tar.gz gunzip AirlineSubsetCsv.tar.gz tar -xvf WeatherSubsetCsv.tar tar -xvf AirlineSubsetCsv.tar rm WeatherSubsetCsv.tar AirlineSubsetCsv.tar cd /home/remoteuser cd Data wget http://strata2017r.blob.core.windows.net/airline/airline_20MM.csv ## Copy data to HDFS cd /home/remoteuser cd Data # Make hdfs directories and copy things over to HDFS /opt/hadoop/current/bin/hadoop fs -mkdir /user/RevoShare/rserve2 /opt/hadoop/current/bin/hadoop fs -mkdir /user/RevoShare/rserve2/Predictions /opt/hadoop/current/bin/hadoop fs -chmod -R 777 /user/RevoShare/rserve2 /opt/hadoop/current/bin/hadoop fs -mkdir /user/RevoShare/remoteuser /opt/hadoop/current/bin/hadoop fs -mkdir /user/RevoShare/remoteuser/Data /opt/hadoop/current/bin/hadoop fs -mkdir /user/RevoShare/remoteuser/Models /opt/hadoop/current/bin/hadoop fs -copyFromLocal * /user/RevoShare/remoteuser/Data ####################################################################################################################################### ####################################################################################################################################### # Install R packages cd /home/remoteuser wget https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/StrataSanJose2017/Scripts/InstallPackages.R cd /usr/bin Revo64-9.0 --vanilla --quiet < /home/remoteuser/InstallPackages.R ####################################################################################################################################### ####################################################################################################################################### ## Change ownership of some of directories cd /home/remoteuser chown -R remoteuser Code Data su hadoop -c "/opt/hadoop/current/bin/hadoop fs -chown -R remoteuser /user/RevoShare/rserve2" su hadoop -c "/opt/hadoop/current/bin/hadoop fs -chown -R remoteuser /user/RevoShare/remoteuser" ####################################################################################################################################### ####################################################################################################################################### ## END ####################################################################################################################################### #######################################################################################################################################