安装
wireguard 一键安装脚本 https://github.com/angristan/wireguard-install
curl -O https://raw.githubusercontent.com/angristan/wireguard-install/master/wireguard-install.sh
chmod +x wireguard-install.sh
./wireguard-install.sh
...约 127 字小于 1 分钟
wireguard 一键安装脚本 https://github.com/angristan/wireguard-install
curl -O https://raw.githubusercontent.com/angristan/wireguard-install/master/wireguard-install.sh
chmod +x wireguard-install.sh
./wireguard-install.sh
拥有公网IP的情况下,可以使用frp来实现内网机器的端口映射和访问。
linux
wget https://github.com/fatedier/frp/releases/download/v0.57.0/frp_0.57.0_linux_amd64.tar.gz
tar -zxvf frp_0.57.0_linux_amd64.tar.gz
nc (netcat) 是 Linux/Unix 下的一个网络工具,它可以用来测试和调试网络连接和端口。
ubuntu:
sudo apt-get install netcat
mac:
brew install nc
ssh -R 80:localhost:3000 serveo.net
ngrok http 3000
快速开始
npx localtunnel --subdomain cizai --port 3000
全局安装
npm install -g localtunnel
lt --port 3000
自定义个性前缀
lt --subdomain <个性前缀> --port <要映射的端口>
# 获取访问密码
wget -q -O - https://loca.lt/mytunnelpassword
| 简介 | 网址 |
|---|---|
| 下雨声 | http://www.rainymood.com/ |
| 下雨声 | http://mostlyrain.com/ |
| 下雨声 | https://www.calm.com/ |
select
from_unixtime(cast(siyu_add_time/1000 as int) , 'yyyy-MM-dd') as sdate,
count(1),
count(if(second_id is null,1,null))
from users
-- 2023-06-14 00:00:00
where siyu_add_time > 1686672000000
group by from_unixtime(cast(siyu_add_time/1000 as int) , 'yyyy-MM-dd')
order by from_unixtime(cast(siyu_add_time/1000 as int) , 'yyyy-MM-dd') desc
更新数据
ALTER table ads_sales_item_shop_di_replica ON CLUSTER ck_cluster1 update item_no='' where item_no is null;
ALTER table ads_sales_item_shop_di_replica ON CLUSTER ck_cluster1 update store_shop_code='' where store_shop_code is null;
ALTER table ads_sales_item_shop_di_replica ON CLUSTER ck_cluster1 update unify_goods_code='' where unify_goods_code is null;
重命名表
RENAME TABLE table_A TO table_A_bak, table_B TO table_B_bak;
查看所有表
select *
FROM system.tables t WHERE database ='ads' AND engine <>'Distributed' ORDER by total_rows DESC
select *
FROM system.tables t WHERE database ='ads'
AND engine <>'Distributed'
and name not like '%del%'
and name not like '%20%'
ORDER by total_rows DESC
自动清理query_log,query_thread_log,trace_log
ALTER TABLE system.query_log on cluster ck_cluster1 MODIFY TTL event_date + INTERVAL 15 DAY
ALTER TABLE system.query_thread_log on cluster ck_cluster1 MODIFY TTL event_date + INTERVAL 15 DAY
ALTER TABLE system.trace_log on cluster ck_cluster1 MODIFY TTL event_date + INTERVAL 15 DAY
立即清理
alter table system.query_thread_log_0 drop partition '202105'
分区名可以用下语句查询
select * from system.parts p where table = '表名'
查看parts
select * from system.parts where table = 'abs_activity_item_info_day_replica'
select * from system.parts where active = 0
当前慢查询
SELECT * FROM system.processes limit 100
耗时大于60秒
kill query where elapsed >= 60
clickhouse不能创建等执行操作时(每个节点都要执行)
select * from system.mutations where is_done = 0;
kill mutation ON CLUSTER ck_cluster1
where database='ads' and table='ads_jd_erp_sale_outstock_replica'
进入zk清理任务
deleteall /clickhouse/distributed_ddl/query-0000011932
查询阻塞的任务
select * from system.distributed_ddl_queue where status != 'Finished'
查看表大小
SELECT
table AS `表名`,
sum(rows) AS `总行数`,
formatReadableSize(sum(data_uncompressed_bytes)) AS `原始大小`,
formatReadableSize(sum(data_compressed_bytes)) AS `压缩大小`,
round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100, 0) AS `压缩率`
FROM system.parts
GROUP BY table
order by sum(data_compressed_bytes) desc
修改字段名
ALTER TABLE visits RENAME COLUMN webBrowser TO browser
分布式集群下用分布式DDL修改字段名
ALTER TABLE visits on cluster shipin_cluster RENAME COLUMN webBrowser TO browser
新增字段
alter table ads_itemprice_sales_section_replica ON CLUSTER ck_cluster1 add column sort_mark Nullable(int)
alter table ads_itemprice_sales_section ON CLUSTER ck_cluster1 add column sort_mark Nullable(int)
GET _cluster/allocation/explain?pretty
GET /_cluster/allocation/explain
get /_cluster/settings
PUT /_cluster/settings
{
"transient": {
"cluster.routing.allocation.enable": "none"
}
}
#分片配置
PUT /_cluster/settings
{
"transient": {
"cluster.routing.allocation.enable": "all"
}
}
#分片重新均衡分配
PUT /_cluster/settings
{
"transient": {
"cluster.routing.rebalance.enable": "all"
}
}
# 设置副本数量
PUT /aabb/_settings
{
"number_of_replicas" : 2
}
get _cluster/health?level=indices
GET _cat/nodes?v&h=ip,heap.current,heap.percent,heap.max,ram.max,disk.avail,node.role,m
curl http://localhost:9200/_cat/nodes?v&h=ip,heap.current,heap.percent,heap.max,ram.max,disk.avail,node.role,m
get _cat/master
post /_cluster/reroute
{
"commands": [
{
"allocate_empty_primary": {
"index": "wap_yonghu_v1",
"shard": 2,
"node": "Ee6ubnnmT52LJchcw0P-pQ",
"accept_data_loss": false
}
}
]
}
#数据丢失
post /_cluster/reroute
{
"commands": [
{
"allocate_empty_primary": {
"index": "aabb_v2",
"shard": 0,
"node": "Ee6ubnnmT52LJchcw0P-pQ",
"accept_data_loss": true
}
}
]
}
#数据不丢失
post /_cluster/reroute
{
"commands" : [ {
"allocate_stale_primary" : {
"index" : "aabb_v2",
"shard" :0,
"node" : "Ee6ubnnmT52LJchcw0P-pQ",
"accept_data_loss" : true
}
}]
}
POST /_cluster/reroute?retry_failed=true
手动迁移分片
POST /_cluster/reroute
{
"commands": [
{
"move": {
"index": "aabb_v1",
"shard": 1,
"from_node": "10.10.20.143",
"to_node": "10.10.20.153"
}
}
]
}
在各DN的数据分布倾斜
select table_skewness('ads_sales_shop_notdis');
| hbase shell命令 | 描述 |
|---|---|
| alter | 修改列族(column family)模式 |
| count | 统计表中行的数量 |
| create | 创建表 |
| describe | 显示表相关的详细信息 |
| delete | 删除指定对象的值(可以为表,行,列对应的值,另外也可以指定时间戳的值) |
| deleteall | 删除指定行的所有元素值 |
| disable | 使表无效 |
| drop | 删除表 |
| enable | 使表有效 |
| exists | 测试表是否存在 |
| exit | 退出hbase shell |
| get | 获取行或单元(cell)的值 |
| incr | 增加指定表,行或列的值 |
| list | 列出hbase中存在的所有表 |
| put | 向指向的表单元添加值 |
| tools | 列出hbase所支持的工具 |
| scan | 通过对表的扫描来获取对用的值 |
| status | 返回hbase集群的状态信息 |
| shutdown | 关闭hbase集群(与exit不同) |
| truncate | 重新创建指定表 |
| version | 返回hbase版本信息 |
insert overwrite table dws_jd_erp_purchase_transfer partition(dt)
select * from
data_kezhi.dws_jd_erp_purchase_transfer
where dt = '${bizdate}'
mongo 172.20.3.59:27017/admin -u usvr_bi-p
默认是100
查看方法
show variables like '%max_connections%'
# 查某人全部关系
return (:star{starname:"张国荣"})-->();
# 查某人朋友的朋友(5层关系)
match p=(n:star{starname:"张国荣"})-[*..5]->() return p limit 50;
# 查询特定关系
match p=()-[:rel{relation:"旧爱"}]->() return p LIMIT 25;
# 使用函数,查询张国荣与张卫健的最短路径
match p=shortestpath((:star{starname:"张国荣"})-[*..5]->(:star{starname:"张卫健"})) return p;
# 查询某节点
MATCH (n:shop) where n.shop_name="奥普浴霸苏州专卖店" RETURN n LIMIT 200
# 查询和某节点的全部关系
MATCH p=(:shop{shop_name:"长沙华艺卫浴专营店"})-->() return p LIMIT 200;
# 查询特定关系
MATCH p=()-[r:`品牌`]->() RETURN p LIMIT 200
# 查某节点(5层关系)
match p=(n:shop{shop_name:"长沙华艺卫浴专营店"})-[*..5]->() return p limit 50;
删除节点和关系
MATCH (n:shop) DETACH DELETE n
UPDATE (要更新的表) table1 t1
SET 字段1 = t2.字段1, 字段2 = t2.字段2,
FROM (数据来源表) table2 t2
WHERE t1.key = t2.key
这里是内容。
这里是内容。
rename-command KEYS ""
rename-command FLUSHALL ""
rename-command FLUSHDB ""
rename-command CONFIG ""
yum install gflags
yum install snappy snappy-devel
yum install zlib zlib-devel
yum install bzip2 bzip2-devel
yum install lz4-devel
yum install libasan
wget https://github.com/facebook/zstd/archive/v1.1.3.tar.gz
mv v1.1.3.tar.gz zstd-1.1.3.tar.gz
tar zxvf zstd-1.1.3.tar.gz
cd zstd-1.1.3
make && make install
// 1,解压rocksDB
tar -zxvf rocksdb-6.4.6.tar.gz
// 2 进入解压后的目录
cd rocksdb-6.4.6
/// 3,编译静态库,获得 librocksdb.a
make static_lib
// 4,编译动态库,获得 lbrocksdb.so
make shared_lib
// 1
cp librocksdb.so.6.4.6 /usr/local/lib
// 2
ln -s librocksdb.so.6.4.6 /usr/local/lib/librocksdb.so.6
// 3
ln -s librocksdb.so.6.4.6 /usr/local/lib/librocksdb.so
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
我们最好在环境变量中添加:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib