整理一个用过的命令的地方,方便自己,也方便他人吧

Docker

Redis

  • redis安装
1
docker pull redis:3.2
  • Redis运行
1
~/redis$ docker run -p 6379:6379 -v $PWD/data:/data  -d redis:3.2 redis-server --appendonly yes

-p 6379:6379 : 将容器的6379端口映射到主机的6379端口

-v $PWD/data:/data : 将主机中当前目录下的data挂载到容器的/data

redis-server --appendonly yes : 在容器执行redis-server启动命令,并打开redis持久化配置

  • 用redis-client端链接容器内部
1
docker exec -it 43f7a65ec7f8 redis-cli
  • 查看容器运行状况
1
docker ps

MySQL

  • Mysql 运行
1
docker run --name mysql -e MYSQL_ROOT_PASSWORD=admin -p 3306:3306 -d mysql:5.7.21
  • 链接MySQL
1
2
3
4
docker run -it --rm \
--link mysql:mysql \
mysql \
sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'

Mongo

  • Mongo 启动
1
2
3
4
5
6
# 不带验证
docker run -p 27017:27017 -v $PWD/db:/data/db -d mongo:3.6.3

# 带验证
docker run -p 27017:27017 -v $PWD/db:/data/db -d mongo:3.6.3 --auth
docker exec -it 8a00b0e0b75b mongo admin
  • 用户初始化
1
2
3
4
5
6
7
8
9
10
11
12
mongo
use admin
db.createUser({ user: 'shuai', pwd: 'admin', roles: [ { role: "root", db: "admin" } ] });
db.auth("shuai","admin")
use dspDashboard
db.createUser(
{
user: "shuai",
pwd: "admin",
roles: [ "readWrite", "dbAdmin" ]
}
)

Kafka

  • Kafka 安装
1
docker pull wurstmeister/kafka:0.10.0.1
  • Kafka 启动
1
2
3
4
5
6
7
docker run --name kafka \
-p 9092:9092 \
-e KAFKA_ADVERTISED_HOST_NAME=mine \
-e KAFKA_ADVERTISED_PORT=9092 \
-e KAFKA_CREATE_TOPICS="test:1:1" \
-e KAFKA_ZOOKEEPER_CONNECT=192.168.214.220:2181 \
-d wurstmeister/kafka:0.10.0.1
  • Kafka Manager
1
2
3
4
5
6
docker run -itd \
--restart=always \
--name=kafka-manager \
-p 9000:9000 \
-e ZK_HOSTS="192.168.214.220:2181" \
sheepkiller/kafka-manager

ZooKeeper

  • ZooKeeper 安装
1
docker pull zookeeper
  • Zookeeper 启动
1
2
3
4
docker run --name some-zookeeper \
--restart always \
-p 2181:2181 \
-d zookeeper

Druid-Imply

  • Imply
1
2
docker run -p 8081-8110:8081-8110 -p 8200:8200 -p 9095:9095 -d --name imply imply/imply
docker exec -it imply bin/post-index-task -f quickstart/wikiticker-index.json
  • Docker-Compose

docker-compose.yml:

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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
version: '2'
services:
zookeeper:
image: wurstmeister/zookeeper ## 镜像
ports:
- "2181:2181" ## 对外暴露的端口号
kafka:
image: wurstmeister/kafka ## 镜像
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: localhost ## 修改:宿主机IP
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 ## 卡夫卡运行是基于zookeeper的
kafka_manager:
image: hlebalbau/kafka-manager:latest
ports:
- "9000:9000"
environment:
ZK_HOSTS: "zookeeper:2181"
APPLICATION_SECRET: "random-secret"
command: -Dpidfile.path=/dev/null


version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper ## 镜像
ports:
- "2181:2181" ## 对外暴露的端口号
kafka:
image: wurstmeister/kafka ## 镜像
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: localhost ## 修改:宿主机IP
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 ## 卡夫卡运行是基于zookeeper的
kafka_manager:
image: hlebalbau/kafka-manager:latest
ports:
- "9000:9000"
environment:
ZK_HOSTS: "zookeeper:2181"
APPLICATION_SECRET: "random-secret"
command: -Dpidfile.path=/dev/null
volumes:
- /var/run/docker.sock:/var/run/docker.sock
imply:
image: imply/imply
ports:
- "2182:2181"
- "8081-8110:8081-8110"
- "8200:8200"
- "9095:9095"
links:
- kafka
volumes:
- /var/run/docker.sock:/var/run/docker.sock

run

1
docker-compose up

RabbitMQ

  • RabbitMQ
1
docker run -d -p 15672:15672  -p  5672:5672  -v $PWD/rabbitmq:/var/lib/rabbitmq  --name rabbitmq rabbitmq:management

Database

MySQL

  • 允许外部访问
1
grant all privileges on *.* to 'root'@'%' identified by 'admin';
  • 查看编码
1
show variables like 'character%';

MongoDB

  • 插入多条
1
2
3
4
5
6
7
8
9
10
11
12
13
db.inventory.insertMany([
// MongoDB adds the _id field with an ObjectId if _id is not present
{ item: "journal", qty: 25, status: "A",
size: { h: 14, w: 21, uom: "cm" }, tags: [ "blank", "red" ] },
{ item: "notebook", qty: 50, status: "A",
size: { h: 8.5, w: 11, uom: "in" }, tags: [ "red", "blank" ] },
{ item: "paper", qty: 100, status: "D",
size: { h: 8.5, w: 11, uom: "in" }, tags: [ "red", "blank", "plain" ] },
{ item: "planner", qty: 75, status: "D",
size: { h: 22.85, w: 30, uom: "cm" }, tags: [ "blank", "red" ] },
{ item: "postcard", qty: 45, status: "A",
size: { h: 10, w: 15.25, uom: "cm" }, tags: [ "blue" ] }
]);
  • 查找全部
1
db.inventory.find( {} )
  • 查找过滤条件
1
db.inventory.find( { status: "D" } )
  • 条件查找
1
2
db.inventory.find( { size: { h: 14, w: 21, uom: "cm" } } )
db.inventory.find( { "size.uom": "in" } )
  • 选择DB
1
use myDB
  • 创建DB
1
2
use diyishuai
db.student.insertOne({"name":"diyishuai","age":25,"girls":[{"name":"tomato","age":18},{"name":"vivian","age":20}]})
The insertOne() operation creates both the database myNewDB and the collection myNewCollection1 if they do not already exist.
  • 创建collection
1
2
db.myNewCollection2.insertOne( { x: 1 } )
db.myNewCollection3.createIndex( { y: 1 } )
  • 按ObjectId查询
1
db.advertisement.find({"_id" : ObjectId("5b1f6e0fc365845f49a4ec2c")})
  • 创建唯一索引
1
db.advertisement.ensureIndex({"name":1,"productId":1},{"unique":true})
  • Mongo数据导出
1
2
mongodump -u shuai -p admin -d attr -o attr
mongodump -u clink -p Centrix5438 -d api_attr -c click --archive=click.archive --gzip
  • Mongo数据导入
1
./bin/mongoimport --host localhost --port 27017 --db dbname --collection collectionName --username root --password pwd  <  mongo.json
1
mongorestore -u shuai -p admin --db dashboard --dir data/db/dashboard

Platform

Linux

  • 端口占用查看
1
lsof -i:3306
  • 关机
1
shutdown -h -t 10

-h 关机
-t 延时多少s

Windows

  • 关机
1
shutdown -s -t 10
  • 端口查看
1
netstat -ano

Mac

  • 关机
1
osascript -e 'tell app "System Events" to shut down'
1
sudo shutdown -h 22:30
  • base64 encode
1
cat file | base64
  • base64 decode
1
cat file | base64 --decode

MQ

RabbitMQ

  • 添加远程用户
    1
    2
    3
    rabbitmqctl add_user root centirxlink123
    rabbitmqctl set_user_tags root administrator
    rabbitmqctl set_permissions -p / root ".*" ".*" ".*"

Kafka-Manager

  • run
1
nohup bin/kafka-manager -Dconfig.file=conf/application.conf -Dhttp.port=9000 &

BigData

Imply

  • 启动
    1
    bin/supervise -c conf/supervise/quickstart.conf

Hadoop

  • 授权
    1
    hdfs dfs -chown root:hdfs  /user

Hive

  • 查看表

    1
    show tables;
  • 查看表结构

    1
    desc tableName;
  • 查看表分区

    1
    show partitions tableName;
  • 从分区中查询数据

    1
    2
    3
    4
    5
    6
    7
    8
    9
    1:
    hive (DTS_DEV)> show partitions t_ut_raw_imp_log;
    OK
    partition
    pt=2019-02-18
    pt=2019-03-03

    2:
    select * from t_ut_raw_imp_log where pt='2019-03-03' limit 10;

云平台

腾讯云

  • ssh登录

    1
    ssh -i ~/.ssh/CentrixlinkMac root@di1shuai
  • Scp文件传输

    1
    scp -i ~/.ssh/CentrixlinkMac knife-1.0.jar root@di1shuai:/tmp

阿里云

  • 访问Hadoop、Spark等WEB-UI
  1. Copy自己的公钥到阿里云

    1
    2
    自己的公钥path:~/.ssh/id_rsa.pub
    阿里云验证path:/root/.ssh/authorized_keys
  2. 配置自己本地的ssh

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    vi .ssh/config

    Host jms
    HostName jms.xxx.com
    User username
    Port 4500

    Host emr
    HostName hxxx.oxxx.sxxx.txxx
    DynamicForward 3128
    User root
    Port 22

    Host druid-master-1
    HostName hxxx.oxxx.sxxx.txxx
    DynamicForward 3128
    User root
    Port 22
  3. 启动代理

    1
    2
    3
    nohup ssh  -ND 8157 emr &
    nohup ssh -ND 8158 druid-master-1 &
    nohup ssh -ND 8159 us-hdfs-header-1 &
  4. 启动代理chrome

    1
    2
    3
    4
    5
    /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome  Chrome --proxy-server="socks5://localhost:8157" --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE localhost" --user-data-dir=/tmp/

    /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome Chrome --proxy-server="socks5://localhost:8158" --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE localhost" --user-data-dir=/tmp/

    /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome Chrome --proxy-server="socks5://localhost:8159" --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE localhost" --user-data-dir=/tmp/
  5. 访问http://localhost:8088or50070

前端

Flutter

  • 分支切换
1
2
3
4
flutter channel dev
flutter channel master
flutter channel beta
flutter channel stable
  • 升级
1
flutter upgrade

Project

  • 创建项目
1
flutter create --org com.example --android-language java project_name

Plugin

  • 创建插件项目
1
flutter create --org com.example --template=plugin test_hover
  • 初始化插件
1
hover init-plugin github.com/my-organization/test_hover
  • 插件发布检查
1
flutter packages pub publish --dry-run
  • 插件发布
1
flutter packages pub publish

Icon

  • 生成icon
1
flutter pub run flutter_launcher_icons:main

Desktop

Macos
  • 启用macos
1
flutter config --enable-macos-desktop

Build

android
  • app bundle
1
2
3
cd <app dir>

flutter build appbundle
  • apk
1
2
3
4
5
cd <app dir>

flutter build apk

flutter install
ios

go-flutter

Plugin
  • 插件初始化
1
hover init
  • 插件获取
1
hover plugins get
  • 插件发布
1
hover plugins
  • 开发一个完整插件
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
# 创建
flutter create --org com.example --template=plugin test_hover

# 初始化
cd test_hover
# test_hover/
hover init-plugin github.com/my-organization/test_hover

# 插件开发
cd go
# test_hover/go

# 运行示例
cd ../example
# test_hover/example
flutter build bundle
hover init
hover plugins get
yes | hover run

# tag发布
cd ..
# test_hover
hover publish-plugin

# flutter发布

# test_hover
flutter packages pub publish --dry-run
flutter packages pub publish
Build
Mac
  • 初始化
1
hover init-packaging darwin-dmg
  • 构建
1
hover build darwin-dmg