Bootstrap

1. Doris分布式环境搭建

一. 环境准备

本次测试集群采用3台机器hadoop1、hadoop2、hadoop3, Frontend和Backend部署在同一台机器上,Frontend部署3台组成高可用,Backend部署3个节点,组成3副本存储。

主机IP操作系统FrontendBackend
hadoop1192.168.47.128Centos7FollowerBE1
hadoop2192.168.47.129Centos7FollowerBE2
hadoop3192.168.47.130Centos7FollowerBE3

1.安装JDK8,具体的安装过程这里不赘述。
2.安装mysql客户端,具体的安装过程这里不赘述。
3.关闭交换分区
在三台主机分别执行如下命令

# hadoop1关闭swap分区
[root@hadoop1 ~]# swapoff -a
# hadoop2关闭swap分区
[root@hadoop2 ~]# swapoff -a
# hadoop3关闭swap分区
[root@hadoop3 ~]# swapoff -a

4.关闭防火墙

# hadoop1关闭防火墙
[root@hadoop1 ~]# systemctl  stop firewalld
# hadoop2关闭防火墙
[root@hadoop2 ~]# systemctl  stop firewalld
# hadoop3关闭防火墙
[root@hadoop3 ~]# systemctl  stop firewalld

5.设置系统最大打开文件句柄数
三台主机都执行如下命令

vi /etc/security/limits.conf 
* soft nofile 1000000
* hard nofile 1000000

6.修改虚拟内存区域数量为

# hadoop1修改内存区域
[root@hadoop1 ~]# sysctl -w vm.max_map_count=2000000
vm.max_map_count = 2000000
# hadoop2修改内存区域
[root@hadoop2 ~]# sysctl -w vm.max_map_count=2000000
vm.max_map_count = 2000000
# hadoop3修改内存区域
[root@hadoop3 ~]# sysctl -w vm.max_map_count=2000000
vm.max_map_count = 2000000

7.关闭透明大页
三台主机都执行如下命令

echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

二. 集群部署

1.下载Doris安装包,并解压

[root@hadoop1 opt]# wget https://apache-doris-releases.oss-accelerate.aliyuncs.com/apache-doris-2.0.3-bin-x64.tar.gz
[root@hadoop1 opt]# tar xf apache-doris-2.0.3-bin-x64.tar.gz
[root@hadoop1 opt]# mv apache-doris-2.0.3-bin-x64 doris-2.0.3

2.修改配置,同步安装包到另外两台主机

# 修改FE配置
[root@hadoop1 doris-2.0.3]# vim fe/conf/fe.conf
priority_networks = 192.168.47.0/24
# 修改BE配置
[root@hadoop1 doris-2.0.3]# vim be/conf/be.conf
priority_networks = 192.168.47.0/24

#将安装包同步到hadoop2和hadoop3
[root@hadoop1 opt]# scp -r doris-2.0.3/ root@hadoop2:/opt
[root@hadoop1 opt]# scp -r doris-2.0.3/ root@hadoop3:/opt

3.启动 FE Master 节点
前面集群规划时选择hadoop3作为Frontend Master节点,因此先在hadoop3启动Frontend。

[root@hadoop3 doris-2.0.3]# ./fe/bin/start_fe.sh --daemon

使用mysql客户端连接Frontend并修改root用户的密码

[root@hadoop3 doris-2.0.3]# mysql -uroot -P9030 -h hadoop3 -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.99 Doris version doris-2.0.3-rc06-37d31a5

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>  SET PASSWORD FOR 'root' = PASSWORD('root123'); 

4.启动BE进程并注册
三台主机分别启动Backend

# hadoop1启动be
[root@hadoop1 doris-2.0.3]# ./be/bin/start_be.sh --daemon
# hadoop2启动be
[root@hadoop2 doris-2.0.3]# ./be/bin/start_be.sh --daemon
# hadoop3启动be
[root@hadoop3 doris-2.0.3]# ./be/bin/start_be.sh --daemon

三个Backend分别向hadoop3 Frontend注册

[root@hadoop3 doris-2.0.3]# mysql -uroot -P9030 -h 192.168.47.130 -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.99 Doris version doris-2.0.3-rc06-37d31a5

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

# 三个BE分别注册
mysql> ALTER SYSTEM ADD BACKEND "192.168.47.128:9050";
Query OK, 0 rows affected (0.02 sec)

mysql> ALTER SYSTEM ADD BACKEND "192.168.47.129:9050";
Query OK, 0 rows affected (0.02 sec)

mysql> ALTER SYSTEM ADD BACKEND "192.168.47.130:9050";
Query OK, 0 rows affected (0.01 sec)

# 查看已经注册的BE
mysql> SHOW BACKENDS;
+-----------+----------------+---------------+--------+----------+----------+---------------------+---------------------+-------+----------------------+-----------+------------------+--------------------+---------------+---------------+---------+----------------+--------------------+--------------------------+--------+--------------------------+-------------------------------------------------------------------------------------------------------------------------------+-------------------------+----------+
| BackendId | Host           | HeartbeatPort | BePort | HttpPort | BrpcPort | LastStartTime       | LastHeartbeat       | Alive | SystemDecommissioned | TabletNum | DataUsedCapacity | TrashUsedCapcacity | AvailCapacity | TotalCapacity | UsedPct | MaxDiskUsedPct | RemoteUsedCapacity | Tag                      | ErrMsg | Version                  | Status                                                                                                                        | HeartbeatFailureCounter | NodeRole |
+-----------+----------------+---------------+--------+----------+----------+---------------------+---------------------+-------+----------------------+-----------+------------------+--------------------+---------------+---------------+---------+----------------+--------------------+--------------------------+--------+--------------------------+-------------------------------------------------------------------------------------------------------------------------------+-------------------------+----------+
| 11128     | 192.168.47.128 | 9050          | 9060   | 8040     | 8060     | 2025-01-10 00:37:03 | 2025-01-10 00:45:32 | true  | false                | 24        | 29.771 KB        | 0.000              | 24.742 GB     | 38.278 GB     | 35.36 % | 35.36 %        | 0.000              | {"location" : "default"} |        | doris-2.0.3-rc06-37d31a5 | {"lastSuccessReportTabletsTime":"2025-01-10 00:44:38","lastStreamLoadTime":-1,"isQueryDisabled":false,"isLoadDisabled":false} | 0                       | mix      |
| 11129     | 192.168.47.129 | 9050          | 9060   | 8040     | 8060     | 2025-01-10 00:37:12 | 2025-01-10 00:45:32 | true  | false                | 24        | 29.771 KB        | 0.000              | 23.307 GB     | 38.278 GB     | 39.11 % | 39.11 %        | 0.000              | {"location" : "default"} |        | doris-2.0.3-rc06-37d31a5 | {"lastSuccessReportTabletsTime":"2025-01-10 00:44:40","lastStreamLoadTime":-1,"isQueryDisabled":false,"isLoadDisabled":false} | 0                       | mix      |
| 11130     | 192.168.47.130 | 9050          | 9060   | 8040     | 8060     | 2025-01-10 00:37:35 | 2025-01-10 00:45:32 | true  | false                | 24        | 29.771 KB        | 0.000              | 23.814 GB     | 38.278 GB     | 37.79 % | 37.79 %        | 0.000              | {"location" : "default"} |        | doris-2.0.3-rc06-37d31a5 | {"lastSuccessReportTabletsTime":"2025-01-10 00:45:05","lastStreamLoadTime":-1,"isQueryDisabled":false,"isLoadDisabled":false} | 0                       | mix      |
+-----------+----------------+---------------+--------+----------+----------+---------------------+---------------------+-------+----------------------+-----------+------------------+--------------------+---------------+---------------+---------+----------------+--------------------+--------------------------+--------+--------------------------+-------------------------------------------------------------------------------------------------------------------------------+-------------------------+----------+
3 rows in set (0.02 sec)

5.FE Follower注册与启动
对Hadoop1和hadoop2的Follower进行注册

[root@hadoop3 doris-2.0.3]# mysql -uroot -P9030 -h 192.168.47.130 -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.99 Doris version doris-2.0.3-rc06-37d31a5

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

# 两个Follower分别注册
mysql> ALTER SYSTEM ADD FOLLOWER "192.168.47.128:9010";
Query OK, 0 rows affected (0.02 sec)

mysql> ALTER SYSTEM ADD FOLLOWER "192.168.47.129:9010";
Query OK, 0 rows affected (0.02 sec)

启动hadoop1和haoop2上的Frontend进程,第一次启动时需要从hadoop3同步元数据。

# 同步元数据
[root@hadoop1 fe]# ./bin/start_fe.sh --helper 192.168.47.130:9010 --daemon
[root@hadoop2 fe]# ./bin/start_fe.sh --helper 192.168.47.130:9010 --daemon

# 非第一次启动
[root@hadoop1 fe]# ./bin/start_fe.sh  --daemon
[root@hadoop2 fe]# ./bin/start_fe.sh  --daemon

此时可以登录到集群的web管理页面上查看集群Backend和Frontend的状态,入口地址为http://192.168.47.130:8030/login

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

6.验证集群功能
集群搭建完成后,下面进行集群功能验证。

[root@hadoop3 doris-2.0.3]# mysql -uroot -P9030 -h hadoop3 -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.99 Doris version doris-2.0.3-rc06-37d31a5

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

# 创建数据库
mysql> create database testdb;
Query OK, 0 rows affected (0.01 sec)

# 创建测试表
mysql> USE testdb;
Query OK, 0 rows affected (0.01 sec)
mysql> CREATE TABLE t1
(
    id INT,
    name VARCHAR(100) 
) DISTRIBUTED BY HASH(id) BUCKETS 10;

# 插入数据
mysql> INSERT INTO t1 values(1, 'name1'), (2, 'name2'), (3, 'name3'), (4, 'name4');
Query OK, 4 rows affected (0.53 sec)
{'label':'insert_9a435c2107994208_b19dcc43b6a92119', 'status':'VISIBLE', 'txnId':'2004'}


# 查询数据
mysql> select * from t1;
+------+-------+
| id   | name  |
+------+-------+
|    2 | name2 |
|    4 | name4 |
|    3 | name3 |
|    1 | name1 |
+------+-------+
4 rows in set (0.60 sec)
;