CentOS7 笔记

永久改变Console背景色:

   vi /etc/profile

#rick begin, set console color
  setterm -foreground black -background white -store
#rick end

安装java8:

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.rpm"
rpm -ivh jdk-8u141-linux-x64.rpm

永久关闭峰鸣声:

    vi /etc/profile

#disable beep
rmmod pcspkr

支持挂载NTFS,并自动发现win7系统引导:

cd /etc/yum.repos.d
wget http://mirrors.aliyun.com/repo/epel-7.repo
yum update
yum install ntfs-3g
grub2-mkconfig -o /boot/grub2/grub.cfg

默认不启动Gnome(手动启动startx, 手动关闭init 5). 最小化安装时不需要:

systemctl set-default multi-user.target

安装ftp服务:其实没必要装这个, 用sftp就行了.

yum install vsftpd
systemctl enable vsftpd

关闭防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service

安装git, telnet:

yum install git
yum install telnet

安装go语言 (不用yum安装, 那个go版本太老了):

wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
tar zxvf go1.8.3.linux-amd64.tar.gz
mv go /usr/local/

    vi /etc/profile:

export PATH=$PATH:/usr/local/go/bin
export GOROOT=/usr/local/go

    测试:

source /etc/profile
go version

安装docker:

yum install docker
systemctl enable docker.service
systemctl start docker.service

 解决docker不能访问gcr.io的问题, 科学上网

    vi /etc/sysconconfig/docker

HTTP_PROXY=192.168.85.43:7070 #这是我的代理, 需要改成你自己的.
http_proxy=192.168.85.43:7070
HTTPS_PROXY=192.168.85.43:7070
https_proxy=192.168.85.43:7070
export HTTP_PROXY HTTPS_PROXY http_proxy https_proxy

   重启docker

service docker restart

    测试一下, 若没有问题则科学上网成功

docker pull gcr.io/google_containers/kube-cross:v1.8.3-1

安装etcd 服务器:

git clone https://github.com/coreos/etcd.git
cd etcd
./build
cd ..
mv etcd /usr/local

    vi /etc/profile

export PATH=$PATH:/usr/local/etcd/bin

    测试

source /etc/profile
etcd

设置etcd自启动:

    vi /usr/lib/systemd/system/etcd.service

[Unit]  
Description=etcd server  
After=network.target  
[Service]  
Type=simple 
WorkingDirectory=/usr/local/etcd  
EnvironmentFile=/usr/local/etcd/etcd.conf  
ExecStart=/usr/local/etcd/bin/etcd  
[Install]  
WantedBy=multi-user.target

  测试服务:

systemctl enable etcd.service  
systemctl start etcd.service
etcdctl cluster-health

单机环境安装kubernetes(注意是单机环境, 所有的组件都在一个台物理机上):

wget https://github.com/kubernetes/kubernetes/releases/download/v1.7.1/kubernetes.tar.gz
tar zxvf kubernetes.tar.gz
cd kubernetes
./cluster/get-kube-binaries.sh

cd client
tar zxvf kubernetes-client-linux-amd64.tar.gz 

cd ../server
tar xzvf kubernetes-server-linux-amd64.tar.gz

cd ../../
mv kubernetes /usr/local

    vi /etc/profile

#install kubernetes client
export PATH=$PATH:/usr/local/kubernetes/client/kubernetes/client/bin

#install kubernetes server
export PATH=$PATH:/usr/local/kubernetes/server/kubernetes/server/bin

    测试

source /etc/profile
kubectl
kubeadm

设置kubernate api server开机启动:

     vi /usr/lib/systemd/system/kube-apiserver.service

[Unit]  
Description=Kubernetes API Server  
After=etcd.service  
Wants=etcd.service  
[Service]  
ExecStart=/usr/local/kubernetes/server/kubernetes/server/bin/kube-apiserver --insecure-bind-address=0.0.0.0 --insecure-port=8080 --etcd_servers=http://127.0.0.1:2379 --service-cluster-ip-range=172.0.0.0/16 --logtostderr=false --log-dir=/log/kubernetes --v=3

Restart=on-failure  
Type=notify 
LimitNOFILE=65536
[Install]  
WantedBy=multi-user.target
systemctl enable kube-apiserver.service  
systemctl start kube-apiserver.service
 

设置kubernate controller manager 开机启动:

   vi /usr/lib/systemd/system/kube-controller-manager.service 

[Unit]
Description=Kubernetes Controller Manager
After=kube-apiserver.service  
Requires=kube-apiserver.service
[Service]
ExecStart=/usr/local/kubernetes/server/kubernetes/server/bin/kube-controller-manager --master=http://127.0.0.1:8080 --logtostderr=false --log-dir=/log/kubernetes --v=3

Restart=on-failure  
LimitNOFILE=65536 
[Install]  
WantedBy=multi-user.target
systemctl enable kube-controller-manager  
systemctl start kube-controller-manager

设置kubernate scheduler server开机启动:

    vi /usr/lib/systemd/system/kube-scheduler.service

[Unit]
Description=Kubernetes Scheduler Service
After=kube-apiserver.service
Requires=kube-apiserver.service
[Service]
ExecStart=/usr/local/kubernetes/server/kubernetes/server/bin/kube-scheduler --master=http://127.0.0.1:8080 --logtostderr=false --log-dir=/log/kubernetes --v=3

Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
systemctl enable kube-scheduler  
systemctl start kube-scheduler