這個大數據時代、我們要么成為別人的數據、要么別人成為我們的數據。
大豬來教大家快速搭建一個大數據的環境,我們可以使用Docker來實現,文章會演示如何使用。
這里我會使用HDP的最新版本3.0.1作為演示,包含的組件版本如下
先下載docker鏡像(打個預防針:大小占 26G 慢慢下吧哈,但收獲很大)
docker pull hortonworks/sandbox-hdp:3.0.1 docker pull hortonworks/sandbox-proxy:1.0
下載啟動配置腳本
git clone https://github.com/dounine/sandbox-hdp-3.0.1.git
添加hosts映射
127.0.0.1 sandbox-hdp.hortonworks.com # 或者是使用公網IP或局域網IP
啟動配置
./docker-deploy-hdp265.sh
成功結果
root@lake /s/d/sandbox-hdp-3.0.1# ./docker-deploy-hdp265.sh + registry=hortonworks + name=sandbox-hdp + version=3.0.1 + proxyName=sandbox-proxy + proxyVersion=1.0 + flavor=hdp + echo hdp + mkdir -p sandbox/proxy/conf.d + mkdir -p sandbox/proxy/conf.stream.d + docker pull hortonworks/sandbox-hdp:3.0.1 3.0.1: Pulling from hortonworks/sandbox-hdp Digest: sha256:7b767af7b42030fb1dd0f672b801199241e6bef1258e3ce57361edb779d95921 Status: Image is up to date for hortonworks/sandbox-hdp:3.0.1 + docker pull hortonworks/sandbox-proxy:1.0 1.0: Pulling from hortonworks/sandbox-proxy Digest: sha256:42e4cfbcbb76af07e5d8f47a183a0d4105e65a1e7ef39fe37ab746e8b2523e9e Status: Image is up to date for hortonworks/sandbox-proxy:1.0 + '[' hdp == hdf ']' + '[' hdp == hdp ']' + hostname=sandbox-hdp.hortonworks.com ++ docker images ++ grep hortonworks/sandbox-hdp ++ awk '{print $2}' + version=3.0.1 + docker network create cda + docker run --privileged --name sandbox-hdp -h sandbox-hdp.hortonworks.com --network=cda --network-alias=sandbox-hdp.hortonworks.com -d hortonworks/sandbox-hdp:3.0.1 46bf6b414dd3c0fb36a3816eac129219d30d49ea9421898158800e0ab3576048 + echo ' Remove existing postgres run files. Please wait' Remove existing postgres run files. Please wait + sleep 2 + docker exec -t sandbox-hdp sh -c 'rm -rf /var/run/postgresql/*; systemctl restart postgresql;' Failed to restart postgresql.service: Unit not found. + sed s/sandbox-hdp-security/sandbox-hdp/g assets/generate-proxy-deploy-script.sh + mv -f assets/generate-proxy-deploy-script.sh.new assets/generate-proxy-deploy-script.sh + chmod +x assets/generate-proxy-deploy-script.sh + assets/generate-proxy-deploy-script.sh + uname + grep MINGW + chmod +x sandbox/proxy/proxy-deploy.sh + sandbox/proxy/proxy-deploy.sh 7fa5c4d0737a6b71796fe997baf397d4078907d83fcfaa2a8c0f241772547147
需要先重置一下ambari的密碼才能登錄
docker exec -ti sandbox-hdp bash ambari-admin-password-reset #重置密碼登錄
結果
[root@sandbox-hdp /]# ambari-admin-password-reset Please set the password for admin: Please retype the password for admin: The admin password has been set. Restarting ambari-server to make the password change effective... Using python /usr/bin/python Restarting ambari-server Waiting for server stop... Ambari Server stopped Ambari Server running with administrator privileges. Organizing resource files at /var/lib/ambari-server/resources... Ambari database consistency check started... Server PID at: /var/run/ambari-server/ambari-server.pid Server out at: /var/log/ambari-server/ambari-server.out Server log at: /var/log/ambari-server/ambari-server.log Waiting for server start................... Server started listening on 8080 DB configs consistency check: no errors and warnings were found.
輸入帳號密碼登錄 ambar webUI http://localhost:8080
是不是很簡單、后續還有更多大數據深入的文章送給你們。
每天發布更多新鮮有含量的技術文章、總有一款適合你。
快關注我、把我打包帶走、每天提醒你學習一手技術。
1、安裝必要的編譯環境好
由于Tengine安裝需要使用源代碼自行編譯,所以在安裝前需要安裝必要的編譯工具:
# yum update # yum install gcc gcc-c++ autoconf automake 1 2
2、安裝需要的組件
A、PCRE
PCRE(Perl Compatible Regular Expressions)是一個Perl庫,包括 perl 兼容的正則表達式庫。nginx rewrite依賴于PCRE庫,所以在安裝Tengine前一定要先安裝PCRE,最新版本的PCRE可在官網(http://www.pcre.org/)獲取。具體安裝流程為:
cd /usr/local/src wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz tar zxvf pcre-8.36.tar.gz cd pcre-8.36 ./configure --prefix=/usr/local/pcre make && make install 1 2 3 4 5 6
附加信息:
源碼的安裝一般由3個步驟組成:配置(configure)、編譯(make)、安裝(make install)。
Configure是一個可執行腳本,它有很多選項,在待安裝的源碼路徑下使用命令./configure –help輸出詳細的選項列表。其中–prefix選項是配置安裝的路徑,如果不配置該選項,安裝后可執行文件默認放在/usr /local/bin,庫文件默認放在/usr/local/lib,配置文件默認放在/usr/local/etc,其它的資源文件放在/usr /local/share,比較凌亂。
如果配置–prefix,如:./configure –prefix=/usr/local/test,可以把所有資源文件放在/usr/local/test的路徑中,不會雜亂。
用了—prefix選項的另一個好處是卸載軟件或移植軟件。當某個安裝的軟件不再需要時,只須簡單的刪除該安裝目錄,就可以把軟件卸載得干干凈凈;移植軟件只需拷貝整個目錄到另外一個機器即可(相同的操作系統)。當然要卸載程序,也可以在原來的make目錄下用一次make uninstall,但前提是make文件指定過uninstall。
B、OpenSSL
OpenSSL 是一個強大的安全套接字層密碼庫,囊括主要的密碼算法、常用的密鑰和證書封裝管理功能及SSL協議,并提供豐富的應用程序供測試或其它目的使用。,安裝OpenSSL(http://www.openssl.org/source/)主要是為了讓tengine支持Https的訪問請求。具體是否安裝看需求。
復制代碼 代碼如下:
cd /usr/local/src wget http://www.openssl.org/source/openssl-1.0.2.tar.gz tar zxvf openssl-1.0.2.tar.gz cd openssl-1.0.2.tar.gz ./configure --prefix=/usr/local/openssl make && make install 1 2 3 4 5 6
C、Zlib
Zlib是提供資料壓縮之用的函式庫,當Tengine想啟用GZIP壓縮的時候就需要使用到Zlib(http://www.zlib.net/)。
cd /usr/local/src wget http://zlib.net/zlib-1.2.8.tar.gz tar zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8.tar.gz ./configure --prefix=/usr/local/zlib make && make install 1 2 3 4 5 6
D、jemalloc
jemalloc(http://www.canonware.com/jemalloc/)是一個更好的內存管理工具,使用jemalloc可以更好的優化Tengine的內存管理。
cd /usr/local/src wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2 tar jxvf jemalloc-3.6.0.tar.bz2 cd jemalloc-3.6.0.tar.bz2 ./configure --prefix=/usr/local/jemalloc make && make install 1 2 3 4 5 6
3、安裝Tengine
在主要核心的組件安裝完畢以后就可以安裝Tegine了,最新版本的Tegine可從官網(http://tengine.taobao.org/)獲取。
在編譯安裝前還需要做的一件事是添加一個專門的用戶來執行Tengine。當然你也可以用root(不建議)。
復制代碼 代碼如下:
groupadd www-data useradd -s /sbin/nologin -g www-data www-data 1 2
接下來才是進行安裝:
cd /usr/local/src wget http://tengine.taobao.org/download/tengine-2.1.0.tar.gz tar -zxvf tengine-2.1.0.tar.gz cd tengine-2.1.0 ./configure --prefix=/usr/local/nginx \ --user=www-data \ --group=www-data \ --with-pcre=/usr/local/src/pcre-8.36 \ --with-openssl=/usr/local/src/openssl-1.0.2 \ --with-jemalloc=/usr/local/src/jemalloc-3.6.0 \ --with-http_gzip_static_module \ --with-http_realip_module \ --with-http_stub_status_module \ --with-http_concat_module \ --with-zlib=/usr/local/src/zlib-1.2.8 make && make install 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
注意配置的時候 –with-pcre 、–with-openssl、–with-jemalloc、–with-zlib的路徑為源文件的路徑。
4、配置Tengine,設置tengine自動啟動
vim /etc/rc.d/init.d/nginx
編輯啟動文件添加下面內容
#!/bin/bash # nginx Startup script for the Nginx HTTP Server # it is v.0.0.2 version. # chkconfig: - 85 15 # description: Nginx is a high-performance web and proxy server. # It has a lot of features, but it's not for everyone. # processname: nginx # pidfile: /var/run/nginx.pid # config: /usr/local/nginx/conf/nginx.conf nginxd=/usr/local/nginx/sbin/nginx nginx_config=/usr/local/nginx/conf/nginx.conf nginx_pid=/usr/local/nginx/logs/nginx.pid RETVAL=0 prog="nginx" # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 [ -x $nginxd ] || exit 0 # Start nginx daemons functions. start() { if [ -e $nginx_pid ];then echo "nginx already running...." exit 1 fi echo -n $"Starting $prog: " daemon $nginxd -c ${nginx_config} RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx return $RETVAL } # Stop nginx daemons functions. stop() { echo -n $"Stopping $prog: " killproc $nginxd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid } reload() { echo -n $"Reloading $prog: " #kill -HUP `cat ${nginx_pid}` killproc $nginxd -HUP RETVAL=$? echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) stop start ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|reload|status|help}" exit 1 esac exit $RETVAL 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
保存退出
復制代碼 代碼如下:
chmod 775 /etc/rc.d/init.d/nginx #賦予文件執行權限
chkconfig nginx on #設置開機啟動
service nginx restart #啟動服務