ansible安裝多節(jié)點(diǎn) openshift 3.7集群

參考鏈接:https://docs.openshift.org/latest/install_config/install/advanced_install.html

主機(jī)準(zhǔn)備

類(lèi)型 主機(jī)名 IP 操作系統(tǒng) CPU 內(nèi)存
Master master.rabbit.com 192.168.8.207 CentOS 7.3 2核4G
Node1 node1.rabbit.com 192.168.8.208 CentOS 7.3 2核2G

安裝前預(yù)配置 所有節(jié)點(diǎn)都要執(zhí)行

1. 配置每個(gè)節(jié)點(diǎn)主機(jī)名
hostnamectl set-hostname master.rabbit.com  #master節(jié)點(diǎn)執(zhí)行
hostnamectl set-hostname node1.rabbit.com   #node1節(jié)點(diǎn)執(zhí)行
2. 編輯每個(gè)節(jié)點(diǎn) /etc/hosts
192.168.8.207 master.rabbit.com
192.168.8.208 node1.rabbit.com

ping 每個(gè)節(jié)點(diǎn)看是否可到達(dá)

3. 每個(gè)節(jié)點(diǎn)開(kāi)啟SELinux
configure SELINUXTYPE=targeted in the /etc/selinux/config file:

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
4. 關(guān)閉所有節(jié)點(diǎn)的防火墻
systemctl stop firewalld
systemctl disable firewalld

安裝及配置軟件包

1. 所有的節(jié)點(diǎn)下執(zhí)行以下命令安裝Openshift依賴(lài)的軟件包。
yum install wget git net-tools bind-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct
yum update
2. 安裝docker 配置阿里云加速器
yum install -y docker
systemctl enable docker

參考鏈接:http://blog.xianshiyue.com/%E5%AE%89%E8%A3%85docker/

3. Configuring Docker Storage

參考鏈接:http://blog.xianshiyue.com/docker-storage-setup-%E9%85%8D%E7%BD%AEdocker-%E5%90%8E%E7%AB%AF%E5%AD%98%E5%82%A8/

4. 配置 Docker Container Logs

參考鏈接:http://blog.xianshiyue.com/docker-log-%E9%85%8D%E7%BD%AE/

5. 啟動(dòng) docker
    systemctl start docker

后面的步驟都在master節(jié)點(diǎn)上執(zhí)行

6. 需要啟用EPEL倉(cāng)庫(kù)以安裝Ansible
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sed -i -e "s/^enabled=1/enabled=0/" /etc/yum.repos.d/epel.repo
yum -y --enablerepo=epel install ansible pyOpenSSL
7. 下載 openshift-ansible ,我這里下載3.7 版本

地址:https://github.com/openshift/openshift-ansible

8. 確保所有的節(jié)點(diǎn)之間可以正常的訪問(wèn),需要生成SSH密鑰
ssh-keygen
for host in master.rabbit.com node1.rabbit.com ;do ssh-copy-id -i ~/.ssh/id_rsa.pub $host;done

配置Ansible

配置Ansible的hosts配置文件(記錄了Ansible需要操作的目標(biāo)主機(jī)信息)。

1. 備份原有的hosts文件
mv -f /etc/ansible/hosts /etc/ansible/hosts.org
2. 創(chuàng)建/etc/ansible/hosts文件,添加下面的內(nèi)容。
# Create an OSEv3 group that contains the masters, nodes, and etcd groups
[OSEv3:children]
masters
nodes
etcd

# Set variables common for all OSEv3 hosts
[OSEv3:vars]
# SSH user, this user should allow ssh based auth without requiring a password
ansible_ssh_user=root

# If ansible_ssh_user is not root, ansible_become must be set to true
#ansible_become=true
openshift_release=3.7.0
openshift_deployment_type=origin
openshift_disable_check=disk_availability,docker_storage,memory_availability,docker_image_availability,package_version,package_availability
# uncomment the following to enable htpasswd authentication; defaults to DenyAllPasswordIdentityProvider
openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider', 'filename': '/etc/origin/master/htpasswd'}]

# host group for masters
[masters]
master.rabbit.com

# host group for etcd
[etcd]
master.rabbit.com

# host group for nodes, includes region info
[nodes]
master.rabbit.com openshift_schedulable=True openshift_node_labels="{'region': 'infra'}"
node1.rabbit.com openshift_node_labels="{'region': 'infra', 'zone': 'east'}"

執(zhí)行安裝

ansible-playbook ~/openshift-ansible-openshift-ansible-3.7.22-1/playbooks/byo/config.yml

安裝過(guò)程比較長(zhǎng),耐心等待,一般情況都不會(huì)太順利,會(huì)有錯(cuò)誤,根據(jù)提示解決錯(cuò)誤后繼續(xù)執(zhí)行相同的命令安裝


遇到的問(wèn)題:

1. Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#56 - "Recv failure: Connection reset by peer"

處理參考鏈接
http://blog.csdn.net/dmt742055597/article/details/78580008?locationNum=10&fps=1
http://blog.xianshiyue.com/centos-%E6%B7%BB%E5%8A%A0yum%E6%BA%90/
http://www.itdadao.com/articles/c15a681465p0.html

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容