目录
1. linux环境准备
1.1 选择ext4文件系统
在安装linux系统的时候,推荐选择ext4文件系统
1.2 安装linux依赖
[root@doris1 ~]# yum install -y gcc.x86_64
1.3 设置系统最大打开文件句柄数
临时设置方式:
[root@doris1 ~]# ulimit -n 65536
- 可以通过
ulimit -a
进行查看
永久设置方式:添加如下到/etc/security/limits.conf,然后重启服务器
* soft nofile 65536
* hard nofile 65536
1.4 关闭swap分区
临时关闭方式:
[root@doris1 ~]# swapoff -a
[root@doris1 ~]#
[root@doris1 ~]# free -m
total used free shared buff/cache available
Mem: 972 158 261 7 552 661
Swap: 0 0 0
[root@doris1 ~]#
[root@doris1 ~]# echo "vm.swappiness = 0" >> /etc/sysctl.conf
[root@doris1 ~]#
[root@doris1 ~]# sysctl -p
vm.swappiness = 0
[root@doris1 ~]#
永久关闭方式:注释/etc/fstab中下面这行,然后重启服务器
/dev/mapper/centos_centos-swap swap swap defaults 0 0
1.5 linux服务器时间同步
服务器之间的时间偏差要求在5秒内,时间同步可以参考Centos7服务器通过Chrony设置时间同步 + timedatectl命令的使用
2. PE的高可用搭配
- 一个follower和一个observer可以实现读高可用
- 3个follower可以实现读写高可用,follower数量必须为奇数
- observer只负责同步follower的元数据,不参加Leader选举
3. 安装
Doris的FE和BE新增扩容,不影响已经运行的FE和BE,所以我们先部署一个FE和一个BE
3.1 下载解压
通过命令cat /proc/cpuinfo | grep avx2
查看flags中是否有avx2。有则支持avx2指令,没有则不支持。然后下载对应的二进制包版本
[root@doris1 ~]# wget https://dist.apache.org/repos/dist/release/doris/1.1/1.1.1-rc03/apache-doris-1.1.1-bin-x86.tar.gz
[root@doris1 ~]#
[root@doris1 ~]# tar -zxvf apache-doris-1.1.1-bin-x86.tar.gz
[root@doris1 ~]#
[root@doris1 ~]# cd apache-doris-1.1.1-bin-x86
[root@doris1 apache-doris-1.1.1-bin-x86]#
[root@doris1 apache-doris-1.1.1-bin-x86]# ls
apache_hdfs_broker fe licenses udf
be LICENSE-dist.txt NOTICE.txt
[root@doris1 apache-doris-1.1.1-bin-x86]#
3.2 安装Java
安装Java8,参考centos7同时安装java8和openJdk11、windows同时安装java8和openJdk11
3.3 安装第一个FE
如果条件好的,FE和BE应该部署在不同的服务器上,即使在同一服务器,也应该位于不同的磁盘上
1. 修改fe/conf/fe.conf:
修改内容如下:
JAVA_OPTS="-Xmx8192m ......省略内容......"
# 如果meta_dir目录不存在,则需手动创建
meta_dir = /root/apache-doris-1.1.1-bin-x86/fe/doris-meta
priority_networks = 192.168.23.61/24
http_port = 7030
新增内容如下:
JAVA_HOME=/root/jdk1.8.0_201
2. 配置环境变量
添加如下到/etc/profile,然后进行source使其生效
export DORIS_HOME=/root/apache-doris-1.1.1-bin-x86
export PATH=$DORIS_HOME/fe/bin:$PATH
3. 启动FE
[root@doris1 apache-doris-1.1.1-bin-x86]# start_fe.sh --daemon
4. 检验FE是否启动成功
[root@doris1 apache-doris-1.1.1-bin-x86]# curl http://doris1:7030/api/bootstrap
{"msg":"success","code":0,"data":{"replayedJournalId":0,"queryPort":0,"rpcPort":0,"version":""},"count":0}[root@doris1 apache-doris-1.1.1-bin-x86]#
[root@doris1 apache-doris-1.1.1-bin-x86]#
5. 访问Doris FE的Web界面
访问http://doris1:7030,输入用户名:root,密码为空(如果修改了doris的root用户密码,则为修改后的密码)。如下所示
3.4 安装第一个BE
1. 新增doris-data.HDD目录
[root@doris1 be]# mkdir doris-data.HDD
2. 修改be/conf/be.conf
修改内容如下:
priority_networks = 192.168.23.61/24
storage_root_path = /root/apache-doris-1.1.1-bin-x86/be/doris-data.HDD,200
webserver_port = 7020
brpc_port = 8061
参数说明:
- HDD表示目录所在的磁盘是HDD类型,可以通过命令
lsblk -d -o name,rota
进行查看,rota返回的是1,表示可以旋转,是机械硬盘HDD - 200表示目录的最大储存容量。需要预留额外40%的空间用作后台compaction以及一些中间数据的存放
3. 配置环境变量
添加如下到/etc/profile,然后进行source使其生效
export DORIS_HOME=/root/apache-doris-1.1.1-bin-x86
export PATH=$DORIS_HOME/be/bin:$PATH
4. FE添加BE
mysql的客户端安装,请参考centos7安装mysql8.0.25版本
[root@doris1 ~]# mysql -h doris1 -P 9030 -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 0
Server version: 5.7.37 Doris version 1.1.1-rc03-2dbd70bf9
Copyright (c) 2000, 2021, 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> ALTER SYSTEM ADD BACKEND "192.168.23.61:9050";
Query OK, 0 rows affected (0.12 sec)
mysql>
- 连接PE的端口为PE的query_port参数值
- 添加BACKEND的端口为BE的heartbeat_service_port参数值
5. 启动BE
[root@doris1 apache-doris-1.1.1-bin-x86]# start_be.sh --daemon
6. 检验BE是否启动成功
方式一:curl
[root@doris1 apache-doris-1.1.1-bin-x86]# curl http://192.168.23.61:7020/api/health
{"status": "OK","msg": "To Be Added"}[root@doris1 apache-doris-1.1.1-bin-x86]#
[root@doris1 apache-doris-1.1.1-bin-x86]#
方式二:mysql,Alive列为true表示BE启动成功
mysql> SHOW PROC '/backends';
+-----------+-----------------+---------------+----------+---------------+--------+----------+----------+---------------------+---------------------+-------+----------------------+-----------------------+-----------+------------------+---------------+---------------+---------+----------------+--------------------------+--------+----------------------+-------------------------------------------------------------------------------------------------------------------------------+
| BackendId | Cluster | IP | HostName | HeartbeatPort | BePort | HttpPort | BrpcPort | LastStartTime | LastHeartbeat | Alive | SystemDecommissioned | ClusterDecommissioned | TabletNum | DataUsedCapacity | AvailCapacity | TotalCapacity | UsedPct | MaxDiskUsedPct | Tag | ErrMsg | Version | Status |
+-----------+-----------------+---------------+----------+---------------+--------+----------+----------+---------------------+---------------------+-------+----------------------+-----------------------+-----------+------------------+---------------+---------------+---------+----------------+--------------------------+--------+----------------------+-------------------------------------------------------------------------------------------------------------------------------+
| 10002 | default_cluster | 192.168.23.61 | doris1 | 9050 | 9060 | 7020 | 8061 | 2022-07-31 16:37:47 | 2022-07-31 16:39:50 | true | false | false | 0 | 0.000 | 43.049 GB | 49.976 GB | 13.86 % | 13.86 % | {"location" : "default"} | | 1.1.1-rc03-2dbd70bf9 | {"lastSuccessReportTabletsTime":"2022-07-31 16:38:59","lastStreamLoadTime":-1,"isQueryDisabled":false,"isLoadDisabled":false} |
+-----------+-----------------+---------------+----------+---------------+--------+----------+----------+---------------------+---------------------+-------+----------------------+-----------------------+-----------+------------------+---------------+---------------+---------+----------------+--------------------------+--------+----------------------+-------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.05 sec)
mysql>
方式三:FE Web界面
** 7. 访问BE的Web界面**
http://doris1:7020
3.5 新增一个PE(follower/observer)
1. 修改fe/conf/fe.conf:
修改内容如下:
JAVA_OPTS="-Xmx8192m ......省略内容......"
# 如果meta_dir目录不存在,则需手动创建
meta_dir = /root/apache-doris-1.1.1-bin-x86/fe/doris-meta
priority_networks = 192.168.23.62/24
http_port = 7030
新增内容如下:
JAVA_HOME=/root/jdk1.8.0_201
2. 配置环境变量
添加如下到/etc/profile,然后进行source使其生效
export DORIS_HOME=/root/apache-doris-1.1.1-bin-x86
export PATH=$DORIS_HOME/fe/bin:$PATH
3. 向Leader PE添加Follower
[root@doris1 ~]# mysql -h doris1 -P 9030 -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 0
Server version: 5.7.37 Doris version 1.1.1-rc03-2dbd70bf9
Copyright (c) 2000, 2021, 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> ALTER SYSTEM ADD FOLLOWER "192.168.23.62:9010";
Query OK, 0 rows affected (0.10 sec)
mysql>
- 端口是fe/conf/fe.conf中的edit_log_port参数值
- 如果添加observer, 则将上面的FOLLOWER修改为OBSERVER即可
4. 启动FE
[root@doris2 apache-doris-1.1.1-bin-x86]# start_fe.sh --helper doris1:9010 --daemon
- –helper参数只在初始化的时候需要
- 端口是fe/conf/fe.conf中的edit_log_port参数值
5. 检验FE是否启动成功
方式一:curl
[root@doris2 apache-doris-1.1.1-bin-x86]# curl http://doris2:7030/api/bootstrap
{"msg":"success","code":0,"data":{"replayedJournalId":0,"queryPort":0,"rpcPort":0,"version":""},"count":0}[root@doris2 apache-doris-1.1.1-bin-x86]#
[root@doris2 apache-doris-1.1.1-bin-x86]#
方式二:mysql,Alive列为true表示FE启动成功
mysql> SHOW PROC '/frontends';
+----------------------------------+---------------+----------+-------------+----------+-----------+---------+----------+----------+------------+------+-------+-------------------+---------------------+----------+--------+----------------------+------------------+
| Name | IP | HostName | EditLogPort | HttpPort | QueryPort | RpcPort | Role | IsMaster | ClusterId | Join | Alive | ReplayedJournalId | LastHeartbeat | IsHelper | ErrMsg | Version | CurrentConnected |
+----------------------------------+---------------+----------+-------------+----------+-----------+---------+----------+----------+------------+------+-------+-------------------+---------------------+----------+--------+----------------------+------------------+
| 192.168.23.61_9010_1659253554808 | 192.168.23.61 | doris1 | 9010 | 7030 | 9030 | 9020 | FOLLOWER | true | 1494516980 | true | true | 1522 | 2022-07-31 17:16:39 | true | | 1.1.1-rc03-2dbd70bf9 | Yes |
| 192.168.23.62_9010_1659258566532 | 192.168.23.62 | doris2 | 9010 | 7030 | 9030 | 9020 | FOLLOWER | false | 1494516980 | true | true | 1521 | 2022-07-31 17:16:39 | true | | 1.1.1-rc03-2dbd70bf9 | No |
+----------------------------------+---------------+----------+-------------+----------+-----------+---------+----------+----------+------------+------+-------+-------------------+---------------------+----------+--------+----------------------+------------------+
2 rows in set (0.27 sec)
mysql>
6. 访问Doris FE的Web界面
访问http://doris2:7030,输入用户名:root,密码为空(如果修改了doris的root用户密码,则为修改后的密码)。如下所示
3.6 新增一个BE
-
前面的步骤可以参考【安装第一个BE】,但注意be/conf/be.conf中的priority_networks参数,如在doris2上安装该参数就是
priority_networks = 192.168.23.62/24
-
数据会在几个小时到一天时间内,自动均衡到新增的BE上
3.7 DECOMMISSION方式安全删除一个BE
语法如下:
mysql> ALTER SYSTEM DECOMMISSION BACKEND "192.168.23.62:9050";
说明如下:
- 命令发送后,Doris会尝试将该BE上的数据向其它BE节点迁移,当所有数据都迁移完成后,Doris会自动删除该节点
- 该命令是一个异步操作。执行后,可以通过
SHOW PROC '/backends';
看到该BE节点的SystemDecommissioned字段为true。表示该节点正在进行下线。DECOMMISSION的进度,可以通过该BE节点的TabletNum字段查看 - 该命令不一定执行成功。比如剩余BE存储空间不足以容纳下线BE上的数据,或
者剩余机器数量不满足最小副本数时,该命令都无法完成。此时BE会一直处于SystemDecommissioned为true的状态 - 该操作可以通过如下命令取消:
CANCEL DECOMMISSION BACKEND "192.168.23.62:9050";
。取消后,该BE上的数据将维持当前剩余的数据量。后续 再次执行DECOMMISSION将重新进行负载均衡