1. 修改主机名
确定主机名配置是否正确,可用hostnamectl修改主机名
# hostnamectl set-hostname master.example.com
2. 启动网卡端口
# vi /etc/sysconfig/network-scripts/ifcfg-ens33
修改ONBOOT=yes
重启网卡systemctl restart network
3. 修改各节点/etc/host文件
192.168.64.146 node1.example.com
192.168.64.147 master.example.com
4. 开启selinux和关闭防火墙
SELINUX=enforcing
SELINUXTYPE=targeted
systemctl stop firewalld
systemctl disabled firewalld
一、安装基础包
1. 安装一下基本软件包
# yum install wget git net-tools bind-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct
2. 将系统更新到最新的软件包:
# yum update
二、准备进行高级安装
如果你打算使用containerized installer来运行高级安装
1. 安装atomic包
# yum install atomic
2. 安装Docker
如果你打算使用 RPM-based installer来运行高级安装
1. 安装Ansible
a. 安装EPEL存储库:
# yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
b. 全局禁用EPEL存储库,以便在安装的后续步骤中不会意外使用它:
# sed -i -e "s/^enabled=1/enabled=0/" /etc/yum.repos.d/epel.repo
c. 安装Ansible的软件包:
# yum -y --enablerepo=epel install ansible pyOpenSSL
2. 从GitHub 克隆openshift / openshift-ansible存储库,它提供了所需的剧本和配置文件:
# cd〜
# git clone https://github.com/openshift/openshift-ansible
# cd openshift-ansible
#git checkout release-3.6
三、安装Docker
# yum install docker
验证版本
# rpm -V docker
# docker version
四、配置Docker存储
1. 创建docker-pool卷
A. use an additional block device (建议选A)
[root@master ~]# vi /etc/sysconfig/docker-storage-setup
DEVS=/dev/sdb
VG=docker-vg
运行docker-storage-setup并查看输出以确保docker-pool卷已创建:
# docker-storage-setup
B. Use an existing, specified volume group
[root@master ~]# vi /etc/sysconfig/docker-storage-setup
VG=docker-vg
# docker-storage-setup
C. Use the remaining free space from the volume group where your root file system is located.
# docker-storage-setup
2. 查看配置是否生效。在/ etc / sysconfig / docker -storage文件和docker-pool逻辑卷中应该有一个dm.thinpooldev值 :
[root@master ~]# cat /etc/sysconfig/docker-storage
[root@master ~]# lvs
3. 检查Docker是否正在运行:
# systemctl is-active docker
# systemctl enable docker
# systemctl start docker
如果Docker已经在运行,重新初始化Docker:
# systemctl stop docker
# rm -rf / var / lib / docker / *
# systemctl restart docker
五、安装etcd(数据库,master控制数据放在其中,减少对master的请求)
# yum -y install etcd
# systemctl enable etcd
# systemctl start etcd
六、实现SSH无密钥主机访问
# ssh-keygen -f /root/.ssh/id_rsa -N ''
# for host in master.example.com \
node1.example.com; \
do ssh-copy-id -i ~/.ssh/id_rsa.pub $host; \
done
高级安装
一、 配置Ansible文件
1. 配置/etc/ansible/hosts
## 备份原生hosts文件,另存为hosts.org
# mv -f /etc/ansible/hosts /etc/ansible/hosts.org
##新创建一个文件
# touch /etc/ansible/hosts
# vi /etc/ansible/hosts
2. 运行高级安装
# ansible-playbook /root/openshift-ansible/playbooks/byo/config.yml
# ansible-playbook /root/openshift-ansible/playbooks/adhoc/uninstall.yml (卸载节点)
failed=0表示没有出现报错,安装成功。
二、 验证安装
# oc get nodes
# oc get nodes -o wide
# oc whoami 可以看到当前是以管理员的权限登录的集群。
# oc get all -o wide 查看资源列表。
# oc get pod --all-namespaces 查看各个组件
验证Web控制台是否安装正确
# https://master.example.com:8443/console