1 ctrl+z後臺掛起
ctrl+c殺掉進程
jobs後臺進程
jobs -l顯示後臺進程且有進程號
(1) CTRL+Z掛起進程並放入後臺
(2) jobs 顯示當前暫停的進程
(3) bg %N 使第N個任務在後臺運行(%前有空格)
(4) fg %N 使第N個任務在前臺運行
==============================================
刪除目錄a下面所有文件及目錄,但是保留a空殼
rm -rf ./a/*
===============================================
1 Linux命令===========
查看某一個端口進程
netstat -nltp|grep 9999
ps -aux |grep 9999
2 查找文件=========
命令:grep [選項參數] “要查找的內容字符串" 路徑
-r :遞歸查找子目錄
-l :只顯示文件名
./ :當前目錄路徑
[root@-xl PythonTest]# grep -rl "python" ./
./stu.py
./gen.py
./test.py
./recursion.py
覺得不夠好,那就替換掉文件名前的路徑
[root@-xl PythonTest]# grep -rl "python" ./ |sed "s;./;;g"
stu.py
gen.py
test.py
recursion.py
3查找文件==========
ls -ll | grep -ER 'kafka'
(E代表正則匹配 R代表遞歸)
==============================
vim
1
vim行首行尾 shift 6 shift 4
1
a)某文件夾下有文件:vector.cc, substr.cc 使用vim命令打開任意一個文件:vim vector.cc打開第一個文件。
按:"Esc"鍵 + “:”,並輸入 :vsp substr.cc
b) 爲了讓鼠標可以在幾個屏幕間自由切換。
按:"Esc"鍵 + “:”,輸入:set mouse=a
1 光標在上面,shift # 選中單詞,搜索, 下一個, n
1 搜索字符串(3步)
shift +g (文檔最後) ? +字符串(搜索字符串) n (搜索下一個匹配項)
g+g(文檔最前) / +字符串(搜索字符串) n (搜索下一個匹配項)
vim shift 8 shift 3
notepad 後移:選中多行tab鍵
去掉後移:shift tab
=======================
vim set nu顯示行數
直接輸行數就可以了
=====================
查看制定端口進程
lsof -i:端口號
=========================
刪除操作:冒號輸入 2,18 d
刪除操作:ctrl+v 上線左右鍵 D鍵
添加操作:注意最後esc鍵之後要隨便按一個鍵
多行縮進縮出:ctrl+v 上線左右鍵 用>或<縮進或縮出到光標所在位置!!!
多行縮進縮出:ctrl+v 上線左右鍵 delete!!!
======================================================
vim選中多行縮進(python多行縮進)與刪除多行前面的空格
最近用vim寫python,有時候會在一段代碼前面套一個循環的操作,這個時候將這一段代碼整體向後平移四個空格,來滿足vim縮進的要求,如何做到這一點呢?
1. ESC之後,ctrl+v進入多行行首選中模式
2. 使用上下鍵進行上下移動,選中多行行首
3. shift+i,進入插入模式
4. 連續敲擊4個空格(注意在敲擊空格按鍵的時候,注意這個時候不能夠多行立即縮進,顯示的是僅僅一行進行縮進,在執行第五步的時候,纔會出現多行縮進的效果)
5. 然後按esc按鍵,即可發現,你選中的行都縮進了
有時候從別的地方拷貝一段代碼,粘貼到python代碼中,過於多行縮進,不夠美觀,這個時候需要選中多行,刪除多行前面的四個空格,方法也很簡單
1. ctrl+v進入塊模式,然後
=====================================================
查看佔用內存百分比最大的前幾個進程
ps aux|head -1
ps aux|grep -v PID|sort -rn -k +3|head
其中第一句主要是爲了獲取標題(USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND)。
接下來的grep -v PID是將ps aux命令得到的標題去掉,即grep不包含PID這三個字母組合的行,再將其中結果使用sort排序。
sort -rn -k +3該命令中的-rn的r表示是結果倒序排列,n爲以數值大小排序,而-k +3則是針對第3列的內容進行排序,再使用head命令獲取默認前10行數據。(其中的|表示管道操作)
===========================
內存大小
[root@xbidc ~]# cat /proc/meminfo |grep MemTotal
MemTotal: 1034612 kB
==================================
tar –czf jpg.tar.gz *.jpg //將目錄裏所有jpg文件打包成jpg.tar後,並且將其用gzip壓縮,生成一個gzip壓縮過的包,命名爲jpg.tar.gz
==================================
1=======================
yarn node -all -list
2==================zookeeper
/opt/zookeeper_3.4/bin/zkServer.sh start
3==============kafka
啓動Kafka服務
bin/kafka-server-start.sh config/server.properties
創建Topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
查看Topic
bin/kafka-topics.sh --list --zookeeper localhost:2181
產生消息
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
消費消息
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
刪除Topic
bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic test
查看描述 Topic 信息
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test
4===========================================================
/usr/bin/spark2-submit --jars /home/hadoopuser/zhangjin/elasticsearch-hadoop-jar/elasticsearch-hadoop-6.4.0.jar --master yarn --deploy-mode cluster --queue root.jiaoguan.xesoa /home/hadoopuser/zhangjin/ELK/elk.py $index $cur_date
4 新建索引
curl -XPUT http://10.97.14.131:9200/api_counselor_keep_day/ -d '{
"settings":{
"index":{
"number_of_shards":6,
"number_of_replicas":2
}
}
}'
4 測試環境新建索引及mapping映射
curl -XPUT http://10.97.14.131:9200/api_counselor_keep_day/all-type/_mapping -d '{
"properties": {
"counselor_id":{"type":"string","store":"yes","index": "not_analyzed"},
"counselor_name":{"type":"string","store":"yes","index": "not_analyzed"},
"date":{"type":"string","store":"yes","index": "not_analyzed"},
"year_id":{"type":"integer","store":"yes","index": "not_analyzed"},
"term_id":{"type":"integer","store":"yes","index": "not_analyzed"},
"datestamp":{"type":"integer","store":"yes","index": "not_analyzed"},
"level_1_id":{"type":"string","store":"yes","index": "not_analyzed"},
"level_2_id":{"type":"string","store":"yes","index": "not_analyzed"},
"level_3_id":{"type":"string","store":"yes","index": "not_analyzed"},
"group_id":{"type":"string","store":"yes","index": "not_analyzed"},
"normal_new_stu_renew_rate":{"type":"integer","store":"yes","index": "not_analyzed"},
"normal_renew_rate":{"type":"integer","store":"yes","index": "not_analyzed"},
"normal_today_renew_1":{"type":"integer","store":"yes","index": "not_analyzed"},
"normal_today_stu_num":{"type":"integer","store":"yes","index": "not_analyzed"},
"normal_renew_increase_num":{"type":"string","store":"yes","index": "not_analyzed"},
"normal_renew_increase_rate":{"type":"string","store":"yes","index": "not_analyzed"},
"fresh_new_stu_renew_rate":{"type":"integer","store":"yes","index": "not_analyzed"},
"fresh_renew_rate":{"type":"integer","store":"yes","index": "not_analyzed"},
"fresh_today_renew_1":{"type":"integer","store":"yes","index": "not_analyzed"},
"fresh_today_stu_num":{"type":"integer","store":"yes","index": "not_analyzed"},
"fresh_renew_increase_num":{"type":"string","store":"yes","index": "not_analyzed"},
"fresh_renew_increase_rate":{"type":"string","store":"yes","index": "not_analyzed"}
}
}'
後添加某個字段的命令
curl -XPUT http://10.97.14.131:9200/api_course_study_detail/all-type/_mapping -d '{
"properties": {
"refund_num":{"type":"string","store":"yes","index": "not_analyzed"},
"refund_rate":{"type":"string","store":"yes","index": "not_analyzed"}
}
}'
postman 添加doc必須要加上自己定義的id
(如果是自帶_update,那必須要加上doc關鍵字)
POST /website/blog/1/_update
{
"doc" : {
"tags" : "testing" ,
"views": 0
}
}
也可以這樣
POST /website/blog/1
{
"tags" : "testing" ,
"views": 0
}
=======================================
#querySql = '{"query":{"filtered":{"filter":{"bool":{"must":[{"term":{"counselor_id":"6728"}}]}}}},"aggs":{"all_interests":{"sum":{"field":"renew_1"}}}}'
=======================================
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [ { "terms": {
"class_id": [38664, 37214]
}
}
]
}
}
}
},
"aggs": {
"all_interests": {
"sum": {
"field": "renew_1"
}
}
},
"from": 0,
"size": 1
}