搭建一個開源項目12-Kubernetes集羣部署(下)以及elasticsearch部署

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
  • 而後在Master節點上執行以下命令:
kubectl apply -f kube-flannel.yaml
kubectl get pods --all-namespaces -o wide

3、安裝ElasticSearch集羣部署

  • 推薦一個開源鏡像倉https://mirrors.huaweicloud.com/,華爲的開源鏡像倉,你們均可以進
  • 節點準備,這裏準備了兩個節點
  • 節點一:192.168.1.9;節點二:192.168.1.8
  • 下載elasticsearch,從開源鏡像倉,而後放到/opt/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、源碼:

相關文章
相關標籤/搜索