apche doris 2.0.0 Linux环境下一键安装部署脚本
1 #!/bin/bash 2 # doris部署环境要求: 3 #(1)一台或多台机器,操作系统CentOS 7.x-86_x64 4 #(2)硬件配置:内存4G+,CPU 2核+; 5 #(3)集群内各个机器之间能相互通信; 6 #(4)集群内各个机器可以访问外网,需要拉取文件; 7 #(5)提前安装 yum install -y wget 8 9 # 安装步骤 10 #1. 安装jdk 1.8.0_202 11 #2. 安装doris 12 #2.1 初始化环境 13 #2.2 下载 apache-doris-2.0.0-bin-x64.tar.gz 14 #2.3 安装 FE 15 #2.4 安装 BE 16 17 set -e 18 19 # 安装日志 20 install_log=/var/log/install_k8s.log 21 tm=$(date +'%Y%m%d %T') 22 23 # 日志颜色 24 COLOR_G="\x1b[0;32m" # green 25 RESET="\x1b[0m" 26 27 function info(){ 28 echo -e "${COLOR_G}[$tm] [Info] ${1}${RESET}" 29 } 30 31 function run_cmd(){ 32 sh -c "$1 | $(tee -a "$install_log")" 33 } 34 35 function run_function(){ 36 $1 | tee -a "$install_log" 37 } 38 39 function install_java(){ 40 yum install -y wget 41 42 info "1.自动下载jdk..." 43 wget --no-check-certificate https://repo.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-linux-x64.tar.gz 44 45 info "2.解压到/usr/local/java文件夹..." 46 mkdir /usr/local/java/ 47 tar -zxvf jdk-8u202-linux-x64.tar.gz -C /usr/local/java 48 49 info "3.配置环境变量..." 50 echo "export JAVA_HOME=/usr/local/java/jdk1.8.0_202" >> /etc/profile 51 echo "export JRE_HOME=${JAVA_HOME}/jre" >> /etc/profile 52 echo "export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib" >> /etc/profile 53 echo "export PATH=${JAVA_HOME}/bin:$PATH" >> /etc/profile 54 source /etc/profile 55 ln -s /usr/local/java/jdk1.8.0_202/bin/java /usr/bin/java 56 57 info "4.测试 java 是否安装正确..." 58 java -version 59 } 60 61 function install_doris() { 62 info "初始化doris部署环境..." 63 init_env 64 65 info "下载doirs..." 66 download_doris 67 68 read -p "是否安装doris fe?默认为:no. Enter [yes/no]:" is_doris_fe 69 if [[ "$is_doris_fe" == 'yes' ]];then 70 run_function "install_doris_fe" 71 fi 72 73 read -p "是否安装doris be?默认为:no. Enter [yes/no]:" is_doris_be 74 if [[ "$is_doris_be" == 'yes' ]];then 75 run_function "install_doris_be" 76 fi 77 } 78 79 # 初始化部署环境 80 function init_env() { 81 info "关闭防火墙" 82 systemctl stop firewalld 83 systemctl disable firewalld 84 85 info "关闭selinux" 86 sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/g' /etc/selinux/config 87 source /etc/selinux/config 88 89 info "关闭swap(k8s禁止虚拟内存以提高性能)" 90 swapoff -a 91 sed -i '/swap/s/^\(.*\)$/#\1/g' /etc/fstab 92 93 info "设置文件句柄数" 94 echo "* soft nofile 204800" >> /etc/security/limits.conf 95 echo "* hard nofile 204800" >> /etc/security/limits.conf 96 echo "* soft nproc 204800" >> /etc/security/limits.conf 97 echo "* hard nproc 204800" >> /etc/security/limits.conf 98 echo fs.file-max = 6553560 >> /etc/sysctl 99 100 info "设置max_map_count" 101 echo vm.max_map_count = 2000000 >> /etc/sysctl 102 sysctl -w vm.max_map_count=2000000 103 } 104 105 function download_doris() { 106 yum install -y wget 107 108 info "1.下载Doris 2.0.0 tar.gz 文件..." 109 if [[ ! -f "/root/apache-doris-2.0.0-bin-x64.tar.gz" ]]; then 110 wget --no-check-certificate https://apache-doris-releases.oss-accelerate.aliyuncs.com/apache-doris-2.0.0-bin-x64.tar.gz 111 fi 112 113 info "2.解压文件/opt/doris文件夹下..." 114 if [[ ! -d "/opt/doris/" ]]; then 115 mkdir /opt/doris/ 116 fi 117 tar -zxvf apache-doris-2.0.0-bin-x64.tar.gz --strip-components 1 -C /opt/doris/ 118 } 119 120 function install_doris_fe() { 121 sleep 1 122 read -p "请输入priority_networks 参数:" fe_ip 123 eval sed -i '58i\priority_networks=${fe_ip}/24' /opt/doris/fe/conf/fe.conf 124 125 info "FE 启动ing..." 126 sudo sh /opt/doris/fe/bin/start_fe.sh --daemo 127 128 info "设置FE自动启动..." 129 touch /etc/init.d/apache-doris-fe 130 echo '#!/bin/bash' >> /etc/init.d/apache-doris-fe 131 echo '# chkconfig: 3 88 88' >> /etc/init.d/apache-doris-fe 132 echo '/bin/bash /opt/doris/fe/bin/start_fe.sh --daemo' >> /etc/init.d/apache-doris-fe 133 134 chmod +x /etc/init.d/apache-doris-fe 135 chkconfig --add apache-doris-fe 136 137 info "检查FE 是否已启动(需等待一段时间,失败可忽略)..." 138 curl http://127.0.0.1:8030/api/bootstrap 139 } 140 141 function install_doris_be() { 142 143 sleep 1 144 read -p "请输入priority_networks 参数:" be_ip 145 eval sed -i '58i\priority_networks=${be_ip}/24' /opt/doris/be/conf/be.conf 146 sed -i '28i\JAVA_HOME=/usr/local/java/jdk1.8.0_202' /opt/doris/be/conf/be.conf 147 148 info "BE 启动ing..." 149 mv /opt/doris/extensions/* /opt/doris/be/lib/ 150 sudo sh /opt/doris/be/bin/start_be.sh --daemo 151 152 info "设置BE自动启动..." 153 touch /etc/init.d/apache-doris-be 154 echo '#!/bin/bash' >> /etc/init.d/apache-doris-be 155 echo '# chkconfig: 3 88 88' >> /etc/init.d/apache-doris-be 156 echo '/bin/bash /opt/doris/be/bin/start_be.sh --daemo' >> /etc/init.d/apache-doris-be 157 158 chmod +x /etc/init.d/apache-doris-be 159 chkconfig --add apache-doris-be 160 161 info "检查BE 是否已启动(需等待一段时间,失败可忽略)..." 162 curl http://127.0.0.1:8040/metrics 163 } 164 165 166 # 安装jdk 167 read -p "是否安装jdk 1.8.0_202?默认为:no. Enter [yes/no]:" is_jdk 168 if [[ "$is_jdk" == 'yes' ]];then 169 run_function "install_java" 170 fi 171 172 # 安装k8s 173 read -p "是否安装is_doris?默认为:no. Enter [yes/no]:" is_doris 174 if [[ "$is_doris" == 'yes' ]];then 175 run_function "install_doris" 176 fi