mkdir vagrant
cd vagrant
mkdir node01
mkdir node02
mkdir node03
vagrant init
node01
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.hostname = "node01"
config.vm.network "private_network", ip: "10.1.100.11"
# 虚拟机配置
config.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = "1024"
vb.cpus = 2
end
# 初始化安装脚本
config.vm.provision "shell", inline: <<-SHELL
yum update
yum install -y vim wget
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
systemctl restart sshd
# 关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
# 关闭selinux
sed -i 's/enforcing/disabled/' /etc/selinux/config
# 转发流量到iptables
cat > /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
# 开启时间同步
yum install ntpdate -y
ntpdate time.windows.com
# 时区
timedatectl set-timezone Asia/Shanghai
# 安装lrzsz命令
yum install -y lrzsz
SHELL
end
node02
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.hostname = "node02"
config.vm.network "private_network", ip: "10.1.100.12"
# 虚拟机配置
config.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = "1024"
vb.cpus = 2
end
# 初始化安装脚本
config.vm.provision "shell", inline: <<-SHELL
yum update
yum install -y vim wget
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
systemctl restart sshd
# 关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
# 关闭selinux
sed -i 's/enforcing/disabled/' /etc/selinux/config
# 转发流量到iptables
cat > /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
# 开启时间同步
yum install ntpdate -y
ntpdate time.windows.com
# 时区
timedatectl set-timezone Asia/Shanghai
# 安装lrzsz命令
yum install -y lrzsz
SHELL
end
node03
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.hostname = "node03"
config.vm.network "private_network", ip: "10.1.100.13"
# 虚拟机配置
config.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = "1024"
vb.cpus = 2
end
# 初始化安装脚本
config.vm.provision "shell", inline: <<-SHELL
yum update
yum install -y vim wget
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
systemctl restart sshd
# 关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
# 关闭selinux
sed -i 's/enforcing/disabled/' /etc/selinux/config
# 转发流量到iptables
cat > /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
# 开启时间同步
yum install ntpdate -y
ntpdate time.windows.com
# 时区
timedatectl set-timezone Asia/Shanghai
# 安装lrzsz命令
yum install -y lrzsz
SHELL
end
默认密码:vagrant
vagrant up
三个节点都需要修改
10.1.100.11 node01
10.1.100.12 node02
10.1.100.13 node03
7.生成ssh密钥
ssh-keygen -t rsa
三个节点都需要执行
ssh-copy-id node01
ssh-copy-id node02
ssh-copy-id node03
ssh node01
ssh node02
ssh node03
tar -zxvf jdk-8u391-linux-x64.tar.gz
scp -r jdk1.8.0_391/ root@node02:/opt/
scp -r jdk1.8.0_391/ root@node03:/opt/
修改/etc/profile
export JAVA_HOME=/opt/jdk1.8.0_391
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile
java -version