jenkins部署-centos
一:系统基础配置
cat > /etc/sysctl.conf
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
net.ipv4.ip_forward=1
vm.swappiness=0
vm.overcommit_memory=1
vm.max_map_count=655360
fs.file-max=655360
net.core.somaxconn=1024
vm.panic_on_oom=0
fs.inotify.max_user_instances=8192
fs.inotify.max_user_watches=1048576
fs.nr_open=52706963
net.ipv6.conf.all.disable_ipv6=1
net.netfilter.nf_conntrack_max=2310720
EOF
cat > /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65535
* soft nproc 65536
* hard nproc 65536
EOF
#更新系统仓库
yum install -y wget
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup_date +%Y%m%d%H%M%S
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
#关闭swap
swapoff -a
sed -i /^[^#]swap/s/^/#/g /etc/fstab
sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
#升级内核
awk -F' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
grub2-set-default 0
#配置时间
timedatectl set-timezone Asia/Shanghai
timedatectl status
yum install -y chrony
systemctl enable chronyd
sed -i '/server 0.centos.pool.ntp.org/a \server ntp1.aliyun.com' /etc/chrony.conf
sed -i '/centos.pool.ntp.org/d' /etc/chrony.conf
systemctl restart chronyd
systemctl status chronyd
timedatectl status
systemctl disable firewalld
systemctl stop firewalld
systemctl status firewalld
#必要重启机器
reboot
#安装部署docker
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
systemctl start docker
systemctl enable docker
#配置docker启动配置
mkdir -p /etc/docker
cat /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "50m",
"max-file": "3"
},
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
],
"metrics-addr" : "0.0.0.0:9323",
"experimental" : true,
"insecure-registries" : ["harbor.petroglory.com"]
}
EOF
systemctl restart docker
docker ps
timedatectl status