sles12.2新机器安装必备软件记录
一台suse12sp2,装必备软件的时候发现之前一些安装过程的问题虽然记得但是因为没有记录又得重新找,所以就写下来防止以后又到处搜解决方法重新爬坑。。。。。。
安装的软件及配置
- tmux
- docker
- set -o vi
- …
遇到的问题
SLES怎么安装docker
除了自带的iso光盘的源外,zypper还要添加suse12.2虚拟化的库,之后就可以安装docker了。
zypper in docker
zypper in systemd-docker
systemctl reenable docker.service
systemctl start docker.service
另外docker-compose从github的release中下载改名加权限即可。
curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
但是此时运行docker info会发现末尾:
WARNING: No swap limit support
WARNING: No kernel memory limit support
其中一个(No kernel memory limit support)是由于suse12自带内核版本低于其docker某些特性所需内核版本引起的,可以通过升级内核解决,另外一个问题(No swap limit support)是要修改grub的配置来解决。 对于No swap limit support:
##将GRUB_CMDLINE_LINUX=""修改为:GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1",生效并重启
vi /etc/default/grub
grub2-mkconfig ##对于suse用的是这个命令,而不是update-grub(这个好像是ubuntu的),20190403,应该用grub2-mkconfig -o /boot/grub2/grub.cfg
reboot
改完之后是这样的:
GRUB_TIMEOUT=8
GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/rootvg/swap splash=silent quiet showopts crashkernel=200M,high crashkernel=72M,low "
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
或者在GRUB_CMDLINE_LINUX_DEFAULT里面也可以,把”cgroup_enable=memory swapaccount=1”移动到其后面,改完后这样:
GRUB_TIMEOUT=8
GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/rootvg/swap splash=silent quiet showopts crashkernel=200M,high crashkernel=72M,low cgroup_enable=memory swapaccount=1"
GRUB_CMDLINE_LINUX=""
对于No kernel memory limit support,zypper添加kernel的repo,注意,不要用12sp2链接的kernel_repo,否则版本低不能解决,运行:
zypper ref
zypper dup -r kernel ##这边的kernel是repo的名字,视zypper里面kernel源的name而定
reboot
然后就没有那两个WARNING了。
杂项小问题
- 安装tmux前需要先安装libevent和ncurses,在这些之前要先装gcc.
zypper install gcc
tar xf libevent-2.1.8-stable.tar.gz
cd libevent-2.1.8-stable/
./configure
make
make install
..
..
tar xf ncurses-6.1.tar.gz
cd ncurses-6.1/
./configure
make
make install
..
..
tar xf tmux-2.6.tar.gz
cd tmux-2.6/
./configure && make
make install
- 但是装完之后(都)安装完这两个依赖后,运行tmux还是提示找不到so文件。此时应该:
ldconfig ##好像是让系统更新动态链接库的索引或者缓存之类的,这样才能找到刚装的so文件
- 要在/etc/profile.local改成vi键绑定,不要在/etc/profile。。。,今天突然感觉/etc/profile太长了,在这里放配置好怪,可能换个地方放配置才科学?。。。然后就瞄了下这文件的开头。。。
# /etc/profile for SUSE Linux
#
# PLEASE DO NOT CHANGE /etc/profile. There are chances that your changes
# will be lost during system upgrades. Instead use /etc/profile.local for
# your local settings, favourite global aliases, VISUAL and EDITOR
# variables, etc ...
#
# Check which shell is reading this file
所以就:
vi /etc/profile.local ##刚装的系统没这个文件。在这加一行“set -o vi”
如下图:
***-***-**:* # cat /etc/profile.local
set -o vi
其它
暂时就先记录这些,有遇到其它问题再补充,防止以后拿到新机器后重新弄这些浪费时间。。。可能写个脚本将这些过程自动化比较合适。。。或者直接虚拟机快照、镜像克隆之类的(可我不是系统管理员不行哈哈)。。。
ps1
对于docker-compose的补充,第一次运行docker-compose之后,貌似会创建对应的网卡和路由(172.18..),而如果如果我们ssh连接的机器,就在这个compose的默认网段内就会发生失去连接的情况(因为172.18..的路由都到docker的网卡去了。。。这个坑浪费好多时间。。。本来想该compose的默认网口配置来解决,后来别人提供了个思路,用route命令增加对冲突机器的路由)。。。改docker配置就是vi /etc/docker/daemon.json:
{
"registry-mirrors": ["https://registry.docker-cn.com"],
"bip": "172.26.0.1/16"
}
增加bip这条配置为其它不会冲突的ip段。
ps2:suse中的docker配置
suse中docker的配置文件的位置和其它系统不同。 运行时遇到的Temporary failure in name resolution错误。在网上搜到的解决办法是:
For Ubuntu
Edit /etc/default/docker and add your DNS server to the following line:
Example
DOCKER_OPTS="--dns 8.8.8.8 --dns 10.252.252.252"
但是,在suse中不是! 在suse中不存在这个文件,查看官方文档,可知,在suse中对应的配置文件为:
/etc/sysconfig/docker
再比如docker的代理配置也可以在此处配置:
## Path : System/Management
## Description : Extra cli switches for docker daemon
## Type : string
## Default : ""
## ServiceRestart : docker
#
DOCKER_OPTS=""
HTTP_PROXY="http://ip:port"
HTTPS_PROXY="http://ip:port"
对suse中的docker而言,此配置文件的配置的环境变量优先级最高,但却又不会出现在systemctl show 展示的环境变量里面。。。。在尝试了/etc/systemd/system/docker.service.d/https-proxy.conf,/etc/docker/daemon.json,~/.docker/config.json,运行systemctl show –property=Environment docker,也不会显示此文件中的环境变量。。。这应该是suse的一个bug吧。