Skip to content
/ bdp Public

A prototype project of big data platform, the source codes of the book Big Data Platform Architecture and Prototype

Notifications You must be signed in to change notification settings

bluishglc/bdp

Repository files navigation

Đại số liệu ngôi cao công trình nguyên hình ( Big Data Platform Project Prototype )

2008 năm Hadoop trở thành Apache đỉnh cấp hạng mục, coi đây là bắt đầu, đại số liệu kỹ thuật nghênh đón mười mấy năm liên tục phát triển, ở giữa theo Spark lực lượng mới xuất hiện, toàn bộ đại số liệu sinh thái vòng lại đã trải qua một lần “Trang bị thăng cấp”, trở nên càng thêm hoàn thiện cùng cường đại. Hôm nay, rất nhiều xí nghiệp đã hoàn thành lúc đầu đối đại số liệu kỹ thuật nếm thử cùng thăm dò ngược lại tiến vào đến ứng dụng giai đoạn, nhưng không thể không nói chính là, đại số liệu ngôi cao giá cấu hệ thống phi thường khổng lồ, kỹ thuật kho tạm đặc biệt thâm, làm đại số liệu khai phá đồng học đối này hẳn là đều tràn đầy thể hội.

Mà ở rất nhiều tế phân lĩnh vực ( tỷ như thật khi tính toán, tác nghiệp điều hành ) cũng không có giống dạng công trình khuôn mẫu, này vừa hiện trạng cùng Java xã khu sử dụng Spring Boot hạ bút thành văn mà dựng Web công trình nguyên hình hình thành tiên minh đối lập. Này dẫn tới rất nhiều đoàn đội ở khởi động đại số liệu ngôi cao xây dựng khi thường thường cảm thấy không chỗ nào người hầu, cũng khiến cho hy vọng thâm nhập học tập đại số liệu kỹ thuật khai phá giả bởi vì khuyết thiếu công trình cấp thí dụ mẫu tham khảo mà cảm thấy mê mang.

Nên nguyên hình hạng mục chính là coi đây là mệnh đề sáng tạo, nó căn cứ vào quá vãng hạng mục tốt nhất thực tiễn tinh luyện mà đến, có thể trợ giúp đoàn đội nhanh chóng khởi động khai phá, thượng thủ liền viết nghiệp vụ số hiệu.

Bổn hạng mục đồng thời là 《Đại số liệu ngôi cao giá cấu cùng nguyên hình thực hiện: Số liệu trung đài xây dựng thực chiến》 một cuốn sách nguyên bộ thí dụ mẫu số hiệu. Nên thư đã từ nổi danh IT sách báo nhãn hiệu điện tử công nghiệp nhà xuất bản bác văn coi điểm xuất bản phát hành, ở kinh đông cùng đương đương có bán. Về như thế nào bố trí cùng vận hành nên hạng mục, thư trung làm phi thường tinh tế giảng giải.

Kinh đông mua thư liên tiếp:https://item.jd /12677623.html

Đương đương mua thư liên tiếp:http://product.dangdang /28974965.html

Điểm đánh《 trọng bàng đề cử: Kiến đại số liệu ngôi cao quá khó khăn! Cho ta phát cái công trình nguyên hình đi! 》Hiểu biết sách báo tình hình cụ thể và tỉ mỉ, quét mã tiến vào kinh đông di động mua trang sách mặt!

大数据平台架构与原型实现:数据中台建设实战


Bố trí nguyên hình hạng mục sử dụng đến kịch bản gốc

Đại số liệu ngôi cao giá cấu cùng nguyên hình thực hiện: Số liệu trung đài xây dựng thực chiến》 một cuốn sách đệ 《4.5 bố trí nguyên hình hạng mục 》 tiết kỹ càng tỉ mỉ giới thiệu nên hạng mục bố trí cùng khởi động phương pháp, vì miễn với viết tay số hiệu, dễ bề đại gia thao tác, chúng ta đem sử dụng tương quan kịch bản gốc cùng phối trí dán ra tới:

  • 4.5.1.1 ở viễn trình server thượng thành lập ứng dụng trình tự đặc biệt tài khoản
#Run as 'root'
#add group if not exists
group=bdp

egrep"^$group\:"/etc/group>&/dev/null
if["$?"!="0"]
then
groupadd"$group"
echo"Group:$groupis added."
fi

users=(bdp-metric bdp-collect bdp-dwh bdp-master-server bdp-stream bdp-workflow)
password='Bdpp1234!'
foruserin${users[@]}
do
#add user if not exists and set password
egrep"^$user\:"/etc/passwd>&/dev/null
if["$?"!="0"]
then
useradd -g"$group""$user"
echo"User:$useris added."
echo"$user:$password"|chpasswd
echo"User:$user,password is reset."
fi
done

#enable all users of bdp group can sudo as hdfs.
echo'%bdp ALL = (hdfs) NOPASSWD: ALL'>/etc/sudoers.d/bdp
  • 4.5.1.2 ở HDFS thượng vì trình tự đặc biệt tài khoản sáng tạo Home mục lục
#create home on hdfs for users need hdfs storage
su -l hdfs
users=(bdp-dwh bdp-stream bdp-workflow)
foruserin${users[@]}
do
home=/user/$user
hdfs dfs -test -d$home&&hdfs dfs -rm -r -f$home
hdfs dfs -mkdir -p$home
hdfs dfs -chown -R$user:bdp$home
done
exit
  • 4.5.1.3 ở HDFS thượng sáng tạo số liệu kho hàng sở cần folder
#create data zones
su -l hdfs
dirs=(/data/src /data/dwh /data/dmt /data/app /data/tmp /data/stg)

fordirin${dirs[@]}
do
hdfs dfs -test -d$dir&&hdfs dfs -rm -r -f$dir
hdfs dfs -mkdir -p$dir
hdfs dfs -chown -R bdp-dwh:bdp$dir
done

hdfs dfs -chmod a+w /data/tmp

exit
  • 4.5.1.4 sáng tạo số liệu kho hàng
dropdatabaseif exists src cascade;
createdatabaseifnot exists src
location'/data/src';

dropdatabaseif exists dwh cascade;
createdatabaseifnot exists dwh
location'/data/dwh';

dropdatabaseif exists dmt cascade;
createdatabaseifnot exists dmt
location'/data/dmt';

dropdatabaseif exists app cascade;
createdatabaseifnot exists app
location'/data/app';

dropdatabaseif exists tmp cascade;
createdatabaseifnot exists tmp
location'/data/tmp';

dropdatabaseif exists stg cascade;
createdatabaseifnot exists stg
location'/data/stg';
  • 4.5.1.5 sáng tạo bdp-stream nhật ký mục lục
mkdir /var/log/bdp-stream
chown bdp-stream:bdp /var/log/bdp-stream
chmod a+w /var/log/bdp-stream
  • 4.5.1.9 sáng tạobdp_metricCùngbdp_masterCơ sở dữ liệu
--1. bdp_metric
DROPDATABASEIF EXISTS bdp_metric;
CREATEDATABASEIFNOT EXISTS bdp_metric DEFAULT CHARACTERSETutf8 DEFAULT COLLATE utf8_general_ci;

DROPUSERIF EXISTS'bdp_metric'@'%';
CREATEUSERIFNOT EXISTS'bdp_metric'@'%'IDENTIFIED BY'Bdpp1234!';
GRANTALL PRIVILEGESONbdp_metric.*TO'bdp_metric'@'%'WITHGRANTOPTION;
FLUSH PRIVILEGES;

--2. bdp_master

DROPDATABASEIF EXISTS bdp_master;
CREATEDATABASEIFNOT EXISTS bdp_master DEFAULT CHARACTERSETutf8 DEFAULT COLLATE utf8_general_ci;

DROPUSERIF EXISTS'bdp_master'@'%';
CREATEUSERIFNOT EXISTS'bdp_master'@'%'IDENTIFIED BY'Bdpp1234!';
GRANTALL PRIVILEGESONbdp_master.*TO'bdp_master'@'%'WITHGRANTOPTION;
FLUSH PRIVILEGES;
  • 4.5.1.10 sáng tạo kafka topic
kafka-topics \
--zookeeper master1.cluster:2181,master1.cluster:2181,utility1.cluster:2181 \
--create \
--topic cpu.usage \
--partitions 12 \
--replication-factor 3

kafka-topics \
--zookeeper master1.cluster:2181,master1.cluster:2181,utility1.cluster:2181 \
--describe \
--topic cpu.usage

kafka-topics \
--zookeeper master1.cluster:2181,master1.cluster:2181,utility1.cluster:2181 \
--create \
--topic mem.used \
--partitions 12 \
--replication-factor 3

kafka-topics \
--zookeeper master1.cluster:2181,master1.cluster:2181,utility1.cluster:2181 \
--describe \
--topic mem.used

kafka-topics \
--zookeeper master1.cluster:2181,master1.cluster:2181,utility1.cluster:2181 \
--create \
--topic alert \
--partitions 12 \
--replication-factor 3

kafka-topics \
--zookeeper master1.cluster:2181,master1.cluster:2181,utility1.cluster:2181 \
--describe \
--topic alert
  • 4.5.1.11 sáng tạo HBase số liệu biểu
disable 'metric'
drop 'metric'
create 'metric', {NAME=>'f', VERSIONS=>1, COMPRESSION => 'SNAPPY', BLOCKCACHE => 'true'}

disable 'alert'
drop 'alert'
create 'alert', {NAME=>'f', VERSIONS=>1, COMPRESSION => 'SNAPPY', BLOCKCACHE => 'true'}

disable 'server_state'
drop 'server_state'
create 'server_state', {NAME=>'f', VERSIONS=>1, COMPRESSION => 'SNAPPY', BLOCKCACHE => 'true'}

Trang bị tụ quần trong quá trình sử dụng đến kịch bản gốc

Đại số liệu ngôi cao giá cấu cùng nguyên hình thực hiện: Số liệu trung đài xây dựng thực chiến》 một cuốn sách chương 3 giới thiệu một cái 7 tiết điểm CDH tụ quần trang bị quá trình, vì miễn với viết tay số hiệu, dễ bề đại gia thao tác, chúng ta đem sử dụng tương quan kịch bản gốc cùng phối trí dán ra tới:

  • 3.3.4.1 sinh thành yum repo văn kiện
tee /etc/yum.repos.d/galera.repo<<EOF
[galera]
name = Galera
baseurl = https://releases.galeracluster /galera-3/centos/7/x86_64
gpgkey = https://releases.galeracluster /GPG-KEY-galeracluster
gpgcheck = 1

[mysql-wsrep]
name = MySQL-wsrep
baseurl = http://releases.galeracluster /mysql-wsrep-5.7/centos/7/x86_64
gpgkey = http://releases.galeracluster /mysql-wsrep-5.7/GPG-KEY-galeracluster
gpgcheck = 1
EOF
  • 3.3.4.4 phối trí Galera tụ quần
[root@master1~]#tee /etc/my.cnf <<EOF
!includedir /etc/my.cnf.d/
[mysqld]
max_connections=1000
max_connect_errors=10000
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
binlog_format=ROW
bind-address=0.0.0.0
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=0
innodb_buffer_pool_size=122M
character-set-server=utf8
collation-server=utf8_general_ci
character_set_server=utf8
collation_server=utf8_general_ci
wsrep_provider=/usr/lib64/galera-3/libgalera_smm.so
wsrep_provider_options="gcache.size=300M; gcache.page_size=300M"
wsrep_cluster_name="mysql_cluster"
wsrep_cluster_address="gcomm://master1.cluster,master2.cluster,utility1.cluster"
wsrep_node_name="master1.cluster"
wsrep_node_address="10.0.0.86"
wsrep_sst_method=rsync

[mysql_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
EOF
  • 3.3.5.1 download CDH Repository
nohup wget --recursive --no-parent --no-host-directories https://archive.cloudera /cm5/redhat/7/x86_64/cm/5.15.2/ -P /opt/nginx/cloudera-repos&

nohup wget --recursive --no-parent --no-host-directories https://archive.cloudera /cm5/redhat/7/x86_64/cm/RPM-GPG-KEY-cloudera -P /opt/nginx/cloudera-repos&

nohup wget --recursive --no-parent --no-host-directories https://archive.cloudera /cdh5/parcels/5.15.2/ -P /opt/nginx/cloudera-repos&
  • 3.3.5.2 trang bị cũng phối trí Nginx
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /opt/nginx;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
autoindex on;
}
}
  • 3.3.5.3 sinh thành Repository miêu tả văn kiện
tee /etc/yum.repos.d/cloudera-manager.repo<<EOF
[cloudera-manager]
name=Cloudera Manager 5.15.2
baseurl=http://utility1.cluster/cloudera-repos/cm5/redhat/7/x86_64/cm/5.15.2/
gpgkey=http://utility1.cluster/cloudera-repos/cm5/redhat/7/x86_64/cm/RPM-GPG-KEY-cloudera
gpgcheck=1
EOF
  • 3.3.6.3 sáng tạo CDH các phục vụ sử dụng cơ sở dữ liệu
--1. scm
DROPDATABASEIF EXISTS scm;
CREATEDATABASEIFNOT EXISTS scm DEFAULT CHARACTERSETutf8 DEFAULT COLLATE utf8_general_ci;

DROPUSERIF EXISTS'scm'@'%';
CREATEUSERIFNOT EXISTS'scm'@'%'IDENTIFIED BY'Bdpp1234!';
GRANTALL PRIVILEGESONscm.*TO'scm'@'%'WITHGRANTOPTION;
FLUSH PRIVILEGES;

--2. amon

DROPDATABASEIF EXISTS amon;
CREATEDATABASEIFNOT EXISTS amon DEFAULT CHARACTERSETutf8 DEFAULT COLLATE utf8_general_ci;

DROPUSERIF EXISTS'amon'@'%';
CREATEUSERIFNOT EXISTS'amon'@'%'IDENTIFIED BY'Bdpp1234!';
GRANTALL PRIVILEGESONamon.*TO'amon'@'%'WITHGRANTOPTION;
FLUSH PRIVILEGES;

--3. rman

DROPDATABASEIF EXISTS rman;
CREATEDATABASEIFNOT EXISTS rman DEFAULT CHARACTERSETutf8 DEFAULT COLLATE utf8_general_ci;

DROPUSERIF EXISTS'rman'@'%';
CREATEUSERIFNOT EXISTS'rman'@'%'IDENTIFIED BY'Bdpp1234!';
GRANTALL PRIVILEGESONrman.*TO'rman'@'%'WITHGRANTOPTION;
FLUSH PRIVILEGES;

--4. hue

DROPDATABASEIF EXISTS hue;
CREATEDATABASEIFNOT EXISTS hue DEFAULT CHARACTERSETutf8 DEFAULT COLLATE utf8_general_ci;

DROPUSERIF EXISTS'hue'@'%';
CREATEUSERIFNOT EXISTS'hue'@'%'IDENTIFIED BY'Bdpp1234!';
GRANTALL PRIVILEGESONhue.*TO'hue'@'%'WITHGRANTOPTION;
FLUSH PRIVILEGES;

--5. hive

DROPDATABASEIF EXISTS hive;
CREATEDATABASEIFNOT EXISTS hive DEFAULT CHARACTERSETutf8 DEFAULT COLLATE utf8_general_ci;

DROPUSERIF EXISTS'hive'@'%';
CREATEUSERIFNOT EXISTS'hive'@'%'IDENTIFIED BY'Bdpp1234!';
GRANTALL PRIVILEGESONhive.*TO'hive'@'%'WITHGRANTOPTION;
FLUSH PRIVILEGES;

--6. sentry

DROPDATABASEIF EXISTS sentry;
CREATEDATABASEIFNOT EXISTS sentry DEFAULT CHARACTERSETutf8 DEFAULT COLLATE utf8_general_ci;

DROPUSERIF EXISTS'sentry'@'%';
CREATEUSERIFNOT EXISTS'sentry'@'%'IDENTIFIED BY'Bdpp1234!';
GRANTALL PRIVILEGESONsentry.*TO'sentry'@'%'WITHGRANTOPTION;
FLUSH PRIVILEGES;

--7. nav

DROPDATABASEIF EXISTS nav;
CREATEDATABASEIFNOT EXISTS nav DEFAULT CHARACTERSETutf8 DEFAULT COLLATE utf8_general_ci;

DROPUSERIF EXISTS'nav'@'%';
CREATEUSERIFNOT EXISTS'nav'@'%'IDENTIFIED BY'Bdpp1234!';
GRANTALL PRIVILEGESONnav.*TO'nav'@'%'WITHGRANTOPTION;
FLUSH PRIVILEGES;

--8. navms

DROPDATABASEIF EXISTS navms;
CREATEDATABASEIFNOT EXISTS navms DEFAULT CHARACTERSETutf8 DEFAULT COLLATE utf8_general_ci;

DROPUSERIF EXISTS'navms'@'%';
CREATEUSERIFNOT EXISTS'navms'@'%'IDENTIFIED BY'Bdpp1234!';
GRANTALL PRIVILEGESONnavms.*TO'navms'@'%'WITHGRANTOPTION;
FLUSH PRIVILEGES;

--9. oozie

DROPDATABASEIF EXISTS oozie;
CREATEDATABASEIFNOT EXISTS oozie DEFAULT CHARACTERSETutf8 DEFAULT COLLATE utf8_general_ci;

DROPUSERIF EXISTS'oozie'@'%';
CREATEUSERIFNOT EXISTS'oozie'@'%'IDENTIFIED BY'Bdpp1234!';
GRANTALL PRIVILEGESONoozie.*TO'oozie'@'%'WITHGRANTOPTION;
FLUSH PRIVILEGES;
  • 3.3.6.4. Trang bị MySQL JDBC Driver
wget https://dev.mysql /get/Downloads/Connector-J/mysql-connector-java-5.1.48.tar.gz
tar zxvf mysql-connector-java-5.1.48.tar.gz
mkdir -p /usr/share/java/
cp mysql-connector-java-5.1.48/mysql-connector-java-5.1.48-bin.jar /usr/share/java/mysql-connector-java.jar
  • 3.3.10 bắt đầu dùng Spark SQL
cp hive-cli-1.2.1.spark2.jar /opt/cloudera/parcels/SPARK2/lib/spark2/jars/
cp spark-hive-thriftserver_2.11-2.3.0.jar /opt/cloudera/parcels/SPARK2/lib/spark2/jars/
cp stop-thriftserver.sh /opt/cloudera/parcels/SPARK2/lib/spark2/sbin/
cp start-thriftserver.sh /opt/cloudera/parcels/SPARK2/lib/spark2/sbin/
cp spark-sql /opt/cloudera/parcels/SPARK2/lib/spark2/bin/
alternatives --install /usr/bin/spark-shell spark-shell /opt/cloudera/parcels/SPARK2/bin/spark2-shell 1
alternatives --install /usr/bin/spark-sql spark-sql /opt/cloudera/parcels/SPARK2/bin/spark2-sql 1
alternatives --install /usr/bin/spark-submit spark-submit /opt/cloudera/parcels/SPARK2/bin/spark2-submit 1
alternatives --install /etc/spark/conf spark-conf /etc/spark2/conf.cloudera.spark2_on_yarn 1
alternatives --remove spark-shell /opt/cloudera/parcels/CDH-5.15.2-1.cdh5.15.2.p0.3/bin/spark-shell
alternatives --remove spark-submit /opt/cloudera/parcels/CDH-5.15.2-1.cdh5.15.2.p0.3/bin/spark-submit