OpenShift 命令行大全
2019-08-09 本文已影响0人
王彦锋BlackStone
-
获取某个分区指定的pod 名称(ES举例)
np="openshift-logging"; \
oc get pods -l component=es -o name -n $np |cut -d -f2
-
执行pod中某个容器的一键式命令
进入ES POD后,在容器elasticsearch中执行curl命令
np="openshift-logging"; \
oc exec `oc get pods -l component=es -o name -n $np |cut -d/ -f2` \
-c elasticsearch \
-n $np \
-- curl -v \
--head \
--cacert etc/elasticsearch/secret/admin-ca \
--cert etc/elasticsearch/secret/admin-cert \
--key etc/elasticsearch/secret/admin-key \
https//:localhost:9200/
进入kibana POD,在容器kibana中执行curl命令
np="openshift-logging"; \
oc exec `oc get pods -l component=kibana-ops -o name -n $np |cut -d/ -f2` \
-c kibana \
-n $np \
-- curl -s \
--cacert /etc/kibana/keys/ca \
--cert /etc/kibana/keys/cert \
--key /etc/kibana/keys/key \
https://logging-es:9200/
-
ElasticSearch 集群管理
查看集群状态
np="openshift-logging"; \
oc exec `oc get pods -l component=es -o name -n $np |cut -d/ -f2` \
-c elasticsearch \
-n $np \
-- curl -s \
--cacert /etc/elasticsearch/secret/admin-ca \
--cert /etc/elasticsearch/secret/admin-cert \
--key /etc/elasticsearch/secret/admin-key \
https://localhost:9200/_cluster/health?pretty=true
查看索引状态
np="openshift-logging"; \
oc exec `oc get pods -l component=es -o name -n $np |cut -d/ -f2` \
-c elasticsearch \
-n $np \
-- curl -s \
--cacert /etc/elasticsearch/secret/admin-ca \
--cert /etc/elasticsearch/secret/admin-cert \
--key /etc/elasticsearch/secret/admin-key \
https://localhost:9200/_cat/indices?v
设置集群索引为无副本,防止单节点集群出现“unassigned_shards>0”的情况发生
np="openshift-logging"; \
oc exec `oc get pods -l component=es -o name -n $np |cut -d/ -f2` \
-c elasticsearch \
-n $np \
-- curl -s \
--cacert /etc/elasticsearch/secret/admin-ca \
--cert /etc/elasticsearch/secret/admin-cert \
--key /etc/elasticsearch/secret/admin-key \
-H "Content-Type: application/json" \
-XPUT 'https://localhost:9200/_settings' \
-d '{
"index" : {
"number_of_replicas" : 0
}
}'