1、配置Kubectl
- 在Master上執行下面的命令來配置Kubectl
[root@k8s-master ~]# echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> /etc/profile
[root@k8s-master ~]# source /etc/profile
[root@k8s-master ~]# echo $KUBECONFIG
2、安裝Pod網絡
- 安裝Pod網絡是Pod之間進行通訊的必要條件,k8s支持衆多網絡方案,這裏咱們依然選用經典的flannel方案
- 首先是設置系統參數,主從都設置
[root@k8s-master bridge]# sysctl net.bridge.bridge-nf-call-iptables=1
kubectl apply -f kube-flannel.yaml
kubectl get pods --all-namespaces -o wide
3、安裝ElasticSearch集羣部署
[root@k8s-master ~]# mkdir /opt/elasticsearch
[root@k8s-master ~]# cd /opt/elasticsearch/
[root@k8s-master elasticsearch]# tar -zxvf elasticsearch-6.4.2.tar.1.gz
[root@k8s-node-1 elasticsearch]# cd elasticsearch-6.4.2//config
[root@k8s-master config]# vim elasticsearch.yml
cluster.name:ruigege #集羣名稱
node.name:ruigege1 #節點名
network.host:192.168.1.9 #綁定的節點1地址
network.bind_host:0.0.0.0 #不設置這個,本機可能不能訪問
discovery.zen.ping.unicast.hosts:["192.168.1.9","192.168.1.8"] #hosts列表
discovery.zen.minimum_master_nodes:1
#以下配置是爲了解決Elasticsearch可視化工具dejavu的跨域問題,若不使用可視化工具那麼就可忽略
http.port: 9200
http.cors.allow-origin:"http://192.168.199.76:1358"
http.cors.enabled:true
http.cors.allow-headers: X-Requested-With,X-Auth-Token,Content-Type,Content-Leng
th,Authorization
http.cors.allow-credentials:true
- 退出保存,而後設置一下節點2,只替換一下就好了
- 添加羣組,設置權限,關閉防火牆,開啓程序
[root@k8s-node-1 config]# groupadd es
[root@k8s-node-1 config]# useradd es -g es
[root@k8s-node-1 config]# cd ..
[root@k8s-node-1 elasticsearch-6.4.2]# cd ..
[root@k8s-node-1 elasticsearch]# chown -R es:es ./elasticsearch-6.4.2
[root@k8s-node-1 elasticsearch]# systemctl stop firewalld
[root@k8s-node-1 elasticsearch]# systemctl disable firewalld
[root@k8s-node-1 elasticsearch]# su es
[es@k8s-node-1 elasticsearch]$ cd elasticsearch-6.4.2/bin
[es@k8s-node-1 bin]$ ./elasticsearch
4、源碼: