參考鏈接:https://docs.openshift.org/latest/install_config/install/advanced_install.html
主機(jī)準(zhǔn)備
類型 | 主機(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)開啟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依賴的軟件包肺缕。
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
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倉庫以安裝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)之間可以正常的訪問,需要生成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
安裝過程比較長坑匠,耐心等待验懊,一般情況都不會(huì)太順利吭服,會(huì)有錯(cuò)誤嚷堡,根據(jù)提示解決錯(cuò)誤后繼續(xù)執(zhí)行相同的命令安裝
遇到的問題:
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