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

Docker

Redis

  • redis安装
docker pull redis:3.2
  • Redis运行
~/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端链接容器内部
docker exec -it 43f7a65ec7f8 redis-cli
  • 查看容器运行状况
docker ps

MySQL

  • Mysql 运行
docker run --name mysql -e MYSQL_ROOT_PASSWORD=admin -p 3306:3306 -d mysql:5.7.21
  • 链接MySQL
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 启动
# 不带验证
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
  • 用户初始化
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 安装
docker pull wurstmeister/kafka:0.10.0.1
  • Kafka 启动
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
docker run -itd \
--restart=always \
--name=kafka-manager \
-p 9000:9000 \
-e ZK_HOSTS="192.168.214.220:2181" \
sheepkiller/kafka-manager

ZooKeeper

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

Druid-Imply

  • Imply
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:

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

docker-compose up

RabbitMQ

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

Database

MySQL

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

MongoDB

  • 插入多条
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" ] }
]);
  • 查找全部
db.inventory.find( {} )
  • 查找过滤条件
db.inventory.find( { status: "D" } )
  • 条件查找
db.inventory.find( { size: { h: 14, w: 21, uom: "cm" } } )
db.inventory.find( { "size.uom": "in" } )
  • 选择DB
use myDB
  • 创建DB
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
db.myNewCollection2.insertOne( { x: 1 } )
db.myNewCollection3.createIndex( { y: 1 } )
  • 按ObjectId查询
db.advertisement.find({"_id" : ObjectId("5b1f6e0fc365845f49a4ec2c")})
  • 创建唯一索引
db.advertisement.ensureIndex({"name":1,"productId":1},{"unique":true})
  • Mongo数据导出
mongodump -u shuai -p admin -d attr -o attr
mongodump -u clink -p Centrix5438 -d api_attr -c click --archive=click.archive --gzip
  • Mongo数据导入
./bin/mongoimport --host localhost --port 27017 --db dbname --collection collectionName --username root --password pwd  <  mongo.json
mongorestore -u shuai -p admin --db dashboard --dir data/db/dashboard

Platform

Linux

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

-h 关机
-t 延时多少s

  • Hosname修改
hostnamectl set-hostname <newhostname>

Windows

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

Mac

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

MQ

RabbitMQ

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

Kafka-Manager

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

BigData

Imply

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

Hadoop

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

Hive

  • 查看表

    show tables;
  • 查看表结构

    desc tableName;
  • 查看表分区

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

    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登录

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

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

阿里云

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

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

    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. 启动代理

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

    /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

  • 分支切换
flutter channel dev
flutter channel master
flutter channel beta
flutter channel stable
  • 升级
flutter upgrade

Project

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

Plugin

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

Icon

  • 生成icon
flutter pub run flutter_launcher_icons:main

Desktop

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

Code

  • 开启边界模式
import 'package:flutter/rendering.dart';

void main() {
debugPaintSizeEnabled = true;
runApp(XXX());
}

Build

android
  • app bundle
cd <app dir>

flutter build appbundle
  • apk
cd <app dir>

flutter build apk

flutter install
ios

go-flutter

Plugin
  • 插件初始化
hover init
  • 插件获取
hover plugins get
  • 插件发布
hover plugins
  • 开发一个完整插件
# 创建
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
  • 初始化
hover init-packaging darwin-dmg
  • 构建
hover build darwin-dmg