sh git repo特定用户:传递

克隆git repo与特定用户:pass

u.bash
git remote set-url origin https://name:password@github.com/repo.git

sh django_shell

django_shell.sh
pip install django-extensions

pip install ipython

echo "SHELL_PLUS = 'ipython'" >> project/settings.py

 python manage.py shell

sh Nifi Docker

nifi
docker run --name nifi \
  -p 9090:9090 \
  -d \
  -e NIFI_WEB_HTTP_PORT='9090' \
  apache/nifi:latest

sh sqlite3 linux

sqlite3.sh
# show tables
.tables

# show strucure of table
.schema table

# insert row
INSERT INTO table (column1,column2 ,..) VALUES( value1,    value2 ,...);

# show headers by default
.headers on

# create table
CREATE TABLE CPU_Usage (Date datetime, CPU_Index int, Average_IDLE int);

# add column to table
ALTER TABLE {tableName} ADD COLUMN COLNew {type};

# alter table name
ALTER TABLE tab RENAME TO tab_new;

# delete table
DROP TABLE TempOldTable;

# quit
.quit

sh .inputrc文件

.inputrc
echo "set completion-ignore-case On" >> ~/.inputrc

sh 如何连接数据库?

how_to_connect_a_dabase.sh
use dataBaseName

sh 显示数据库

show_databases.sh
show dbs

sh 在Docker中安装Prometheus和Grafana

docker-compose.yml
# docker-compose.yml
version: '2'
services:
    prometheus:
        image: prom/prometheus:0.18.0
        volumes:
            - ./prometheus.yml:/etc/prometheus/prometheus.yml
            - prometheus_data:/prometheus
        command:
            - '-config.file=/etc/prometheus/prometheus.yml'
        ports:
            - '9090:9090'
    node-exporter:
        image: prom/node-exporter
        ports:
            - '9100:9100'
    grafana:
            image: grafana/grafana
            environment:
                - GF_SECURITY_ADMIN_PASSWORD=pass
            depends_on:
                - prometheus
            ports:
                - "3000:3000"
volumes:
        prometheus_data: {}
prometheus.yml
# prometheus.yml
global:
    scrape_interval: 5s
    external_labels:
        monitor: 'my-monitor'
scrape_configs:
    - job_name: 'prometheus'
      target_groups:
          - targets: ['localhost:9090']
    - job_name: 'node-exporter'
      target_groups:
          - targets: ['192.168.10.166:9100']
run_docker_compose.sh
#!/bin/bash

docker-compose up -d

sh MySQL Tunner

run.sh
#!/bin/bash

curl -O https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
chmod +x mysqltuner.pl
./mysqltuner.pl

sh MySQL性能与mysqlslap

test_mysql.sh
#!/bin/bash

export MYSQL_USER="root"
export MYSQL_PASSWORD="root123."

# 单线程测试。测试做了什么。
mysqlslap -a -u$MYSQL_USER -p$MYSQL_PASSWORD
 
# 多线程测试。使用–concurrency来模拟并发连接。
mysqlslap -a -c 100 -u$MYSQL_USER -p$MYSQL_PASSWORD
 
# 迭代测试。用于需要多次执行测试得到平均值。
mysqlslap -a -i 10 -u$MYSQL_USER -p$MYSQL_PASSWORD
 
mysqlslap ---auto-generate-sql-add-autoincrement -a -u$MYSQL_USER -p$MYSQL_PASSWORD
mysqlslap -a --auto-generate-sql-load-type=read -u$MYSQL_USER -p$MYSQL_PASSWORD
mysqlslap -a --auto-generate-secondary-indexes=3 -u$MYSQL_USER -p$MYSQL_PASSWORD
mysqlslap -a --auto-generate-sql-write-number=1000 -u$MYSQL_USER -p$MYSQL_PASSWORD
mysqlslap --create-schema world -q "select count(*) from City" -u$MYSQL_USER -p$MYSQL_PASSWORD
mysqlslap -a -e innodb -u$MYSQL_USER -p$MYSQL_PASSWORD
mysqlslap -a --number-of-queries=10 -u$MYSQL_USER -p$MYSQL_PASSWORD
 
# 测试同时不同的存储引擎的性能进行对比:
mysqlslap -a --concurrency=50,100 --number-of-queries 1000 --iterations=5 --engine=myisam,innodb --debug-info -u$MYSQL_USER -p$MYSQL_PASSWORD
 
# 执行一次测试,分别50和100个并发,执行1000次总查询:
mysqlslap -a --concurrency=50,100 --number-of-queries 1000 --debug-info -u$MYSQL_USER -p$MYSQL_PASSWORD
 
# 50和100个并发分别得到一次测试结果(Benchmark),并发数越多,执行完所有查询的时间越长。为了准确起见,可以多迭代测试几次:
mysqlslap -a --concurrency=50,100 --number-of-queries 1000 --iterations=5 --debug-info -u$MYSQL_USER -p$MYSQL_PASSWORD