mysql、flume、zookeeper、kafka快速搭建
準備做實時資料計算。
資料來源為mysql的20張表吧。通過flume解析binlog日誌,然後sink到kafka,由sparkstreaming消費,實時處理業務資料生成目標資料寫到我們的mysql中。
一.mysql搭建
0. 檢查是否已安裝並刪除已安裝的包
yum list installed mysql* yum remove mysql-community-client.x86_64 mysql-community-common.x86_64 mysql-community-devel.x86_64 mysql-community-libs.x86_64 mysql-community-libs-compat.x86_64 mysql-community-server.x86_64 mysql80-community-release.noarch 移除mysql資料夾 [
[email protected] ~]# whereis mysql mysql: /usr/local/mysql [[email protected] ~]# rm -rf /usr/local/mysql 1.更新mysql源 rpm -Uvh https://repo.mysql.com/mysql80-community-release-el6.rpm 2.安裝mysql yum install -y mysql-community-server mysql-community 速度不一,請等待。。。。。。 3.新增mysql執行執行等級 chkconfig --level 2345 mysqld on 拓展: 2、3、4、5 對應不同的執行等級: 0 - halt (系統直接關機) 1 - single user mode (單人維護模式,用在系統出問題時的維護) 2 - Multi-user, without NFS (類似底下的 runlevel 3,但無 NFS 服務) 3 - Full multi-user mode (完整含有網路功能的純文字模式) 4 - unused (系統保留功能) 5 - X11 (與 runlevel 3 類似,但載入使用 X Window) 6 - reboot (重新啟動) 如果2、3、4、5 不為on, 則表示 nginx服務在執行級別為2、3、4、5時候沒有啟動 (即開機的時候不會啟動ngnix服務) 例如 chkconfig --level 2345 nginx on 表示設定nginx 服務在執行級別為2、3、4、5時啟動 (即設定開機啟動nginx服務) 4.啟動服務 service mysqld start 5. 檢視初始化密碼 cat /var/log/mysqld.log | grep password
6.我是懶得要密碼了,畢竟測試
mysql> USE mysql ;
mysql> UPDATE user SET Password = password ( '' ) WHERE User = 'root' ;
mysql> flush privileges ;
mysql> quit
二、flume安裝
wget http://mirrors.tuna.tsinghua.edu.cn/apache/flume/1.8.0/apache-flume-1.8.0-bin.tar.gz
tar –zxvf apache-flume-1.8.0-bin.tar.gz
mv apache-flume-1.8.0-bin /usr/local/flume
cp flume-env.sh.template flume-env.sh
三、zookeeper安裝
1.1 下載
cd /usr/local/kafka
wget https://archive.apache.org/dist/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz
tar -zxvf zookeeper-3.3.6.tar.gz
vim /etc/profile
1.2 安裝
使用tar解壓要安裝的目錄即可,以3.4.5版本為例
這裡以解壓到/usr/myapp,實際安裝根據自己的想安裝的目錄修改(注意如果修改,那後邊的命令和配置檔案中的路徑都要相應修改)
tar -zxf zookeeper-3.4.5.tar.gz -C /usr/myapp
1.3 配置
在主目錄下建立data和logs兩個目錄用於儲存資料和日誌:
cd /usr/myapp/zookeeper-3.4.5
mkdir data
mkdir logs
在conf目錄下新建zoo.cfg檔案,寫入以下內容儲存:
tickTime=2000
dataDir=/usr/myapp/zookeeper-3.4.5/data
dataLogDir=/usr/myapp/zookeeper-3.4.5/logs
clientPort=2181
1.4 啟動和停止
進入bin目錄,啟動、停止、重啟分和檢視當前節點狀態(包括叢集中是何角色)別執行:
./zkServer.sh start
./zkServer.sh stop
./zkServer.sh restart
./zkServer.sh status
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/usr/software/zookeeper/data
dataLogDir=/usr/software/zookeeper/logs
# the port at which the clients will connect
clientPort=2181
四、安裝kafka
https://blog.csdn.net/qq_33792843/article/details/75727921
kafka的配置說明
http://www.cnblogs.com/yinchengzhe/p/5111635.html
kafka.common.KafkaException: Socket server failed to bind to centos1:9092: Unresolved address.
解決方案:https://www.cnblogs.com/yy3b2007com/p/8684974.html
kafka.admin.AdministrationException: replication factor: 1 larger than available brokers: 0
解決方案:https://blog.csdn.net/g1219371445/article/details/78828915
就是啟動kafka然後建立
java.net.UnknownHostException: 主機名: 主機名: 未知的名稱或服務
解決方案:https://blog.csdn.net/huanbia/article/details/69055523
測試也應該參照文件的,
0.修改/etc/hosts檔案,將127.0.0.1 增加主機名稱
1.bin/kafka-server-start.sh config/server.properties
2../kafka-create-topic.sh -partition 1 -replica 1 -zookeeper localhost:2181 -topic test
3.另一個埠來./kafka-console-consumer.sh -zookeeper localhost:2181 -topic test