陈沙克

Dec 132017
 

学习了一下git的使用过程。

假设我已经有一个仓库在我自己账号下,我下载回来,修改一下,push上去我修改的内容。

cd /home
git clone https://github.com/shake/CentOS-Dockerfiles.git

配置git

git config --list
git config --global user.name "shake"
git config --global user.email "shake.chen@gmail.com"
git config --list

我修改下载的文件后

cd /home/CentOS-Dockerfiles/
git remote add origin https://github.com/shake/CentOS-Dockerfiles.git
git add .
git commit -m "httpd"
git push -u origin master

这里面需要解析一下 git remote add origin 含义

就是把这个git的远程的名字命名为 origin,你可以改自己喜欢名字,只是github推荐,大家习惯origin就是远程的仓库。

# git remote
origin

可以删除。

Dec 122017
 

记录一下自己在CentOS下的一些调整。我笔记本虚拟机的初始化操作的记录。

Systemd

这是CentOS 7最大改动的地方,让大家需要时间去熟悉

所有的服务

systemctl list-units --type service

启动的服务

systemctl list-unit-files --type=service | grep enabled

一个服务

# systemctl status <name>
# systemctl stop <name>
# systemctl disable <name>
# systemctl start <name>
# systemctl restart <name>

https://www.rayheffer.com/essential-linux-skills-with-centos-7-managing-services-with-systemd/

Chrony服务

CentOS 7 其实是建议采用chrony服务来实现同步时间。我采用最小化安装CentOS 7的时候,Chrony服务是没安装

yum install chrony
systemctl start chronyd
systemctl enable chronyd

默认同步时间的服务器是CentOS,你可以修改成国内的时间服务器

编辑 /etc/chrony.conf

server 0.cn.pool.ntp.org iburst
server 1.cn.pool.ntp.org iburst
server 2.cn.pool.ntp.org iburst
server 3.cn.pool.ntp.org iburst

这个时候,重启chronyd服务

systemctl restart chronyd
chronyc sources

这个时候你就会发现有国内的时间服务器。需要注意,如果你机器时间和标准时间差异很大,你需要强制同步

当你强制同步时间前,先要把chrony服务停止
systemctl stop chronyd
chronyd -q 'pool pool.ntp.org iburst'
强制同步时间后,再启动chrony服务

红帽的文档,是世界上最好的,准确的文档

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-using_chrony

chronyc tracking
chronyc sources
chronyc sourcestats

Date and Time

查看当前时间和时区

# timedatectl status
      Local time: Tue 2017-12-12 18:02:46 CST
  Universal time: Tue 2017-12-12 10:02:46 UTC
        RTC time: Tue 2017-12-12 10:02:46
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

如果你希望手工修改时间,这个时候,你需要先停止同步时间

timedatectl set-ntp 0

这个时候,你就可以设置时间

timedatectl set-time 17:00:00

如果启用ntp 服务

timedatectl set-ntp 1

修改日期

timedatectl set-time ‘YYYY-MM-DD  HH:MM:SS’

查看硬件时间

hwclock

同步system时间到硬件

hwclock --hctosys

http://linuxtechlab.com/playing-date-time-rhelcentos/

搜索

我们经常需要搜索某个配置文件

find /etc -name "yum.*" -type f

很多技巧,-type f,搜索文件,-type d 搜索目录

还有一种简单办法,就是安装mlocate的包,可以直接搜索

yum install mlocate

更新数据库

updatedb
# locate yum.conf
/etc/yum.conf
/usr/share/man/man5/yum.conf.5

这种方式其实其实是不建议使用,还是使用find比较好。

查看一个文件是属于哪个rpm包

# rpm -qf /etc/yum.conf
yum-3.4.3-154.el7.centos.noarch

查看rpm包包含哪些文件,已经安装的rpm包

 rpm -ql chrony
/etc/NetworkManager/dispatcher.d/20-chrony
/etc/chrony.conf
/etc/chrony.keys

如果需要搜索关键字

grep -rlw "tecadmin" /var/log

加上 -i参数,就是不区分大小写

https://tecadmin.net/find-all-files-containing-specific-text-on-linux/

内核版本

查看操作系统版本

cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
查看内核版本,现在内核的版本是
# uname -a
Linux server01.chenshake.com 3.10.0-693.el7.x86_64

#1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
以前内核版本号很难记忆,现在其实已经加上时间。这个内核版本,是8月22日的版本。这是centos 7.4默认的内核版本号。
如果升级一下,你会发现最新的版本号是
]# uname -a
Linux server01.chenshake.com 3.10.0-693.11.1.el7.x86_64

#1 SMP Mon Dec 4 23:52:40 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

升级

升级系统的包

yum update
可能会导致内核升级,需要重启机器才能生效。
升级操作系统版本,例如从7.3升级7.4
yum upgrade

vim

yum install vim

编辑  /etc/profile

# add at the last line
alias vi='vim'

让设置马上生效

source /etc/profile

CentOS7 的vim 默认已经已经支持恢复到上次光标位置的功能,基本不需要啥调整就可以使用。

如果需要做修改配置就编辑 /etc/vimrc 文件就可以。

set ignorecase

我增加搜索的时候忽略大小写。

Selinux

关闭selinux是一个惯例,包括检查selinux是否关闭。

# sestatus
SELinux status:                 enabled

关闭selinux

sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0

我的习惯就是重启机器,确保生效。

# sestatus
SELinux status:                 disabled

设置Repo

为了方便,其实最好是把红帽的yum的工具包都装上。

查看repo

cd /etc/yum.repos.d/
mkdir backup
move CentOS* ./backup/

设置阿里源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

检查

yum clean all
yum makecache
yum list | wc -l

如果我们希望增加一个docker的repo,可以用这个方法

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

lrzsz

这个工具,其实非常方便xshell下非常方便,上传和下载文件。

yum install lrzsz

关闭防火墙

systemctl status firewalld
systemctl disable firewalld.service
systemctl stop firewalld.service

主机名

需要搞清楚hostname和FQDN Name的区别

设置hostname

# cat /etc/hostname
server01

如果希望修改,可以使用

hostnamectl –static set-hostname server01

让修改马上生效

hostname -F /etc/hostname

设置FQDN

# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.100.10	server01.chenshake.com	server01
查看
# hostname
server01

hostname -f
server01.chenshake.com

-f,含义是FQDN,类似域名的名称。

通过hostnamectl 还能查看系统的整体状况,是vm还是物理机器。

# hostnamectl status
   Static hostname: server01
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 7c4bea6eadac4a1cae068a167a0c961b
           Boot ID: 173cfb58e1c948ce947bd8261b327f91
    Virtualization: vmware
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-693.11.1.el7.x86_64
      Architecture: x86-64

网络工具

一些常用的网络工具需要安装

  1. netstat 需要安装 net-tools
  2. nmap,需要安装 nmap
  3. lsof,需要安装lsof
yum install net-tools lsof nmap

使用

netstat -nlptu

需要对参数有啥了解

  • -n 表示不解析ip到域名,这个参数必须
  • -l 表示显示打开的端口
  • -p 表示显示端口应用名字
  • -t 表示tcp协议
  • -u 表示 udp协议

查看22端口情况

lsof -i :22

lsof 功能很强, 包括查看某个文件是否给某个进程使用

lsof /usr/sbin/sshd

nmap其实是扫描工具,可以扫描自己,查看端口的情况

nmap localhost

https://www.cyberciti.biz/faq/howto-install-nmap-on-centos-rhel-redhat-enterprise-linux/

关闭IPv6

编辑  /etc/sysctl.conf.

net.ipv6.conf.all.disable_ipv6 = 1

马上生效

sysctl -p

对比一下

关闭前

# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:9e:48:a3 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.10/24 brd 192.168.100.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::7a67:a172:a8cd:635/64 scope link
       valid_lft forever preferred_lft forever

关闭后

# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:9e:48:a3 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.10/24 brd 192.168.100.255 scope global ens33
       valid_lft forever preferred_lft forever

http://aws-labs.com/disable-ipv6-centos-7-rhel-7/

最大打开文件数量

下面内容还没完全理解

在开发运维的时候我们常常会遇到类似“Socket/File: Can’t open so many files”,“无法打开更多进程”,这个时候,我们需要调整系统的默认参数。

file-max

内核可分配的最大文件数

# cat /proc/sys/fs/file-max
396334

系统最大打开文件描述符数

cat /proc/sys/fs/file-nr
960	0	396334
临时修改
 echo 1000000 > /proc/sys/fs/file-max

永久性修改 在/etc/sysctl.conf中设置

fs.file-max = 1000000

单个进程最大打开文件描述符数,nr_open是单个进程可分配的最大文件数

soft link

# ulimit -n
1024

hard link

# ulimit -Hn
4096

修改

http://blog.csdn.net/superchanon/article/details/13303705

http://blog.51cto.com/qujunorz/1703295

https://unix.stackexchange.com/questions/127777/how-to-configure-the-process-open-file-limit-of-a-user

Dec 032017
 

Kolla第一个真正意义上可以在生产部署的版本Ocata版本发布以后,经过半年多的验证,其实这次11月份的OpenStack峰会上,其实也体现出来,越来越多用户在尝试和测试。

Ocata版本

由于Kolla,是一个开源的项目,他支持CentOS,Ubuntu,source和二进制的部署方式,采用不同的方式,你可能面对的问题是不一样的。那么对于我来说,或者国内来说,

Kolla Ocata Source+CentOS 7.4 + Dcoker CE =Perfect

这个组合应该应该了很多客户生产的验证。可以这样说,Kolla生产中稳定性,可靠性的所有的问题。都已经彻底解决。

一个系统的稳定,可靠,真的不是靠拍胸口来证明的。需要生产环境下的长期压力测试,

这样说吧,现在对付100个节点的OpenStack群集规模,已经是可以轻松面对。

kolla控制节点扩容

用户经常质疑OpenStack的一个问题就是:在Vmware的环境下,我可以从一个节点开始使用,逐步增加节点。为啥OpenStack上来就需要3个控制节点呢?刚开始节点,我还不需要那么高可靠,我还打算周末关机省电呢?

简单来说,就是OpenStack群集的控制节点,能不能从1个扩展到3个。目前市场上,所有的部署工具,都是无法支撑的这个功能的。当年Fuel尝试了一下,也放弃了。

对于kolla来说,其实很简单,你部署第一个控制节点的时候,只需要设置好haproxy的IP,那么剩下的都是好办的。

从1个控制节点,增加到3个控制节点,从3个控制节点,扩展到5个控制节点,都是轻松面对。

OpenStack项目状况

Kolla基本集成了所有OpenStack项目,那么那些项目是可用的呢。我就整理一下把。方便大家测试,针对目前的Ocata版本

生产环境

  1. Nova (kvm)
  2. Neutron(L3HA)
  3. Cinder(Ceph)
  4. Glance(Ceph)
  5. Keystone (AD)
  6. Horizon
  7. Heat
  8. swift

上面这8个项目,应该算是经过了大量验证,已经达到完美的情况,应该来说,100个节点内,应该是轻松面对。

  1. Octavia,负载均衡项目,其实该项目也是可以生产使用,目前就是Horizon UI上有点逻辑问题,导致删除的功能不能正常,需要命令行下删除。他的架构,也是可以支撑大规模部署。VM As Service
  2. IRonic,裸机管理,这个功能其实目前是非常好用。包括多租户,都是支持。
  3. Sahara,大数据服务,功能都是正常的。
  4. Rally,部署完OpenStack,进行压力测试,这块我费了很多心思,也是可以很好支持。完全是可以玩起来。

OpenStack Big Tent底下,所谓官方项目,大概目前是60个左右,用户需要用到的项目大概有30多个,不过真正意义上,能投入生产,经过用户验证的,也就上面这12个项目。其实如果你去看红帽的OpenStack支持列表,也是差不多的。

可用项目

下面我整理一下大家可以关注的项目,或者需要大家去测试的项目,希望我们可以努力去完善。

  1. Barbican:密钥管理项目,很多项目的安全,cinder,sahara的数据加密,都是需要这个组件来完成。
  2. Designate:dns项目,由于OpenStack平台如果希望支持k8s,需要使用外部dns服务,受到大家重视,该项目也是可以好好测试,目前kolla里也是比较重视。
  3. Manila: Netapp和EMC一直都在支持,目前对Ceph集成,也在完善。值得去看看。也是因为K8s,再次受到重视。
  4. Mistral:工作流项目,目前例如tacker,都用它来做流程。kolla也是work。
  5. Magnum:部署k8s工具,这个工具,目前是可用,经过我们测试。
  6. kuryr:k8s网络相关,
  7. zun,容器管理项目,替代nova docker。
  8. Dragonflow: 华为,中兴都在玩,很难得的事情。

实验室

这些项目,一直都没真正意义跑起来,目前社区也存在严重问题,缺乏后续发展

  1. CloudKitty
  2. Congress
  3. Freezer
  4. Karbor
  5. Monasca
  6. Murano
  7. Searchlight
  8. Senlin
  9. Solum
  10. Tacker
  11. Telemetry(aodh,panko,ceilometer)
  12. Trove
  13. Vitrage
  14. Watcher
  15. Zaqar

上面15个项目,其实已经基本都没有全职的人员在干活,非常危险了。据说已经成为国内刷榜的重点地带。

Nov 302017
 

整理一下同事的笔记。

yum install epel-release
yum install axel vim git curl wget lrzsz gcc  python-devel yum* python-pip

设置docker官方repo,安装docker CE版本

yum-config-manager \
--add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce
docker -v
配置docker
mkdir /etc/systemd/system/docker.service.d
tee /etc/systemd/system/docker.service.d/docker.conf << 'EOF'
[Service]
MountFlags=shared
EOF
编辑 /usr/lib/systemd/system/docker.service
# ExecStart=/usr/bin/dockerd
ExecStart=/usr/bin/dockerd --insecure-registry 192.168.10.139:4000

启动docker

systemctl daemon-reload
systemctl restart docker
systemctl enable docker
docker info

registry服务器

docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 \
--restart=always --name registry registry:2

监控系统

涉及很多软件,很有代表性:Prometheus,grafana,alertmanager,exporters

Prometheus

https://prometheus.io/docs/prometheus/latest/installation/

docker run -p 9090:9090 -v /tmp/prometheus.yml:/etc/prometheus/prometheus.yml \
       prom/prometheus
Nov 242017
 

听了不少课程,看了几本书,感觉还是很模糊。不过看图,确实是可以加快我的理解。希望这下面一切,都可以很快在OpenShift验证一遍。

目前的想法是通过jenkins作为调度,Jenkins需要启用的插件

  1. Robot Framework
  2. sonarqube (java)
  3. Unit Testing

默认OpenShift平台的Jenkins插件,自带下面插件

  1. OpenShift pipeline plugin
  2. OpenShift Client Plugin
  3. OpenShift Sync Plugin
  4. OpenShift Login Plugin
  5. Kubernetes Plugin

https://github.com/openshift/jenkins

jenkins

jenkins1

jenkins_is_the_hub_CD_Devops

Nov 092017
 

通过图来了解一个软件,效果应该是最好的。

部署架构图

ocp_smart_start_diagram

What isOpenShift

Snap1

Roadmap

Snap2

流程

Snap3

  1. developer provides git repo
  2. Developer chooses image from grgistry
  3. layer is applied to image
  4. layer is added back to registry
  5. image is scheduled and deployed
  6. Developer can declare webhooks
  7. updated image is added back to the registry
  8. New Images is depoyed as rooling update

Snap5

Compare

Snap4

Architecture

Snap6