Partition table scan: MBR: not present BSD: not present APM: not present GPT: not present
Creating new GPT entries.
Command (? for help): x
Expert command (? for help): z About to wipe out GPT on /dev/sda. Proceed? (Y/N): Y GPT data structures destroyed! You may now partition the disk using fdisk or other utilities. Blank out MBR? (Y/N): Y
# devices device 0 osd.0 class hdd device 1 osd.1 class hdd device 2 osd.2 class hdd device 3 osd.3 class hdd device 4 osd.4 class hdd device 5 osd.5 class hdd device 6 osd.6 class hdd device 7 osd.7 class hdd device 8 osd.8 class hdd
# types type 0 osd type 1 host type 2 chassis type 3 rack type 4 row type 5 pdu type 6 pod type 7 room type 8 datacenter type 9 zone type 10 region type 11 root
# buckets host community-ceph13-1 { id -3 # do not change unnecessarily id -4 class hdd # do not change unnecessarily # weight 0.144 alg straw2 hash 0 # rjenkins1 item osd.0 weight 0.048 item osd.3 weight 0.048 item osd.6 weight 0.048 } host community-ceph13-2 { id -5 # do not change unnecessarily id -6 class hdd # do not change unnecessarily # weight 0.144 alg straw2 hash 0 # rjenkins1 item osd.1 weight 0.048 item osd.4 weight 0.048 item osd.8 weight 0.048 } host community-ceph13-3 { id -7 # do not change unnecessarily id -8 class hdd # do not change unnecessarily # weight 0.144 alg straw2 hash 0 # rjenkins1 item osd.2 weight 0.048 item osd.5 weight 0.048 item osd.7 weight 0.048 } root default { id -1 # do not change unnecessarily id -2 class hdd # do not change unnecessarily # weight 0.431 alg straw2 hash 0 # rjenkins1 item community-ceph13-1 weight 0.144 item community-ceph13-2 weight 0.144 item community-ceph13-3 weight 0.144 }
# rules rule replicated_rule { id 0 type replicated min_size 1 max_size 10 step take default step chooseleaf firstn 0 type host step emit }
[root@dev yujiang]# cat remove_ceph_lvm.sh #!/bin/bash set -x
DEVICE_LIST=(a b c d e f g h i j k l) DEVICE_PATH="/dev" DEVICE_PREFIX="sd"
VG=`ls -l /dev/ | grep ceph- | awk '{print $9}' `
for name in ${DEVICE_LIST[@]} do echo ${name} done
for name in ${VG[@]} do LV=`ls -l ${DEVICE_PATH}/${name} | grep osd- | awk '{print $9}'` for lv in ${LV} do LV_PATH=${DEVICE_PATH}/${name}/${lv} lvremove ${LV_PATH} done vgremove ${DEVICE_PATH}/${name} done
for name in ${DEVICE_LIST[@]} do pvremove ${DEVICE_PATH}/${DEVICE_PREFIX}${name} done
执行shell命令: ansible atlanta -a "/sbin/reboot" -f 10 这个命令中,atlanta是一个组,这个组里面有很多服务器,"/sbin/reboot"命令会在atlanta组下的所有机器上执行。这里ssh-agent会fork出10个子进程(bash)以并行的方式执行reboot命令。如前所说"每次重启10个"即是以这种方式实现。 指定用户执行shell命令: ansible atlanta -a "/usr/bin/foo" -u username 使用sudo: ansible atlanta -a "/usr/bin/foo" -u username --sudo [--ask-sudo-pass]
文件管理: 创建文件夹:ansible webservers -m file -a "dest=/path/to/c mode=755 owner=mdehaan group=mdehaan state=directory" 拷贝文件:ansible atlanta -m copy -a "src=/etc/hosts dest=/tmp/hosts"
软件包管理: 确认一个软件包已经安装,但不去升级它:ansible webservers -m yum -a "name=acme state=present" 确认一个软件包的安装版本:ansible webservers -m yum -a "name=acme-1.5 state=present" 确认一个软件包还没有安装:ansible webservers -m yum -a "name=acme state=absent"
其他模块 git模块:git相关 service模块:系统服务相关 setup模块:系统环境相关
如何执行一个耗时的任务
1 2 3 4 5 6 7
ansible all -B 3600 -P 0 -a "/usr/bin/long_running_operation --do-stuff" -B 1800 表示最多运行60分钟,-P 0表示不获取状态
ansible all -B 1800 -P 60 -a "/usr/bin/long_running_operation --do-stuff" -B 1800表示最多运行30分钟,-P 60表示每隔一分钟获取一次状态
ansible web1.example.com -m async_status -a "jid=488359678239.2844"
production # inventory file for production servers(生产服务器的inventory文件) staging # inventory file for staging environment(临时环境的inventory文件)
group_vars/ group1.yml # here we assign variables to particular groups(将变量分配给特定的groups) group2.yml host_vars/ hostname1.yml # here we assign variables to particular systems(将变量分配给特定systems) hostname2.yml
library/ # if any custom modules, put them here (可选)(放置自定义modules) module_utils/ # if any custom module_utils to support modules, put them here (可选)(放置支持modules的自定义module_utils) filter_plugins/ # if any custom filter plugins, put them here (可选)(放置自定义filter plugins)
site.yml # master playbook(playbook入口) webservers.yml # playbook for webserver tier(webserver层playbook) dbservers.yml # playbook for dbserver tier(dbserver层playbook)
roles/ common/ # this hierarchy represents a "role"(这个层次代表role) tasks/ # main.yml # <-- tasks file can include smaller files if warranted(tasks文件) handlers/ # main.yml # <-- handlers file(处理程序文件) templates/ # <-- files for use with the template resource(用于模板资源的文件) ntp.conf.j2 # <------- templates end in .j2(模板以.j2结尾) files/ # bar.txt # <-- files for use with the copy resource(用于复制资源的文件) foo.sh # <-- script files for use with the script resource(用于脚本资源的脚本文件) vars/ # main.yml # <-- variables associated with this role(与此role关联的变量) defaults/ # main.yml # <-- default lower priority variables for this role(此role的默认优先级较低的变量) meta/ # main.yml # <-- role dependencies(role依赖) library/ # roles can also include custom modules(role还可以包括自定义modules) module_utils/ # roles can also include custom module_utils(role还可以包括自定义module_utils) lookup_plugins/ # or other types of plugins, like lookup in this case(或其他类型的plugins,例如lookup)
webtier/ # same kind of structure as "common" was above, done for the webtier role(与上面的"common"相同的结构,为webtier role定义) monitoring/ # "" fooapp/ # ""
我们将使用statx() system call来提供测试的具体示例。在撰写本文时,没有测试Linux内核版本4.11中的system call。Linux system call特定的测试主要包含在testcases/kernel/syscalls目录,但你也可以grep整个LTP repository以检查任何现有system call的用法。
/* * Copyright (c) 2017 Instruction Ignorer <"can't"@be.bothered.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* * Test statx * * All tests should start with a description of _what_ we are testing. * Non-trivial explanations of _how_ the code works should also go here. * Include relevant links, Git commit hashes and CVE numbers. * Inline comments should be avoided. */
查看IP地址 [root@cephL ~]# ip addr show enp0s8 3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:52:03:aa brd ff:ff:ff:ff:ff:ff inet 192.168.56.102/24 brd 192.168.56.255 scope global dynamic enp0s8 valid_lft 847sec preferred_lft 847sec inet6 fe80::4b2b:b766:22c:f503/64 scope link valid_lft forever preferred_lft forever
查看IPv6地址 [root@cephL ~]# ip -6 addr show dev enp0s8 3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000 inet6 fe80::4b2b:b766:22c:f503/64 scope link valid_lft forever preferred_lft forever
添加IP地址 [root@cephL ~]# ip addr add 192.168.56.103/24 dev enp0s8 删除IP地址 [root@cephL ~]# ip addr del 192.168.56.103/24 dev enp0s8
路由
1 2 3 4 5 6 7 8 9 10 11 12 13 14
[root@cephL ~]# ip route show 192.168.56.0/24 dev enp0s8 proto kernel scope link src 192.168.56.102 metric 100 192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
让kernel报告路由,它会发送一个数据包到指定的地址 [root@cephL ~]# ip route get 61.135.169.125 61.135.169.125 via 10.116.21.254 dev enp0s9 src 10.116.21.135 cache (解释:61.135.169.125是访问的地址,10.116.21.254是默认路由,10.116.21.135是enp0s9设备IP地址)
添加默认路由 [root@cephL ~]# ip route add default via 10.116.21.253 dev enp0s9 删除默认路由 [root@cephL ~]# ip route del default via 10.116.21.253 dev enp0s9
查询特定接口统计信息 [root@cephL ~]# ip -s link ls enp0s9 4: enp0s9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 08:00:27:3e:3e:e2 brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped overrun mcast 54527 583 0 0 0 0 TX: bytes packets errors dropped carrier collsns 60946 633 0 0 0 0
ARP,查看接入的MAC地址
1 2 3 4 5 6
[root@cephL ~]# ip neighbour 192.168.56.1 dev enp0s8 lladdr 0a:00:27:00:00:00 DELAY 10.116.21.254 dev enp0s9 lladdr 00:00:0c:07:ac:0c DELAY 10.116.21.253 dev enp0s9 lladdr b4:de:31:c7:e7:47 STALE 192.168.56.100 dev enp0s8 lladdr 08:00:27:3e:18:34 STALE 10.116.21.252 dev enp0s9 lladdr b4:de:31:c7:d8:e7 STALE
ip工具可以连续监视devices, addresses和routes的状态。
1 2 3 4 5 6 7
[root@cephL ~]# ip monitor all [nsid current]192.168.56.1 dev enp0s8 lladdr 0a:00:27:00:00:00 REACHABLE [nsid current]10.116.21.254 dev enp0s9 lladdr 00:00:0c:07:ac:0c STALE [nsid current]192.168.56.1 dev enp0s8 lladdr 0a:00:27:00:00:00 REACHABLE [nsid current]10.116.21.254 dev enp0s9 lladdr 00:00:0c:07:ac:0c REACHABLE [nsid current]3: enp0s8 inet 192.168.56.102/24 brd 192.168.56.255 scope global dynamic enp0s8 valid_lft 1200sec preferred_lft 1200sec
up和down网络设备
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
[root@cephL ~]# ip link set enp0s9 down [root@cephL ~]# ip route show 192.168.56.0/24 dev enp0s8 proto kernel scope link src 192.168.56.102 metric 100 192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 [root@cephL ~]# ping www.baidu.com ping: www.baidu.com: 未知的名称或服务
[root@cephL ~]# ip link set enp0s9 up [root@cephL ~]# ip route show default via 10.116.21.254 dev enp0s9 proto static metric 100 10.116.20.0/23 dev enp0s9 proto kernel scope link src 10.116.21.135 metric 100 192.168.56.0/24 dev enp0s8 proto kernel scope link src 192.168.56.102 metric 100 192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 [root@cephL ~]# ping www.baidu.com PING www.a.shifen.com (61.135.169.121) 56(84) bytes of data. 64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=1 ttl=50 time=4.35 ms
1.安装libmemcached wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz tar zxvf libmemcached-1.0.18.tar.gz && cd libmemcached-1.0.18 ./configure --prefix=/usr/lib/libmemcached make && make install