go开发环境

#!/bin/bash

#部署docker环境
#部署docker-compose
#部署etcd-3.3.9
#部署go环境 go-1.12.4
#部署nginx-1.16
#部署redis-5
#部署mysql-5.7


# 系统初始化、环境升级和安装必要插件依赖
#设置时区并同步时间 cn.pool.ntp.org/time.windows.com
# cat /usr/share/zoneinfo/Asia/Shanghai >/etc/localtime
cd /etc
rm -f localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
if ! crontab -l |grep ntpdate &>/dev/null ;then
    (echo "* 1 * * * ntpdate cn.pool.ntp.org >/dev/null 2>&1";crontab -l) |crontab
fi

#设置最大打开文件数

if ! grep "* soft nofile 65535" /etc/security/limits.conf &>/dev/null; then
	cat >> /etc/security/limits.conf << EOF
	* soft nofile 65535
	* hard nofile 65535
EOF
fi

#系统内核优化

cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 262144
net.core.somaxconn = 262144
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.ip_local_port_range = 1024 65000
net.nf_conntrack_max = 655360
net.netfilter.nf_conntrack_tcp_timeout_established = 1200
EOF
sysctl -p /etc/sysctl.conf

# 安装系统性能分析工具及其他
yum -y update
yum -y install wget git vim lrzsz mysql unzip zip gcc make net-tools iostat

#安装部署docker环境


sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2

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

sudo yum-config-manager --enable docker-ce-nightly
sudo yum install docker-ce docker-ce-cli containerd.io -y
systemctl start docker
systemctl enable docker

#安装部署docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version

#部署go环境 go-1.12.4
#部署nginx-1.16
#部署redis-5
#部署mysql-5.7

#部署etcd,拉取镜像
docker pull quay.io/coreos/etcd:v3.3.9

#启动etcd

docker run -d -it --restart=always --name etcd -e ETCDCTL_API=3 -p 2379:2379 -p 2380:2380 quay.io/coreos/etcd:v3.3.9 etcd --advertise-client-urls http://0.0.0.0:2379 --listen-client-urls http://0.0.0.0:2379

Last updated