第2章 工具環境搭建(具體實操)2.1 MongoDB(單節點)環境配置2.2 Redis(單節點)環境配置2.3 ElasticSearch(單節點)環境配置2.4 Azkaban(單節點)環境配置2.4.1 安裝 Git2.4.2 編譯 Azkaban2.4.3 部署 Azkaban Solo2.5 Spark(單節點)環境配置2.6 Zookeeper(單節點)環境配置2.7 Flume-ng(單節點)環境配置2.8 Kafka(單節點)環境配置2.9 Apache 環境配置2.10 Tomcat 環境配置2.11 開發環境配置2.11.1 安裝IDEA(略)2.11.2 Postman 安裝2.11.3 安裝 nodejs2.11.4 安裝AngularJS CLIphp
[atguigu@hadoop102 software]$ pwd
/opt/software
// 經過 wget 下載 Linux 版本的 MongoDB
[atguigu@hadoop102 software]$ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.4.3.tgz
// 將壓縮包解壓到指定目錄 /opt/module 下
[atguigu@hadoop102 software]$ tar -zxf mongodb-linux-x86_64-rhel62-3.4.3.tgz -C /opt/module/
// 將解壓後的文件重命名爲 mongodb
[atguigu@hadoop102 module]$ mv mongodb-linux-x86_64-rhel62-3.4.3/ mongodb
// 在安裝目錄下建立 data 文件夾用於存放數據和日誌
[atguigu@hadoop102 mongodb]$ mkdir /opt/module/mongodb/data
// 在 data 文件夾下建立 db 文件夾,用於存放數據
[atguigu@hadoop102 mongodb]$ mkdir /opt/module/mongodb/data/db
// 在 data 文件夾下建立 logs 文件夾,用於存放日誌
[atguigu@hadoop102 mongodb]$ mkdir /opt/module/mongodb/data/logs
// 在 logs 文件夾下建立 mongodb.log 文件
[atguigu@hadoop102 mongodb]$ touch /opt/module/mongodb/data/logs/mongodb.log
// 在 data 文件夾下建立 mongodb.conf配 置文件
[atguigu@hadoop102 mongodb]$ touch /opt/module/mongodb/data/logs/mongodb.conf
// 在 mongodb.conf 文件中輸入以下內容
[atguigu@hadoop102 data]$ pwd
/opt/module/mongodb/data
[atguigu@hadoop102 data]$ vim mongodb.conf
#端口號
port = 27017
#數據目錄
dbpath = /opt/module/mongodb/data/db
#日誌目錄
logpath = /opt/module/mongodb/data/logs/mongodb.log
#設置後臺運行
fork = true
#日誌輸出方式
logappend = true
#開啓認證(爲了開發方便,不用輸入用戶名和密碼)
#auth = true
完成 MongoDB 的安裝後,啓動 MongoDB 服務器:html
// 啓動 MongoDB 服務器
[atguigu@hadoop102 mongodb]$ sudo /opt/module/mongodb/bin/mongod -config /opt/module/mongodb/data/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 4854
child process started successfully, parent exiting
// 查看 MongoDB 的啓動狀況
[atguigu@hadoop102 mongodb]$ ps -ef | grep mongo
root 4854 1 1 10:47 ? 00:00:00 /opt/module/mongodb/bin/mongod -config /opt/module/mongodb/data/mongodb.conf
atguigu 4875 4336 0 10:48 pts/0 00:00:00 grep mongo
[atguigu@hadoop102 mongodb]$
// 訪問 MongoDB 服務器
[atguigu@hadoop102 mongodb]$ /opt/module/mongodb/bin/mongo
// 中止 MongoDB 服務器
[atguigu@hadoop102 mongodb]$ sudo /opt/module/mongodb/bin/mongod -shutdown -config /opt/module/mongodb/data/mongodb.conf
MongoDB 的安裝小結:前端
1、MongoDB 若是沒有可視化客戶端,可使用 bin/mongo 直接鏈接。
2、MongoDB 在關閉的時候,也須要經過 -config 來指定啓動時指定的文件。
3、MongoDB 不須要安裝在 /usr 目錄下,能夠是任何的目錄。
4、啓動:bin/mongod -config ./data/mongodb.conf
5、鏈接:bin/mongo
6、關閉:bin/mongodb -shutdown -config ./data/mongodb.conf
// 經過 wget 下載 Redis 的源碼
[atguigu@hadoop102 software]$ wget http://download.redis.io/releases/redis-4.0.2.tar.gz
// 將源代碼解壓到指定目錄 /opt/module 下
[atguigu@hadoop102 software]$ tar -zxf redis-4.0.2.tar.gz -C /opt/module
// 進入 Redis 源代碼目錄,編譯安裝(由於 redis 是用 C 語言寫的)
[atguigu@hadoop102 module]$ cd redis-4.0.2/
// 安裝 GCC
[atguigu@hadoop102 module]$ sudo yum install gcc
// 編譯源代碼
[atguigu@hadoop102 redis-4.0.2]$ make MALLOC=libc
// 編譯安裝
[atguigu@hadoop102 redis-4.0.2]$ sudo make install
// 建立配置文件,放入指定的目錄
[atguigu@hadoop102 redis-4.0.2]$ sudo cp /opt/module/redis-4.0.2/redis.conf /opt/module/redis-4.0.2/myredis
// 修改配置文件中如下內容
[atguigu@hadoop102 redis-4.0.2]$ sudo vim /opt/module/redis-4.0.2/myredis/redis.conf
bind 0.0.0.0 #69行 #綁定主機 IP,默認值爲127.0.0.1,咱們是跨機器運行,因此須要更改
daemonize yes #136行 #是否之後臺 daemon 方式運行,默認不是後臺運行
pidfile /var/run/redis/redis_6379.pid #158行 #redis 的 PID 文件路徑(可選)
logfile "/opt/module/redis-4.0.2/myredis/redis.log" #171行 #定義 log 文件位置,模式 log 信息定向到 stdout,輸出到 /dev/null(可選)
dir "/opt/module/redis-4.0.2/myredis" #263行 #本地數據庫存放路徑,默認爲./(可選)
// 編譯安裝默認存在在 /usr/local/bin 目錄下,以下
[atguigu@hadoop102 redis-4.0.2]$ cd /usr/local/bin/
[atguigu@hadoop102 bin]$ ll
總用量 9572
-rw-r--r-- 1 root root 83 5月 8 01:27 dump6379.rdb
-rw-r--r-- 1 root root 83 5月 8 01:27 dump6380.rdb
-rw-r--r-- 1 root root 83 5月 8 01:27 dump6381.rdb
lrwxrwxrwx 1 root root 6 4月 28 17:17 nc -> netcat
-rwxr-xr-x 1 root root 103479 4月 28 17:17 netcat
-rwxr-xr-x 1 root root 290454 5月 23 12:37 redis-benchmark
-rwxr-xr-x 1 root root 2971304 5月 23 12:37 redis-check-aof
-rwxr-xr-x 1 root root 45443 5月 6 17:27 redis-check-dump
-rwxr-xr-x 1 root root 2971304 5月 23 12:37 redis-check-rdb
-rwxr-xr-x 1 root root 419907 5月 23 12:37 redis-cli
lrwxrwxrwx 1 root root 12 5月 23 12:37 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 2971304 5月 23 12:37 redis-server
在安裝完 Redis 以後,啓動 Redisjava
// 啓動 Redis 服務器
[atguigu@hadoop102 redis-4.0.2]$ redis-server /opt/module/redis-4.0.2/myredis/redis.conf
// 鏈接 Redis 服務器
[atguigu@hadoop102 redis-4.0.2]$ redis-cli -h 192.168.25.102 -p 6379
// 查看 Redis 的啓動狀況
[atguigu@hadoop102 redis-4.0.2]$ ps -ef | grep redis
atguigu 6033 1 0 13:08 ? 00:00:00 redis-server 0.0.0.0:6379
atguigu 6046 4336 0 13:12 pts/0 00:00:00 grep redis
// 中止 Redis 服務器
[atguigu@hadoop102 redis-4.0.2]$ redis-cli shutdown
Redis 的安裝小結:node
一、對於源碼包,安裝三部曲:
1) ./configure 檢查依賴環境
2) make 編譯
3) make install 編譯安裝
2、啓動:redis-server ./redis.conf
3、鏈接:redis-cli
4、關閉:redis-cli shutdown
// 經過 wget 下載 ElasticSearch 安裝包
[atguigu@hadoop102 software]$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.tar.gz
配置 ElasticSearch:linux
// 解壓 ElasticSearch 到安裝目錄
[atguigu@hadoop102 software]$ tar -zxf elasticsearch-5.2.2.tar.gz -C /opt/module/
在 /opt/module/elasticsearch-5.2.2 路徑下建立 data 和 logs 文件夾
// 建立 ElasticSearch 數據文件夾 data
[atguigu@hadoop102 elasticsearch-5.2.2]$ mkdir data
// 建立 ElasticSearch 日誌文件夾 logs
[atguigu@hadoop102 elasticsearch-5.2.2]$ mkdir logs
// 修改 ElasticSearch 配置文件
[atguigu@hadoop102 config]$ pwd
/opt/module/elasticsearch-5.2.2/config
[atguigu@hadoop102 config]$ vim elasticsearch.yml
# ---------------------------------- Cluster -----------------------------------
cluster.name: my-application #設置集羣的名稱
# ------------------------------------ Node ------------------------------------
node.name: node-102 #修改當前節點的名稱
# ----------------------------------- Paths ------------------------------------
path.data: /opt/module/elasticsearch-5.2.2/data #修改數據路徑
path.logs: /opt/module/elasticsearch-5.2.2/logs #修改日誌路徑
# ----------------------------------- Memory -----------------------------------
bootstrap.memory_lock: false #設置ES節點容許內存交換
bootstrap.system_call_filter: false #禁用系統調用過濾器
# ---------------------------------- Network -----------------------------------
network.host: 192.168.25.102 #設置當前主機名稱
# --------------------------------- Discovery ----------------------------------
discovery.zen.ping.unicast.hosts: ["hadoop102"] #設置集羣的主機列表
修改 Linux 配置參數:c++
// 使用 root 用戶,修改文件數配置,在文件末尾添加以下配置
[root@hadoop102 elasticsearch-5.2.2]# vim /etc/security/limits.conf
添加以下內容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
// 使用 root 用戶,修改* soft nproc 1024 爲 * soft nproc 2048
[root@hadoop102 elasticsearch-5.2.2]# vim /etc/security/limits.d/90-nproc.conf
修改以下內容:
* soft nproc 1024
#修改成
* soft nproc 2048
// 使用 root 用戶,在文件末尾添加:
[root@hadoop102 elasticsearch-5.2.2]# vim /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
// 執行命令如下命令,使配置生效
[root@hadoop102 elasticsearch-5.2.2]# sysctl -p
在完成 ElasticSearch 的配置以及 Linux 的配置後,啓動 ElasticSearchgit
// 啓動 ElasticSearch 服務
[atguigu@hadoop102 elasticsearch-5.2.2]$ ./bin/elasticsearch -d # -d 表示後臺啓動
// 訪問 ElasticSearch 服務
[atguigu@hadoop102 elasticsearch-5.2.2]$ curl http://hadoop102:9200/
{
"name" : "node-102",
"cluster_name" : "my-application",
"cluster_uuid" : "yb29ijbJQ2mBzCHTOjyUGw",
"version" : {
"number" : "5.2.2",
"build_hash" : "f9d9b74",
"build_date" : "2017-02-24T17:26:45.835Z",
"build_snapshot" : false,
"lucene_version" : "6.4.1"
},
"tagline" : "You Know, for Search"
}
// 中止 ElasticSearch 服務
[atguigu@hadoop102 elasticsearch-5.2.2]$ jps
8514 Elasticsearch
8908 Jps
[atguigu@hadoop102 elasticsearch-5.2.2]$ kill -9 8514
Elasticsearch head 插件安裝(圖形化界面)
方式一:參考連接:https://www.cnblogs.com/chenmingjun/p/10817378.html#_label1_3
方式二:安裝 Chrome 瀏覽器插件:Elasticsearch headangularjs
Elasticsearch 的安裝小結:github
一、配置 Linux 的參數,配置完成以後,執行 sudo sysctl -p,使配置生效
二、配置 yml 的時候,value 以前要有個空格
三、啓動:bin/elasticsearch -d
四、訪問:安裝 elasticsearch-head 插件,或者安裝 Chrome 插件
五、關閉:kill -9 xxx
// 安裝 git
[atguigu@hadoop102 software]$ sudo yum install git
// 經過 git 下載 Azkaban 源代碼
[atguigu@hadoop102 software]$ git clone https://github.com/azkaban/azkaban.git
// 進入 azkaban 目錄
[atguigu@hadoop102 software]$ cd azkaban/
// 切換到 3.36.0 版本
[atguigu@hadoop102 azkaban]$ git checkout -b 3.36.0
詳細請參照:https://github.com/azkaban/azkaban
// 安裝編譯環境
[atguigu@hadoop102 azkaban]$ sudo yum install gcc
[atguigu@hadoop102 azkaban]$ sudo yum install -y gcc-c++*
// 執行編譯命令
[atguigu@hadoop102 azkaban]$ ./gradlew clean build
// 最終咱們在 azkaban/azkaban-solo-server/build/distributions 目錄下咱們獲得 azkaban-solo-server-3.36.0.tar.gz
// 將編譯好的 azkaban 中的 azkaban-solo-server-3.36.0.tar.gz 拷貝到指定目錄
[atguigu@hadoop102 azkaban]$ cp ./azkaban-solo-server/build/distributions/azkaban-solo-server-3.36.0.tar.gz /opt/software
// 解壓 azkaban-solo-server-3.36.0.tar.gz 到指定目錄
[atguigu@hadoop102 software]$ tar -zxf azkaban-solo-server-3.36.0.tar.gz -C /opt/module/
// 進入到 /opt/module/ 目錄,重命名 azkaban-solo-server-3.36.0 爲 azkaban
[atguigu@hadoop102 module]$ mv azkaban-solo-server-3.36.0/ azkaban
// 啓動 Azkaban Solo 單節點服務
[atguigu@hadoop102 azkaban]$ bin/azkaban-solo-start.sh
// 訪問 Azkaban 服務,經過瀏覽器打開 http://ip:8081,經過用戶名:azkaban,密碼:azkaban 登陸。
// 關閉 Azkaban 服務
[atguigu@hadoop102 azkaban]$ bin/azkaban-solo-shutdown.sh
Azkaban Solo 的安裝小結:
一、須要將 azkaban 源代碼進行編譯,編譯以前須要注意版本的選擇 git checkout -b version
二、獲取到 azkaban-solo-server.tar.gz
三、啓動:bin/azkaban-solo-start.sh
4、訪問:經過 http://IP:8081 默認的用戶名和密碼是:azkaban
5、中止:bin/azkaban-solo-shutdown.sh
注意:本次安裝在一臺 Linux 機器上,安裝的模式是單節點 Standalone 模式,因此 Master 和 Worker 在同一臺機器上。
// 經過 wget 下載 spark 安裝包
[atguigu@hadoop102 software]$ wget https://d3kbcqa49mib13.cloudfront.net/spark-2.1.1-bin-hadoop2.7.tgz
// 將 spark 解壓到安裝目錄(注意:解壓 .tgz 文件須要 root 權限)
[atguigu@hadoop102 software]$ sudo tar –zxf spark-2.1.1-bin-hadoop2.7.tgz –C /opt/module/
// 進入 spark 安裝目錄
[atguigu@hadoop102 module]$ cd spark-2.1.1-bin-hadoop2.7/
// 複製 slave 配置文件
[atguigu@hadoop102 spark-2.1.1-bin-hadoop2.7]$ cp ./conf/slaves.template ./conf/slaves
// 修改 slave 配置文件
[atguigu@hadoop102 spark-2.1.1-bin-hadoop2.7]$ vim ./conf/slaves
hadoop102 #在文件最後將本機主機名進行添加(注意:是單節點安裝)
// 複製 spark-env 配置文件
[atguigu@hadoop102 spark-2.1.1-bin-hadoop2.7]$ cp ./conf/spark-env.sh.template ./conf/spark-env.sh
SPARK_MASTER_HOST=hadoop102 #添加 spark master 的主機名
SPARK_MASTER_PORT=7077 #添加 spark master 的端口號
安裝完成以後,啓動 Spark
// 啓動 Spark 集羣
[atguigu@hadoop102 spark-2.1.1-bin-hadoop2.7] sbin/start-all.sh
// 訪問 Spark 集羣,瀏覽器訪問 http://hadoop102:8080
// 關閉 Spark 集羣
[atguigu@hadoop102 spark-2.1.1-bin-hadoop2.7] sbin/stop-all.sh
Spark 的安裝小結:
一、須要配置 slaves 文件
二、須要配置 spark-env.sh 文件
三、啓動:sbin/start-all.sh
4、訪問:http://IP:8080
5、中止:sbin/stop-all.sh
// 經過 wget 下載 Zookeeper 安裝包
[atguigu@hadoop102 software]$ wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
// 將 Zookeeper 解壓到安裝目錄
[atguigu@hadoop102 software]$ tar –zxf zookeeper-3.4.10.tar.gz –C /opt/module/
// 進入 Zookeeper 安裝目錄
[atguigu@hadoop102 module]$ cd zookeeper-3.4.10/
// 建立 data 數據目錄
[atguigu@hadoop102 zookeeper-3.4.10]$ mkdir data/
// 複製 Zookeeper 配置文件
[atguigu@hadoop102 zookeeper-3.4.10]$ cp ./conf/zoo_sample.cfg ./conf/zoo.cfg
// 修改 Zookeeper 配置文件
[atguigu@hadoop102 zookeeper-3.4.10]$ vim conf/zoo.cfg
dataDir=/opt/module/zookeeper-3.4.10/data #將數據目錄地址修改成建立的目錄
// 啓動 Zookeeper 服務
[atguigu@hadoop102 zookeeper-3.4.10]$ bin/zkServer.sh start
// 查看 Zookeeper 服務狀態
[atguigu@hadoop102 zookeeper-3.4.10]$ bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: standalone
// 關閉 Zookeeper 服務
[atguigu@hadoop102 zookeeper-3.4.10]$ bin/zkServer.sh stop
Zookeeper 的安裝小結:
一、修改 zoo.cfg 中的數據路徑
二、啓動:bin/zkServer.sh start
3、檢查:bin/zkServer.sh status
4、中止:bin/zkServer.sh stop
// 經過 wget 下載 Flume 安裝包
[atguigu@hadoop102 software]$ wget http://www.apache.org/dyn/closer.lua/flume/1.8.0/apache-flume-1.8.0-bin.tar.gz
// 將 Flume 解壓到安裝目錄
[atguigu@hadoop102 software]$ tar –zxf apache-flume-1.8.0-bin.tar.gz –C /opt/module/
// 將 flume/conf 下的 flume-env.sh.template 文件修改成 flume-env.sh,並配置 flume-env.sh 文件,以下:
[atguigu@hadoop102 conf]$ mv flume-env.sh.template flume-env.sh
[atguigu@hadoop102 conf]$ vim flume-env.sh
export JAVA_HOME=/opt/module/jdk1.8.0_144
// 經過 wget 下載 Kafka 安裝包
[atguigu@hadoop102 software]$ wget http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/0.10.2.1/kafka_2.11-0.10.2.1.tgz
// 將 Kafka 解壓到安裝目錄
[atguigu@hadoop102 software]$ tar –zxf kafka_2.12-0.10.2.1.tgz –C /opt/module/
// 修改解壓後的文件名稱
[atguigu@hadoop102 module]$ mv kafka_2.11-0.11.0.2/ kafka
// 修改 Kafka 配置文件
[atguigu@hadoop102 kafka]$ vim config/server.properties
host.name=hadoop102 #修改主機名
port=9092 #修改服務端口號
zookeeper.connect=hadoop102:2181,hadoop103:2181,hadoop104:2181 #修改 Zookeeper 服務器地址
// 啓動 Kafka 服務 !!! 啓動以前須要啓動 Zookeeper 服務 !!!
[atguigu@hadoop102 kafka]$ bin/kafka-server-start.sh -daemon ./config/server.properties &
// 關閉 Kafka 服務
[atguigu@hadoop102 kafka]$ bin/kafka-server-stop.sh
// 建立 topic
[atguigu@hadoop102 kafka]$ bin/kafka-topics.sh --create --zookeeper hadoop102:2181 --replication-factor 1 --partitions 1 --topic recommender
// kafka-console-producer
[atguigu@hadoop102 kafka]$ bin/kafka-console-producer.sh --broker-list hadoop102:9092 --topic recommender
// kafka-console-consumer
[atguigu@hadoop102 kafka]$ bin/kafka-console-consumer.sh --bootstrap-server hadoop102:9092 --topic recommender
--------------------------------------------------------------------------------------------------
老版本:消費者會將本身的 offset 文件保存在 zookeeper(低版本的kafka)。因此消費者鏈接的是 zookeeper。
[atguigu@hadoop102 kafka]$ bin/kafka-console-consumer.sh --zookeeper hadoop102:2181 --topic recommender
新版本:消費者會將本身的 offset 文件保存在 kafka 集羣中(高版本的kafka)。因此消費者鏈接的是 kafka。這樣作的好處是:提升了效率,減小了網絡傳輸。
[atguigu@hadoop102 kafka]$ bin/kafka-console-consumer.sh --bootstrap-server hadoop102:9092 --topic recommender
// 安裝 httpd
[bigdata@linux ~]$ sudo yum install httpd
// 啓動 httpd
[bigdata@linux ~]$ sudo service httpd start 或者 /etc/init.d/httpd start
// 關閉 httpd
[bigdata@linux ~]$ sudo service httpd stop 或者 /etc/init.d/httpd stop
// 訪問 Apache 服務器,經過瀏覽器訪問:http://ip:80
// 默認的安裝目錄是:/var/www ,咱們的頁面放在目錄 /var/www/html 中
[atguigu@hadoop102 www]$ ll
總用量 16
drwxr-xr-x. 2 root root 4096 6月 19 2018 cgi-bin
drwxr-xr-x. 3 root root 4096 3月 4 10:12 error
drwxr-xr-x. 2 root root 4096 6月 19 2018 html
drwxr-xr-x. 3 root root 4096 3月 4 10:12 icons
// 經過 wget 下載 tomcat 服務器安裝包
[atguigu@hadoop102 software]$ wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.23/bin/apache-tomcat-8.5.23.tar.gz
// 將 tomcat 安裝包解壓到安裝目錄下
[atguigu@hadoop102 software]$ tar -xf apache-tomcat-8.5.23.tar.gz -C /opt/module/
// 啓動 tomcat 服務
[atguigu@hadoop102 apache-tomcat-8.5.23]$ bin/startup.sh
// 關閉 tomcat 服務
[atguigu@hadoop102 apache-tomcat-8.5.23]$ bin/shutdown.sh
// 訪問 tomcat 服務,瀏覽器打開:http://ip:8080
Tomcat 的安裝小結:
1、直接解壓便可
2、啓動:bin/startup.sh
3、訪問:瀏覽器訪問:http://IP:8080
4、中止:bin/shutdown.sh
5、日誌:tail -f logs/catalina.out
參考連接:http://www.javashuo.com/article/p-oxgmwdlq-cw.html
主要用於 REST API 的測試。下載 windows 安裝版本,雙擊默認安裝。
主要用於前端的開發支持。
在 https://nodejs.org/en/download/ 中下載對應版本的 NodeJS,並安裝:
一、點擊 Next
在命令行執行:npm install -g @angular/cli