服务自动拉起

本文档主要介绍如何配置Doris集群的自动拉起,保证生产环境中出现特殊情况导致服务宕机后未及时拉起服务从而影响到业务的正常运行。

Doris集群必须完全搭建完成后再配置FE和BE的自动拉起服务。

Systemd配置Doris服务

systemd具体使用以及参数解析可以参考这里

sudo 权限控制

在使用 systemd 控制 doris 服务时,需要有 sudo 权限。为了保证最小粒度的 sudo 权限分配,可以将 doris-fe 与 doris-be 服务的 systemd 控制权限分配给指定的非 root 用户。在 visudo 来配置 doris-fe 与 doris-be 的 systemctl 管理权限。

1. Cmnd_Alias DORISCTL=/usr/bin/systemctl start doris-fe,/usr/bin/systemctl stop doris-fe,/usr/bin/systemctl start doris-be,/usr/bin/systemctl stop doris-be

3. ## Allow root to run any commands anywhere
4. root    ALL=(ALL)       ALL
5. doris   ALL=(ALL)       NOPASSWD:DORISCTL

配置步骤

  1. 分别在fe.conf和be.conf中添加 JAVA_HOME变量配置,否则使用systemctl start 将无法启动服务

1. echo "JAVA_HOME=your_java_home" >> /home/doris/fe/conf/fe.conf 2. echo "JAVA_HOME=your_java_home" >> /home/doris/be/conf/be.conf 2. 下载doris-fe.service文件: doris-fe.service 3. doris-fe.service具体内容如下:

``` 1. # Licensed to the Apache Software Foundation (ASF) under one 2. # or more contributor license agreements. See the NOTICE file 3. # distributed with this work for additional information 4. # regarding copyright ownership. The ASF licenses this file 5. # to you under the Apache License, Version 2.0 (the 6. # "License"); you may not use this file except in compliance 7. # with the License. You may obtain a copy of the License at 8. # 9. # http://www.apache.org/licenses/LICENSE-2.0 10. # 11. # Unless required by applicable law or agreed to in writing, 12. # software distributed under the License is distributed on an 13. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14. # KIND, either express or implied. See the License for the 15. # specific language governing permissions and limitations 16. # under the License.

  1. [Unit]
  2. Description=Doris FE
  3. After=network-online.target
  4. Wants=network-online.target

  5. [Service]

  6. Type=forking
  7. User=root
  8. Group=root
  9. LimitCORE=infinity
  10. LimitNOFILE=200000
  11. Restart=on-failure
  12. RestartSec=30
  13. StartLimitInterval=120
  14. StartLimitBurst=3
  15. KillMode=none
  16. ExecStart=/home/doris/fe/bin/start_fe.sh --daemon
  17. ExecStop=/home/doris/fe/bin/stop_fe.sh

  18. [Install]

  19. WantedBy=multi-user.target ```

注意事项

  • ExecStart、ExecStop根据实际部署的fe的路径进行配置

  • 下载doris-be.service文件: doris-be.service

  • doris-be.service具体内容如下:

``` 1. # Licensed to the Apache Software Foundation (ASF) under one 2. # or more contributor license agreements. See the NOTICE file 3. # distributed with this work for additional information 4. # regarding copyright ownership. The ASF licenses this file 5. # to you under the Apache License, Version 2.0 (the 6. # "License"); you may not use this file except in compliance 7. # with the License. You may obtain a copy of the License at 8. # 9. # http://www.apache.org/licenses/LICENSE-2.0 10. # 11. # Unless required by applicable law or agreed to in writing, 12. # software distributed under the License is distributed on an 13. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14. # KIND, either express or implied. See the License for the 15. # specific language governing permissions and limitations 16. # under the License.

  1. [Unit]
  2. Description=Doris BE
  3. After=network-online.target
  4. Wants=network-online.target

  5. [Service]

  6. Type=forking
  7. User=root
  8. Group=root
  9. LimitCORE=infinity
  10. LimitNOFILE=200000
  11. Restart=on-failure
  12. RestartSec=30
  13. StartLimitInterval=120
  14. StartLimitBurst=3
  15. KillMode=none
  16. ExecStart=/home/doris/be/bin/start_be.sh --daemon
  17. ExecStop=/home/doris/be/bin/stop_be.sh

  18. [Install]

  19. WantedBy=multi-user.target ```

注意事项

  • ExecStart、ExecStop根据实际部署的be的路径进行配置

  • 服务配置

将doris-fe.service、doris-be.service两个文件放到 /usr/lib/systemd/system 目录下 2. 设置自启动

添加或修改配置文件后,需要重新加载

1. systemctl daemon-reload

设置自启动,实质就是在 /etc/systemd/system/multi-user.target.wants/ 添加服务文件的链接

1. systemctl enable doris-fe 2. systemctl enable doris-be 3. 服务启动

1. systemctl start doris-fe 2. systemctl start doris-be

Supervisor配置Doris服务

Supervisor 具体使用以及参数解析可以参考这里

Supervisor 配置自动拉起可以使用 yum 命令直接安装,也可以通过pip手工安装,pip手工安装流程比较复杂,只展示yum方式部署,手工部署请参考这里进行安装部署。

配置步骤

  1. yum安装supervisor

1. yum install epel-release 2. yum install -y supervisor 2. 启动服务并查看状态

1. systemctl enable supervisord # 开机自启动 2. systemctl start supervisord # 启动supervisord服务 3. systemctl status supervisord # 查看supervisord服务状态 4. ps -ef|grep supervisord # 查看是否存在supervisord进程 3. 配置BE进程管理

``` 1. 修改start_be.sh脚本,去掉最后的 & 符号

  1. vim /path/doris/be/bin/start_be.sh
  2. 将 nohup $LIMIT ${DORIS_HOME}/lib/palo_be "$@" >> $LOG_DIR/be.out 2>&1 </dev/null &
  3. 修改为 nohup $LIMIT ${DORIS_HOME}/lib/palo_be "$@" >> $LOG_DIR/be.out 2>&1