基于Centos:服务器基础环境安装: JDK、Maven、Python、Go、Docker、K8s

创建用户

shell 复制代码
useradd dev
groupadd op
chown -R :op /opt
chmod -R 770 /opt
usermod -aG op dev

JDK8

shell 复制代码
yum install -y  java-1.8.0-openjdk-devel
echo '
export JAVA_HOME=/usr/lib/jvm/java-1.8.0/
' >> /etc/profile

source /etc/profile

JDK11

shell 复制代码
yum install -y java-11-openjdk-devel.x86_64

echo '
export ES_JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.19.0.7-1.el7_9.x86_64
export LS_JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.19.0.7-1.el7_9.x86_64
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.19.0.7-1.el7_9.x86_64
' >> /etc/profile

source /etc/profile

maven

shell 复制代码
yum install -y maven

echo '<?xml version="1.0" encoding="UTF-8"?>
      <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
          <mirrors>
              <mirror>
                  <id>ali-maven</id>
                  <mirrorOf>*</mirrorOf>
                  <name>ali mirror</name>
                  <url>https://maven.aliyun.com/nexus/content/groups/public</url>
              </mirror>
          </mirrors>
      </settings>' > /etc/maven/settings.xml

Python3

shell 复制代码
yum install -y python3 python3-pip

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

Go

shell 复制代码
yum install -y epel-release golang
go version

NodeJS

shell 复制代码
curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash -
yum install -y nodejs

其它工具

shell 复制代码
yum install -y htop zip unzip git

Docker

shell 复制代码
yum -y remove docker-*
yum -y remove containerd*
rm -rf /var/lib/docker

yum list installed |grep docker
rpm -qa |grep docker


sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

sudo yum install -y yum-utils
sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

sudo yum install -y docker-ce-20.10.1 docker-ce-cli-20.10.1 containerd.io docker-compose-plugin

sudo systemctl start docker
sudo systemctl enable docker

Kubernetes

首先设置hostname 和hosts文件

shell 复制代码
hostnamectl set-hostname master
hostnamectl set-hostname node01
hostnamectl set-hostname node02

echo '
172.17.12.218 master
172.17.12.216 node01
172.17.12.217 node02' >> /etc/hosts

配置防火墙和网络

shell 复制代码
systemctl stop firewalld && systemctl disable firewalld
sed -i 's/enforcing/disabled/' /etc/selinux/config && setenforce 0
swapoff -a
sed -ri 's/.*swap.*/#&/' /etc/fstab

cat > /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF

sysctl --system

安装kubeadm

shell 复制代码
cat > /etc/yum.repos.d/kubernetes.repo << EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

yum install -y kubelet-1.23.0 kubeadm-1.23.0 kubectl-1.23.0
systemctl enable kubelet

主节点初始化

shell 复制代码
kubeadm init \
  --kubernetes-version 1.23.0 \
  --apiserver-advertise-address=0.0.0.0 \
  --service-cidr=10.96.0.0/16 \
  --pod-network-cidr=10.244.0.0/16 \
  --image-repository registry.aliyuncs.com/google_containers

主节点安装网络插件

shell 复制代码
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

从节点执行主节点初始化完成后输出的token信息加入主节点即可;

相关推荐
星就前端叭33 分钟前
【开源】一款基于SpringBoot的智慧小区物业管理系统
java·前端·spring boot·后端·开源
带刺的坐椅33 分钟前
RxSqlUtils(base R2dbc)
java·reactor·solon·r2dbc
上海运维Q先生1 小时前
面试题整理19----Metric的几种类型?分别是什么?
运维·服务器·面试
silence2501 小时前
深入了解 Reactor:响应式编程的利器
java·spring
weixin_SAG1 小时前
21天掌握javaweb-->第19天:Spring Boot后端优化与部署
java·spring boot·后端
m0_748247551 小时前
SpringMVC跨域问题解决方案
java
Elcker1 小时前
KOI技术-事件驱动编程(Sping后端)
java·spring·架构
GitNohup1 小时前
Spring boot处理跨域问题
java·spring boot·跨域
Just_Paranoid1 小时前
使用 IDE生成 Java Doc
java·开发语言·ide
西海天际蔚蓝1 小时前
递归查询全量分页数据问题
java