1 MySQL 部署
服务器
192.168.1.12
创建 MySQL 用户、新建安装目录、授权目录
useradd mysql
passwd mysql
mkdir /mysql
chown -R mysql:mysql /mysql
切换至 MySQL 用户、下载安装包、解压、重命名目录
su - mysql
cd /mysql
wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
tar -zxvf mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.36-linux-glibc2.12-x86_64 mysql
初始化 MySQL
cd /mysql/mysql
bin/mysqld --initialize-insecure --user=mysql --basedir=/mysql/mysql --datadir=/mysql/mysql/data
编辑 my.cnf 配置文件
cat > /mysql/mysql/my.cnf << EOF
[client]
port=3306
socket=/mysql/mysql/mysql.sock
default-character-set=utf8
[mysqld]
port=3306
basedir=/mysql/mysql
datadir=/mysql/mysql/data
pid-file=/mysql/mysql/mysql.pid
#socket=/mysql/mysql/mysql.sock
log_error=/mysql/mysql/error.log
default-storage-engine=INNODB
character_set_server=utf8
lower_case_table_names=1
table_open_cache=128
max_connections=2000
max_connect_errors=6000
innodb_file_per_table=1
innodb_buffer_pool_size=1G
max_allowed_packet=64M
transaction_isolation=READ-COMMITTED
innodb_flush_method=O_DIRECT
innodb_lock_wait_timeout=1800
innodb_flush_log_at_trx_commit=0
sync_binlog=0
group_concat_max_len=1024000
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
skip-name-resolve
EOF
启动 MySQL
echo "LimitNOFILE=65535
LimitNPROC=65535 " >> /mysql/mysql/bin/mysqld_safe
cd /mysql/mysql
bin/mysqld_safe --defaults-file=/mysql/mysql/my.cnf --user=mysql &
配置环境变量、登陆 MySQL 、修改 root 密码
echo "PATH=\$PATH:/mysql/mysql/bin" >> ~/.bash_profile
source ~/.bash_profile
mysql -uroot
set password=password('j9sCpEMTxM8Zr');
grant all privileges on *.* to 'root'@'%' identified by 'j9sCpEMTxM8Zr' with grant option;
flush privileges;
exit
#创建 dataease 数据库
mysql -uroot -pj9sCpEMTxM8Zr
CREATE DATABASE `dataease` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
编写启动脚本
cat > /mysql/start.sh <<EOF
#!/bin/bash
cd /mysql/mysql && \
bin/mysqld_safe --defaults-file=/mysql/mysql/my.cnf --user=mysql &
sleep 5 && \
echo -e "\n"
EOF
chmod +x /mysql/start.sh
加入开机启动
exit
#退出mysql回到root用户
chmod +x /etc/rc.d/rc.local
echo "su - mysql -c \"/mysql/start.sh\"" >> /etc/rc.d/rc.local
2 Doris 部署
Doris是一个高性能的分析型数据库,分为前端(FE)和后端(BE);
FE:主要负责用户请求的接入、查询解析规划、元数据的管理、节点管理相关工作;
BE:主要负责数据存储、查询计划的执行;
Apache Doris 官方建议生产环境的配置方案:
模块 | CPU | 内存 | 磁盘 | 网络 | 实例数量(最低要求) |
---|---|---|---|---|---|
FE | 16核+ | 64GB+ | SSD 或 RAID 卡,100GB+ * | 万兆网卡 | 3 |
BE | 16核+ | 64GB+ | SSD 或 SATA,100G+ * | 万兆网卡 | 10 |
2.1 服务器环境
(本次演示环境)
doris-fe:
192.168.1.13
doris-be:
192.168.1.14
2.2 系统优化
echo "* soft nofile 65536
* hard nofile 65536 " >> /etc/security/limits.conf
swapoff -a
sed -i 's/^[^#].*swap*/#&/g' /etc/fstab
mount -a
systemctl stop firewalld
systemctl disable firewalld
2.3 配置 JDK 环境
wget -O jdk.tgz https://download.oracle.com/otn/java/jdk/8u331-b09/165374ff4ea84ef0bbd821706e29b123/jdk-8u331-linux-x64.tar.gz?AuthParam=1659681156_5e03cd86d25a21f27920eddfa4194a76 && \
tar -zxvf jdk.tgz -C /usr/local/ && \
echo "export JAVA_HOME=/usr/local/jdk1.8.0_341/
export PATH=\$JAVA_HOME/bin:\$PATH
export CLASSPATH=.\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar" >> ~/.bash_profile && \
source ~/.bash_profile && \
java -version
2.4 部署 fe
本环境 1 个 fe 节点,以下操作在 1 个 fe 节点进行
下载 doris 安装包、解压、配置环境变量
wget https://dist.apache.org/repos/dist/release/doris/1.1/1.1.1-rc03/apache-doris-1.1.1-bin-x86.tar.gz && \
tar -zxvf apache-doris-1.1.1-bin-x86.tar.gz -C /opt/ && \
cd /opt/
mv apache-doris-1.1.1-bin-x86/ doris/
#添加doris环境变量
echo "DORIS_HOME=/opt/doris" >> ~/.bash_profile
source ~/.bash_profile
配置 fe
cp /opt/doris/fe/conf/fe.conf /opt/doris/fe/conf/fe.conf.bak
sed -i "s/8192/4096/g" /opt/doris/fe/conf/fe.conf
echo "meta_dir = \${DORIS_HOME}/doris-meta
priority_networks = 192.168.1.0/24
qe_max_connection = 65535
max_conn_per_user = 1024
sys_log_delete_age=1d
audit_log_delete_age=3d
exec_mem_limit=4294967296
tablet_create_timeout_second=30
catalog_trash_expire_second = 60
enable_batch_delete_by_default=true
max_layout_length_per_row=10000000" >> /opt/doris/fe/conf/fe.conf
启动 fe
#fe1启动:
/opt/doris/fe/bin/start_fe.sh --daemon
#查看启动日志
tail -100f /opt/doris/fe/log/fe.out
#检查端口监听
ss -lnt
添加开机启动
cat > /opt/doris/fe/start.sh << EOF
#!/bin/bash
ulimit -n 65536
source /root/.bash_profile
/opt/doris/fe/bin/start_fe.sh --daemon
EOF
chmod +x /opt/doris/fe/start.sh
echo -e "sleep 10\n/opt/doris/fe/start.sh" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
2.5 部署 be
本环境 1 个 be 节点,以下操作在 1 个节点进行
下载 doris 安装包、解压、配置环境变量
wget https://dist.apache.org/repos/dist/release/doris/1.1/1.1.1-rc03/apache-doris-1.1.1-bin-x86.tar.gz && \
tar -zxvf apache-doris-1.1.1-bin-x86.tar.gz -C /opt/ && \
cd /opt/
mv apache-doris-1.1.1-bin-x86/ doris/
#添加doris环境变量
echo "DORIS_HOME=/opt/doris" >> ~/.bash_profile
source ~/.bash_profile
配置 be
cp /opt/doris/be/conf/be.conf /opt/doris/be/conf/be.conf.bak
echo "priority_networks = 192.168.1.0/24
storage_root_path = /disk/s1
sys_log_roll_num = 1
load_error_log_reserve_hours=1
trash_file_expire_time_sec = 60
snapshot_expire_time_sec = 60
pending_data_expire_time_sec = 60
enable_spilling = true" >> /opt/doris/be/conf/be.conf
启动 be
/opt/doris/be/bin/start_be.sh --daemon
#查看启动日志
tail -100f /opt/doris/be/log/be.out
#检查端口监听
ss -lnt
添加开机启动
cat > /opt/doris/be/start.sh << EOF
#!/bin/bash
ulimit -n 65536
source /root/.bash_profile
/opt/doris/be/bin/start_be.sh --daemon
EOF
chmod +x /opt/doris/be/start.sh
echo -e "sleep 10\n/opt/doris/be/start.sh" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
2.6 添加 be 到 fe
通过 MySQL 服务器添加 be 节点
#登录 MySQL 服务器操作
mysql -h10.102.48.20 -P9030 -uroot
#10.102.48.2 为fe节点IP
#-P9030 为fe.conf 中的 query_port
#默认使用 root 账户,无密码登录
#10.102.48.25为be节点
#9050 为 be.conf 中的 heartbeat_service_port
ALTER SYSTEM ADD BACKEND "192.168.1.14:9050";
SHOW PROC '/backends';
#确认 Alive 为 true
2.7 创建 DataEase 库并改密
CREATE DATABASE dataease;
SET PASSWORD FOR 'root' = PASSWORD('Password123@doris');