机器初始化 (一)

发表于 Kubernetes 分类,标签:

可参考

http://choerodon.io/zh/docs/installation-configuration/steps/kubernetes/


# 更换阿里云yum源

yum -y install wget curl
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/* /etc/yum.repos.d/bak/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache

# 关闭selinux

sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
setenforce 0

# 关闭不必要的服务

systemctl stop rpcbind.socket
systemctl stop rpcbind
systemctl disable rpcbind.socket
systemctl disable rpcbind
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl stop postfix.service
systemctl disable postfix.service
systemctl stop chronyd.service
systemctl disable chronyd.service


# 修改主机名

hostnamectl --static set-hostname $1

# 修改网卡名称

device_name=eth
i=0
ls /etc/sysconfig/network-scripts/ifcfg-* |grep -v ifcfg-lo |sort -n |while read line
do
   if [ "$(basename ${line})" != "ifcfg-${device_name}${i}" ];then
   printf "Change Network Device Name $(basename ${line} |awk -F'-' '{print $2}') to ${device_name}${i}…"
   mv ${line} $(dirname ${line})/ifcfg-${device_name}${i}
   sed -i "s/NAME=$(basename ${line} |awk -F'-' '{print $2}')/NAME=${device_name}${i}/g" $(dirname ${line})/ifcfg-${device_name}${i}
   sed -i "s/DEVICE=$(basename ${line} |awk -F'-' '{print $2}')/DEVICE=${device_name}${i}/g" $(dirname ${line})/ifcfg-${device_name}${i}
   printf "\033[32;1m%10s\033[0m\n" "[ DONE ]"
   fi
   ((i++))
done
sed -i "/GRUB_CMDLINE_LINUX/s/\(.*\)rhgb\(.*\)/\1net.ifnames=0 biosdevname=0 rhgb\2/g" /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg &> /dev/null
printf "\033[32;1mReboot…\033[0m\n"
printf "\033[32;1mYou Can Enter Ctrl+C To Stop Reboot\033[0m\n"

# 关闭ipv6

sed -i "/GRUB_CMDLINE_LINUX/s/\(.*\)crashkernel\(.*\)/\1ipv6.disable=1 crashkernel\2/g" /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg

# 安装docker安装源

yum makecache fast
yum install -y yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum -y install gcc gcc-c++ vim screen lrzsz net-tools wget curl unzip zip dos2unix rsync telnet zip unzip tree
yum -y install bash-completion-extras bash-completion
yum -y install device-mapper-persistent-data lvm2 deltarpm 
yum install -y docker-ce
systemctl start docker
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
    "registry-mirrors": ["https://vzkjk0y7.mirror.aliyuncs.com"],
    "bip":"10.88.1.1/24"
}
EOF
systemctl daemon-reload
systemctl restart docker
systemctl enable docker


0 篇评论

发表我的评论