01-001-linux安装多版本python环境

1:简介

使用源码安装多个版本 python 环境,对系统原有 py 不影响

2:Linux 安装多个版本 python

2.1 下载 python 安装包

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
// ---------- python3.8 源码安装 --------------
// (1) 创建安装目录
mkdir -p /usr/local/python/python3.8
cd /usr/local/python/python3.8
// (2) 下载源码包
sudo wget  https://registry.npmmirror.com/-/binary/python/3.8.13/Python-3.8.13.tgz
tar -zxvf Python-3.8.13.tgz
cd Python-3.8.13
// (3) 配置要安装的目录
./configure prefix=/usr/local/python/python3.8 --enable-optimizations
// (4) 编译源码
sudo make -j8
// (5) make altinstall与make install的区别,altinstall skips creating the python link and the manual pages links
// https://blog.csdn.net/andylauren/article/details/108363030
sudo make altinstall



// python3.10
mkdir -p /usr/local/python/python3.10
cd /usr/local/python/python3.10
sudo wget https://registry.npmmirror.com/-/binary/python/3.10.6/Python-3.10.6.tgz

2.2 update-alternative 管理多版本 python

update-alternatives 命令用于处理 linux 系统中软件版本的切换

01-kafka

消息队列Kafka

1: Introduction

2: Arch 架构

3: 可视化 tools

1
2
//  kafka-map
https://github.com/dushixiang/kafka-map

01-有趣项目记录

有趣项目记录

1: 工具类

2: 好玩类

2.1 自动发送暖心邮件

1
https://github.com/Vincedream/NodeMail

2.2 土味情话生成器

1
https://github.com/zerosoul/honeyed-words-generator

3: 文件传输

1
2
3
// tl-rtc-file
// 用webrt在web端传输文件,支持传输超大文件, 分片传输,跨终端,不限平台,方便使用,内网不限速,支持私有部署
https://github.com/iamtsm/tl-rtc-file

4: 分布式文件系统

1
2
seaweedfs
https://github.com/seaweedfs/seaweedfs

5: 工具类

  • ctop

007-Python第三方库大全

部分转自:https://www.ctq6.cn/python%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93%E5%A4%A7%E5%85%A8/#wsgi-%E6%9C%8D%E5%8A%A1%E5%99%A8

01-常见编程语言-如何在命令行编译并运行

常见编程语言-如何在命令行编译并运行

1 : Summary

2 : java 编译与运行

2.1 环境准备

  • 环境准备 安装 oracle java sdk ,或者 oracle open jdk ,然后将 java 可执行程序所在程序配置到 $PATH (windows 用户配置到 %path%)。
  • java open jdk 有非常多的版本,可通过 jabba 安装,版本非常全。 windows 用户安装了 scoop 的,可以使用 scoop 来安装,使用 scoop search jdk 会提示相应的步骤 macos/linux 用户还可以使用 jenv 来管理多版本。

2.2 编写代码

1
2
3
4
5
6
// hello.java
class Hello {
  public static void main(String[] args){
    System.out.println("I'm a Simple Program");
  }
}

2.3 编译运行

  • 命令javac hello.java && java Hello

Go项目一般性组织结构

Go项目一般性组织结构

1: summary

2: 其他一些规划方案

3: 自己的规划组织方式

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
├── cmd/
   └── main.go //启动函数
├── server                 // 对外的服务,比如微服务,rpc
   └── rpc
   └── micro
├── pkg
    ├── common  // 全局
       └── conf
       └── log
       └── db
       └── redis
       └── globalvaribal
       └── const
    ├── internal/
           └── service/
               └── xxx_service.go //业务逻辑处理类
               └── xxx_service_test.go
           └── model/
               └── xxx_info.go//结构体
           └── api/
               └── xxx_api.go//路由对应的接口实现
           └── router/
               └── router.go//路由
           └── tools/   // 服务内部的一些公共工具,方法和函数
               └── datetool//时间工具类
               └── jsontool//json 工具类

01-ClickHouse常用sql脚本

ClickHouse常用sql脚本

一: ClickHouse 介绍

  • ClickHouse 是一个用于联机分析(OLAP)的列式数据库管理系统(DBMS).
  • https://clickhouse.com/docs/zh/
  • 数据文件路径: /var/lib/clickhouse/
  • 日志文件路径:/var/log/clickhouse-server/clickhouse-server.log

二: Clickhouse 连接

三: ClickHouse Database

3.1 数据库操作

  • ClickHouse 严格区分大小写
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
-- 显示所有数据库
SHOW database

-- 显示当前使用的数据库
select currentDatabase();

-- 创建数据库
CREATE database if not exists tick

-- 删除数据库
DROP  database tick ON CLUSTER <集群名>

-- 显示数据库中的所有表
show tables FROM tick ON CLUSTER <集群名>

-- 手动optimize,合并分区
optimize table tick final;

3.2 表操作

3.2.1 查看表结构

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
-- 建表
create table IF NOT EXISTS test.user ON CLUSTER <集群名> (
    `uid` Int32,
    `name` String,
    `age` UInt32,
    `birthday` Date
)ENGINE = MergeTree()
PARTITION BY  (`birthday`)
ORDER BY (uid,birthday);

-- 设置表TTL
--    涉及判断的字段必须是Date或者Datetime类型,推荐使用分区的日期字段:
--      SECOND , MINUTE , HOUR , DAY , WEEK , MONTH , QUARTER , YEAR
Alter table test.user Modify TTL createAt+interval 1 day;


-- 显示表结构
DESCRIBE TABLE test.user;

-- 显示建表语句
SHOW CREATE TABLE test.user;

-- 删除表
DROP table IF EXISTS test.student;

-- 添加字段
alter table product_test add column `test` String DEFAULT '' COMMENT '注释';

--删除字段
alter table product_test drop column `test`;

--修改字段
alter table product_test modify column `test` Nullable(String) DEFAULT NULL COMMENT '注释';

--删除数据
ALTER TABLE db_name.table_name DROP PARTITION '分区(例如:时间20220516)'

-- 删除表中所有数据(清空表)
alter table tableName delete where 1=1;

四: View 视图

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
--ClickHouse支持视图功能,目前一共支持两种视图:普通(Normal)视图和物化(Materialized)视图
--通过DROP TABLE [$db_name.]$view_table_name语句可以直接删除视图,而通过SHOW TABLES可以展示所有的表,视图也会被认为是一种特殊的表一并进行展示

--普通视图
--普通视图不会存储任何数据,它只是一个查询映射,起到了简化查询语义的作用,对查询的性能也不会有任何正负作用


--物化视图
--物化视图支持定义表引擎,因为其数据保存的形式由表引擎决定
--需要定义表引擎,决定数据存储的形式
--物化视图中的数据不支持同步删除,如果源表的数据不存在或者源表被删除了,物化视图的数据依然存在
--物化视图不会随着基础表的变化而变化,所以它也称为快照(snapshot)
--如果要更新数据的话,需要用户手动进行,如周期性执行SQL,或利用触发器等机制

五: ClickHouse-client

1
2
3
4
5
//
clickhouse-client --host localhost --user admin --password admin

// 导出数据
clickhouse-client --query "select * from t_order_mt where create_time='2020-06-01 12:00:00'" --format CSVWithNames> /opt/module/data/rs1.csv

六: clickhouse-local

01-docker cheat sheet

Docker Cheat Sheet

1: Process Management

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Show all running docker containers
docker ps
# Show all docker containers
docker ps -a
# Run a container
docker run <image>:<tag>
# Run a container and connect to it
docker run -it <image>:<tag>
# Run a container in the background
docker run -d <image>:<tag>
# Stop a container
docker stop <container>
# Kill a container
docker kill <container>

2: Images/Repository

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# List available local images
docker images
# Search for docker images
docker search <image>
# Pull a docker image
docker pull <image>
# Build an image with a dockerfile
docker build -t <image>:<tag> <run_directory> -f <dockerfile>
# Login to a remote repository
docker login <repository>
# Push an image to your remotee repository
docker push <image>:<tag>
# Remove a local docker image
docker rmi <image>:<tag>
# Show metadata for an image
docker inspect <image>
# Remove all unused docker images
docker image prune

3: Volumes & Ports

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# List volumes
docker volume ls
# Create a volume
docker volume create <volume>
# Delete a volume
docker volume rm <volume>
# Show volume metadata
docker volume inspect <volume>
# Delete all volumes not attached to a container
docker volume prune
# Mount a local directory to your container
docker run -v <local_dir>:<container_dir> <image>
# Copy file or folder from a docker container to host machine
docker cp <container>:<container_dir> <local_dir>
# Copy file or folder from local machine onto a container
docker cp <local_dir> <container>:<container_dir>
# Map a local port to a docker instance
docker run -d -p 127.0.0.1:<local_port>:<docker_port> <image>
# List the ports a docker container is running on
docker port <container>

4: Troubleshooting(故障排除)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Show the logs of a container
docker logs <container>
# Follow/tail the logs of a container
docker logs -f <container>
# Show timestamps on docker logs
docker logs -t <container>
# Show details/metadata of a container
docker inspect <container>
# Show a 'top' view of processes running on a container
docker top <container>
# Show a 'top' view of all docker containers
docker stats
# Show any files that have changed since startup
docker diff <container>
# Connect to an already running container
docker attach <container>
# Execute a command on a container
docker exec -it <container_id> /bin/bash
# Show docker system wide information
docker system info
# Show docker disk space used
docker system df

5: Docker Compose

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Start your docker-compose defined resources in detached mode
docker-compose up -d -f <docker_compose_yaml>
# Stop all docker-compose resources
docker-compose stop
# Destroy all docker-compose resources
docker-compose down
# Show docker-compose processes
docker-compose ps
# Show docker-compose logs
docker-compose logs
# Show docker-compose resource consumption
docker-compose top

01-docker-compose搭建redis cluster

docker-compose搭建redis cluster

一: Redis Cluster 集群

  • 在 Redis 中,集群的解决方案有三种
    • 1.主从复制
    • 2.哨兵机制
    • 3.Cluster

二: 主从复制模式

Redis 虽然读取写入的速度都特别快,但是也会产生读压力特别大的情况。为了分担读压力,Redis 支持主从复制,读写分离。一个 Master 可以有多个 Slaves。 redis-master-slave复制模式