標籤:
升級CentOS
準備工作:
1:安裝開發平台工具
yum groupinstall "Development tools"
2:安裝核心升級需要的相依元件
yum install ncurses-devel
qt-devel
hmaccalc zlib-devel binutils-devel elfutils-libelf-devel
3:因為selinux和LXC有衝突,所以需要禁用
# vi /etc/selinux/config SELINUX=disabled
4:配置Fedora EPEL 源
,用於yum docker-io
# yum install epel-release.noarch
5:下載升級linux核心源,可以自己去官方下載kernel版本(需要帶aufs模組),自己編譯。另一種是下載帶aufs模組的rpm包(http://down.51cto.com/data/1903250)直接安裝(推薦)
升級核心(直接下載的RPM):
gzip -dv kernel-ml-aufs-3.10.5-3.el6.x86_64.rpm.gz
rpm -ivh kernel-ml-aufs-3.10.5-3.el6.x86_64.rpm
設定新的kernel為預設啟動項,新安裝的核心會在檔案清單的第一位,設定為0
vi /etc/grub.cong
default=0
reboot //重啟
uname -r //檢測當前kernel版本,3.10.5-3.el6.x86_64,則表示升級kernel成功
docker安裝主意事項
1:安裝docker
yum install docker-io
2:要想docker正常運行還需要在/etc/fstab裡增加cgroup檔案系統
echo "none /sys/fs/cgroup cgroup defaults 0 0" >> /etc/fstab
mount /sys/fs/cgroup
只有重新啟動才能掛載/sys/fs/cgroup(因為當前啟動並執行核心不支援cgroup),所以上面掛載的命令也可以不執行,但系統需要重新啟動
3:檢測aufs模組是否載入
grep aufs /proc/filesystems
4:以守護模式運行docker.io(在一個新的終端裡)
docker -d
如果出現異常:DNS/Networking Errors inside the docker,可重設docker的運行環境,嘗試解決問題
# pkill docker
# iptables -t nat -F
# ifconfig docker0 down
# brctl delbr docker0
# docker -d
5:檢測docker是否正常運行
docker run hello-world //預設是不存在這個鏡像的,等待docker自動下載hello-world
出現一下資訊,則表示docker安裝成功
Hello from Docker.This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (Assuming it was not already locally available.) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bashFor more examples and ideas, visit: http://docs.docker.com/userguide/
異常錯誤:
1:docker啟動的時候報錯
Starting cgconfig service: Error: cannot mount cpuset to /cgroupuset: Device or resource busy,(cgconfig 在啟動時預設會讀取 /etc/cgconfig.config 中的配置來建立 Cgroups 階層,綁定所需的檔案系統並關聯子系統,建立 Cgroups 組並設定每個組的子系統參數)
解決方案:
service cgconfig status //檢查是否正常運行
vi /etc/cgconfig.conf
mount {
cpuset = /cgroup/cpuset;
cpu = /cgroup/cpu;
cpuacct = /cgroup/cpuacct;
memory = /cgroup/memory; //註解掉這一段,即:#memory = /cgroup/memory;
devices = /cgroup/devices;
freezer = /cgroup/freezer;
net_cls = /cgroup/net_cls;
blkio = /cgroup/blkio;
}
service cgconfig start //重啟開啟服務
2:Error response from daemon: Cannot start container {id}: [8] System error: write /sys/fs/cgroup/docker/{id}2a7ce2f9bc/cgroup.procs: no space left on device
處理方法(參考地址:http://stackoverflow.com/questions/29961584/docker-cgroup-procs-no-space-left-on-device):
A simple command should do the trick.
sudo echo 1 > /sys/fs/cgroup/docker/cgroup.clone_children
If it still does not work, run below commands and restart docker service:
sudo echo 0 > /sys/fs/cgroup/docker/cpuset.mems sudo echo 0 > /sys/fs/cgroup/docker/cpuset.cpus
CentOS安裝docker基礎教程