commit
This commit is contained in:
parent
c8fb1d5c74
commit
0add342efb
@ -969,3 +969,43 @@ Maven下载依赖
|
||||
|
||||
仅用于分表。仅DATE、DATETIME类型。
|
||||
一年之中第几天%分表数。tbpartitions不能超过366。
|
||||
|
||||
# MySQL 查询语句
|
||||
|
||||
## 查询语句中字段别名取表中的comment
|
||||
|
||||
在 MySQL 中,字段的 comment 并不存储在数据行里,而是放在 **information_schema.COLUMNS** 中。
|
||||
因此可以通过把 **column_comment** 查出来,再拼成 **SELECT 语句的别名**,实现“用表中字段的 comment 做别名”的效果。
|
||||
|
||||
一次性查出某张表所有列,并把 comment 作为别名:
|
||||
|
||||
```mysql
|
||||
-- 示例:表名 mydb.mytable
|
||||
SELECT CONCAT(
|
||||
'SELECT ',
|
||||
GROUP_CONCAT(
|
||||
CONCAT('`', COLUMN_NAME, '` AS `', REPLACE(COLUMN_COMMENT, '`', ''), '`')
|
||||
ORDER BY ORDINAL_POSITION
|
||||
),
|
||||
' FROM mytable;'
|
||||
) AS sql_text
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = 'mydb'
|
||||
AND TABLE_NAME = 'mytable';
|
||||
```
|
||||
|
||||
执行后得到一条 SQL,例如:
|
||||
|
||||
```mysql
|
||||
SELECT id AS 主键, name AS 用户名, age AS 年龄 FROM mytable;
|
||||
```
|
||||
|
||||
**拼 SQL 时丢列**
|
||||
上一段拼接脚本里 `GROUP_CONCAT` 有 **长度限制**(默认 1024 字节)。
|
||||
如果表列很多,会被截断导致看起来“少字段”。
|
||||
解决方法:
|
||||
|
||||
```mysql
|
||||
SET SESSION group_concat_max_len = 1000000; -- 临时放大
|
||||
```
|
||||
|
||||
|
||||
@ -69,10 +69,12 @@ vim 的各种工作模式可以通过不同的键进行切换,用户统一使
|
||||
|
||||
在底线命令模式中,基本的命令有(已经省略了冒号):
|
||||
|
||||
- :w: 保存文件
|
||||
- :q: 退出 Vim 编辑器
|
||||
- :wq: 保存文件并退出 Vim 编辑器
|
||||
- :q!: 强制退出 Vim 编辑器,不保存修改
|
||||
- :w 保存文件
|
||||
- :q 退出 Vim 编辑器
|
||||
- :wq 保存文件并退出 Vim 编辑器
|
||||
- :q! 强制退出 Vim 编辑器,不保存修改
|
||||
- :set nu 开启行号
|
||||
- :set nonu 关闭行号
|
||||
|
||||
按`ESC`键可随时退出底线命令模式。
|
||||
|
||||
@ -183,4 +185,20 @@ vim 的各种工作模式可以通过不同的键进行切换,用户统一使
|
||||
</thead>
|
||||
</table>
|
||||
</center>
|
||||
# Vim配置文件
|
||||
|
||||
## 当前用户配置文件(~/.vimrc)
|
||||
|
||||
若在当前用户目录下没有`.vimrc`,则手动新建即可
|
||||
|
||||
```bash
|
||||
vim ~/.vimrc
|
||||
```
|
||||
|
||||
其中可添加如命令模式中的命令,比如`set nu`,之后再打开vim则默认开启行号
|
||||
|
||||
```
|
||||
set nu
|
||||
```
|
||||
|
||||
`:wq`保存退出后,需使用`source ~/.vimrc`使改动生效
|
||||
|
||||
@ -10,6 +10,196 @@ tags:
|
||||
|
||||
## 安装
|
||||
|
||||
### Docker Compose 方式
|
||||
|
||||
> [Quick Start - Apache Doris](https://doris.apache.org/docs/dev/gettingStarted/quick-start)
|
||||
|
||||
新建用于Docker Compose 集群编排启动目录`mkdir -p /OLAP/doris`
|
||||
|
||||
```bash
|
||||
mkdir -p /OLAP/doris
|
||||
```
|
||||
|
||||
编写启动脚本`start-doris.sh`
|
||||
|
||||
> https://doris.apache.org/files/start-doris.sh
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
|
||||
# Default version
|
||||
DORIS_QUICK_START_VERSION="2.1.9"
|
||||
|
||||
# Parse parameters
|
||||
while getopts "v:" opt; do
|
||||
case $opt in
|
||||
v) DORIS_QUICK_START_VERSION="$OPTARG"
|
||||
;;
|
||||
\?) echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check system type
|
||||
OS_TYPE=$(uname -s)
|
||||
if [[ "$OS_TYPE" != "Linux" && "$OS_TYPE" != "Darwin" ]]; then
|
||||
echo "Error: Unsupported operating system [$OS_TYPE], only Linux and Mac are supported"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check Docker environment
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo "Error: Docker environment not detected, please install Docker first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check docker-compose
|
||||
COMPOSE_CMD=""
|
||||
if command -v docker-compose &> /dev/null; then
|
||||
COMPOSE_CMD="docker-compose"
|
||||
elif docker compose version &> /dev/null; then
|
||||
COMPOSE_CMD="docker compose"
|
||||
else
|
||||
echo "Error: docker-compose plugin or docker-compose command is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Generate docker-compose configuration for corresponding system
|
||||
if [[ "$OS_TYPE" == "Linux" ]]; then
|
||||
cat > docker-compose-doris.yaml <<EOF
|
||||
version: "3"
|
||||
services:
|
||||
fe:
|
||||
image: apache/doris:fe-${DORIS_QUICK_START_VERSION}
|
||||
hostname: fe
|
||||
environment:
|
||||
- FE_SERVERS=fe1:127.0.0.1:9010
|
||||
- FE_ID=1
|
||||
network_mode: host
|
||||
volumes:
|
||||
- /mnt/app/doris/fe/doris-meta/:/opt/apache-doris/fe/doris-meta/
|
||||
- /mnt/app/doris/fe/log/:/opt/apache-doris/fe/log/
|
||||
be:
|
||||
image: apache/doris:be-${DORIS_QUICK_START_VERSION}
|
||||
hostname: be
|
||||
environment:
|
||||
- FE_SERVERS=fe1:127.0.0.1:9010
|
||||
- BE_ADDR=127.0.0.1:9050
|
||||
depends_on:
|
||||
- fe
|
||||
network_mode: host
|
||||
volumes:
|
||||
- /mnt/app/doris/be/storage/:/opt/apache-doris/be/storage/
|
||||
- /mnt/app/doris/be/script/:/docker-entrypoint-initdb.d/
|
||||
EOF
|
||||
else # Mac system
|
||||
cat > docker-compose-doris.yaml <<EOF
|
||||
version: "3"
|
||||
networks:
|
||||
custom_network:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.20.80.0/24
|
||||
|
||||
services:
|
||||
fe:
|
||||
image: apache/doris:fe-${DORIS_QUICK_START_VERSION}
|
||||
hostname: fe
|
||||
ports:
|
||||
- 8030:8030
|
||||
- 9030:9030
|
||||
- 9010:9010
|
||||
environment:
|
||||
- FE_SERVERS=fe1:172.20.80.2:9010
|
||||
- FE_ID=1
|
||||
networks:
|
||||
custom_network:
|
||||
ipv4_address: 172.20.80.2
|
||||
|
||||
be:
|
||||
image: apache/doris:be-${DORIS_QUICK_START_VERSION}
|
||||
hostname: be
|
||||
ports:
|
||||
- 8040:8040
|
||||
- 9050:9050
|
||||
environment:
|
||||
- FE_SERVERS=fe1:172.20.80.2:9010
|
||||
- BE_ADDR=172.20.80.3:9050
|
||||
depends_on:
|
||||
- fe
|
||||
networks:
|
||||
custom_network:
|
||||
ipv4_address: 172.20.80.3
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Start services
|
||||
$COMPOSE_CMD -f docker-compose-doris.yaml up -d
|
||||
|
||||
echo "Doris cluster started successfully, version: ${DORIS_QUICK_START_VERSION}"
|
||||
echo "You can manage the cluster using the following commands:"
|
||||
echo " Stop cluster: $COMPOSE_CMD -f docker-compose-doris.yaml down"
|
||||
echo " View logs: $COMPOSE_CMD -f docker-compose-doris.yaml logs -f"
|
||||
echo " Connect to cluster: mysql -uroot -P9030 -h127.0.0.1"
|
||||
|
||||
# Display connection information based on system type
|
||||
if [[ "$OS_TYPE" == "Linux" ]]; then
|
||||
echo -e "\nAccess FE/BE http ports (8030, 8040) using the following addresses (Linux system):"
|
||||
echo " http://127.0.0.1:8030"
|
||||
echo " http://127.0.0.1:8040"
|
||||
elif [[ "$OS_TYPE" == "Darwin" ]]; then
|
||||
echo -e "\nAccess FE/BE http ports (8030, 8040) using the following addresses (Mac system):"
|
||||
echo " http://docker.for.mac.localhost:8030"
|
||||
echo " http://docker.for.mac.localhost:8040"
|
||||
echo "Note: If access fails, try using 127.0.0.1 address:"
|
||||
echo " http://127.0.0.1:8030"
|
||||
echo " http://127.0.0.1:8040"
|
||||
fi
|
||||
```
|
||||
|
||||
赋予权限
|
||||
|
||||
```bash
|
||||
chmod 755 start-doris.sh
|
||||
```
|
||||
|
||||
启动集群
|
||||
|
||||
```bash
|
||||
./start-doris.sh
|
||||
```
|
||||
|
||||
可以指定启动的版本通过`-v`参数,比如:
|
||||
|
||||
```bash
|
||||
./start-doris.sh -v 2.1.8
|
||||
```
|
||||
|
||||
使用MySQL客户端连接到集群并检查集群状态
|
||||
|
||||
```bash
|
||||
## Check the FE status to ensure that both the Join and Alive columns are true.
|
||||
mysql -uroot -P9030 -h127.0.0.1 -e 'SELECT `host`, `join`, `alive` FROM frontends()'
|
||||
+-----------+------+-------+
|
||||
| host | join | alive |
|
||||
+-----------+------+-------+
|
||||
| 127.0.0.1 | true | true |
|
||||
+-----------+------+-------+
|
||||
|
||||
## Check the BE status to ensure that the Alive column is true.
|
||||
mysql -uroot -P9030 -h127.0.0.1 -e 'SELECT `host`, `alive` FROM backends()'
|
||||
+-----------+-------+
|
||||
| host | alive |
|
||||
+-----------+-------+
|
||||
| 127.0.0.1 | 1 |
|
||||
+-----------+-------+
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 配置
|
||||
|
||||
#### Linux系统环境配置(所有节点均需配置)
|
||||
|
||||
@ -480,7 +480,54 @@ source ~/.zshrc
|
||||
conda init
|
||||
```
|
||||
|
||||
3.
|
||||
3. conda和pip换镜像源
|
||||
|
||||
修改conda,通过以下命令进行添加
|
||||
|
||||
```lua
|
||||
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
|
||||
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
|
||||
conda config --set show_channel_urls yes
|
||||
```
|
||||
|
||||
修改后可以通过以下命令查看:
|
||||
|
||||
```armasm
|
||||
conda info
|
||||
```
|
||||
|
||||
下载试试:如果两都能看到下载源,那么就更改成功。
|
||||
|
||||
```mipsasm
|
||||
conda install
|
||||
```
|
||||
|
||||
##### Linux系统下:
|
||||
|
||||
linux系统下要到用户的文件夹下新建目录.pip,并在目录新建配置文件pip.conf
|
||||
|
||||
```bash
|
||||
mkdir ~/.pip
|
||||
cd ~/.pip
|
||||
vi pip.conf
|
||||
```
|
||||
|
||||
编辑内容:
|
||||
|
||||
```ini
|
||||
[global]
|
||||
index-url=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
[install]
|
||||
trusted-host=pypi.tuna.tsinghua.edu.cn
|
||||
disable-pip-version-check = true
|
||||
timeout = 6000
|
||||
```
|
||||
|
||||
下载试试:
|
||||
|
||||
```bash
|
||||
pip install
|
||||
```
|
||||
|
||||
# Jupyter Notebook
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user