HackToday Walk Blog


  • Home

  • Tags

  • Archives

  • Search

NTP: no server suitable for synchronization found

Posted on 2015-07-24

Ntp Server 在Redhat 7配置后,发现client

1
ntpdate -u <serverip>

报错: no server suitable for synchronization found

检查排错后,原来是firewall的问题,

在NTP server 配置防火墙

1
2
iptables -I INPUT -p udp --dport 123 -j ACCEPT
iptables -I OUTPUT -p udp --sport 123 -j ACCEPT

这样就可以了,注意-I, 不是-A
确保你的CHAIN最后一条不是Reject,因为-A是在最后添加一条新的规则。

Linux Shell Escaping a dollar In cat command

Posted on 2015-07-24

发现社区一个脚本执行后,cat命令写入后文件里面的表达式都求值展看了,其实这个是因为$的缘故,参看这个

http://stackoverflow.com/questions/21984960/escaping-a-dollar-sign-in-unix-inside-the-cat-command

1
2
3
4
5
6
7
8
9
10
11
12
13
You can use regular quoting operators in a here document:

$ cat <<HERE
> foo(\$bar)
> HERE
foo($bar)

or you can disable expansion by quoting the here-doc delimiter:

$ cat <<'HERE' # note single quotes
> foo($bar)
> HERE
foo($bar)

Redhat resolv.conf changes disappear!

Posted on 2015-07-20

最近使用redhat 7.1 系统,改过resolv.conf,总是发现文件修改完,重启系统,文件又变成没有修改之前的状态了。

原来查出是NetworkManager在作怪。

http://totalcae.com/blog/2013/06/prevent-etcresolv-conf-from-being-blown-away-by-rhelcentos-after-customizing/

OpenStack unit测试运行tox错误: ValueError: ("Expected , or end-of-list in"

Posted on 2015-07-17

今天pull到最新的代码,发现错误,

1
ValueError: ("Expected ',' or end-of-list in", "mock>=1.1;python_version!='2.6'", 'at', ";python_version!='2.6'")

后来找到 https://bugs.launchpad.net/devstack/+bug/1468808

原来是对应的virtualenv版本太低导致,
解决方法就是升级virtualenv

1
pip install -U virtualenv

OpenStack Swift Selinux, Permission denied

Posted on 2015-06-16

如果参考社区的文档,在Redhat7.1系统上安装swift,会发现陷入到无穷无尽的

1
can not access directory or file,  Permission Denied

什么原因呢,实际上是selinux context导致的权限问题。

这个是社区的文档
http://docs.openstack.org/kilo/install-guide/install/yum/content/swift-install-storage-node.html

Step6 中,

1
2
Ensure proper ownership of the mount point directory structure:
# chown -R swift:swift /srv/node

实际上这样的权限是

1
2
#ls -Z /srv/node
drwxr-xr-x. swift swift system_u:object_r:unlabeled_t:s0 sdb1

需要执行:

1
#restorecon -R /srv/node

然后再查看:

1
2
#ls -Z /srv/node
drwxr-xr-x. swift swift system_u:object_r:swift_data_t:s0 sdb1

这样就不会出现问题了,对于/var/cache/swift 同样适用

下面我做了另外一个实验,不使用本地的实际硬盘,创建一个loop device,使用xfs进行格式化。然后挂载来作为swift的back storage。
关于如何开机自动挂载loop device可以参考【3】

比如,

1
xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0

测试发现,如果 的前缀path是/srv/node 开始的,这样是没有问题的,但是如果换做其他的path,比如/etc/swift,
就会出现Permission Denied问题(restorecon 无法解决)

据cschwede说,everything under /srv and /var/run/swift should work
我没有测试/var/run/swift,但是/etc/swift是有问题的,后来ho建议了一个增加mount option的方法,

1
xfs loop,noatime,nodiratime,nobarrier,logbufs=8,context=system_u:object_r:swift_data_t:s0 0 0

这样就解决问题了。

感谢:
swift社区的ho(IRC nickname)的热情帮助解决问题。

参考文献:

  1. https://ask.openstack.org/en/question/60539/swift-juno-permission-denied-error/
  2. http://wiki.centos.org/HowTos/SELinux
  3. http://itekblog.com/mount-iso-using-fstab/

Ubuntu 14.04 pip package bug (ImportError: cannot import name IncompleteRead)

Posted on 2015-05-18

ubuntu 14.04 默认安装的pip package有个bug,
运行pip 出现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in
load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 351, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2363, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 61, in
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in
from pip.download import path_to_url
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in
from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead

http://flexget.com/wiki/PipProblems
http://stackoverflow.com/questions/27341064/how-do-i-fix-importerror-cannot-import-name-incompleteread

都提到了这个问题,简单fix的方法,就是升级pip版本

Docker build image issue for fatal error: ffi.h: No such file or directory

Posted on 2015-05-18

如果使用base的Ubuntu 14.04的image,会发现在在安装python的cryptography package,会报错,

1
2
3
4
5
 fatal error: ffi.h: No such file or directory
 #include 
                 ^
compilation terminated....distutils
`

根据, http://www.123code.blogspot.com/2014/10/fixed-installing-python-cryptography.html,
需要安装两个 libssl-dev libffi-dev包

一个简单的在线运行代码web实现

Posted on 2015-05-05

前几天想实验一个在线运行code的web实现,在github商店找到一个简单的事例,clone如下,

https://github.com/HackToday/codelauncher

实际上,这个项目最初的实现支持包括c和python,使用Flask Web框架来进行开发,使用了模版继承等特性,
具体参见这个 http://flask.pocoo.org/docs/0.10/quickstart/

我们可以简单的添加其他语言的支持,比如ruby,go 等。
以Ruby为例,简单的添加代码如下:

https://github.com/HackToday/codelauncher/commit/aa912a1303460bed35537d04b027fee846c0697f
https://github.com/HackToday/codelauncher/commit/879a10e37362218a61cdb6bae259b58c26ef2ba6

这个简单的实现,可以在此基础上做点有意思的事情,大家可以实验一下。

Docker Swarm的使用入门

Posted on 2015-04-23

Swarm是docker官方的native cluster方案,实现将Docker的host pool虚拟为一个主机,兼容docker的标准API, 保证了所有可以和docker daemon通信交互的软件,可以无缝的移植和docker swarm集群交互。

Docker的官方文档中提供了多种方式来搭建swarm nodes

  1. 官方例子使用docker hub token发现服务

  2. 静态文件方式

  3. etcd方式

  4. consul方式

  5. zookeeper方式

  6. 静态ip列表方式

  7. ip范围模式匹配方式

本文选1,2 为例介绍

实验环境,
搭建两个机器,实体机或者虚拟机都可以,保证可以和外网通信。

方式1.
1.1创建cluster id

1
docker run --rm swarm create

1.2 在每个节点运行 docker daemon,需要以tcp端口监听方式运行

1
docker -H tcp://0.0.0.0:2375 -d

在cluster中注册每个节点的ip

1
docker run -d swarm join --addr= token://

1.3 启动swarm manager

1
docker run -d -p :2375 swarm manage token://

1.4 检查集群状态
docker -H tcp:// info

检查集群节点信息
docker run –rm swarm list token://

如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Containers: 40
Strategy: spread
Filters: affinity, health, constraint, port, dependency
Nodes: 2
host1: node1:2375
?.Containers: 32
?.Reserved CPUs: 0 / 1
?.Reserved Memory: 0 B / 4.054 GiB
host2: node2:2375
?.Containers: 8
?.Reserved CPUs: 0 / 1
?.Reserved Memory: 0 B / 4.054 GiB
1.5 使用集群,就是针对swarm manager 来操作
docker -H tcp:// run ...

方式2:

手工维护,有点麻烦,但是不依赖docker hub外部服务
这里的主要区别是:

2.1 添加节点信息,

1
2
$ echo >> /tmp/my_cluster
$ echo >> /tmp/my_cluster

2.2 在每个节点运行 docker daemon, 同1.2

2.3 启动swarm manager

1
docker run  -it -v /tmp/:/mywork -p 6000:2375  swarm manage file:///mywork/my_cluster

2.4. 检查集群状态

1
2
3
4
docker -H tcp:// info
```

检查节点信息

docker run -v /tmp/:/mywork –rm swarm list file:///mywork/my_cluster
`

2.5 操作集群,同1.5

参考资料:

  1. http://docs.docker.com/swarm/
  2. https://docs.docker.com/swarm/discovery/

Redhat 7 - How to disable consistent network device naming

Posted on 2015-04-07

Redhat7官方确实给了如何沿用旧的网卡名字的方法,但是如果按照上面的操作,发现有的无法实现,不知道是不是受不同hypervisor的影响,
因为我要修改的是一个Vcenter上的虚拟机? 不太清楚,可能需要问问redhat那边的人,先记录一下这个link方便日后查阅

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/sec-Disabling_Consistent_Network_Device_Naming.html

我只使用了最后一种方式

  1. vim /etc/default/grub

  2. 添加启动参数

1
net.ifnames=0
  1. 生成新的grub 配置
1
grub2-mkconfig -o /boot/grub2/grub.cfg

注意这一步是否基于BIOS还是UEFI会有所不同,参见
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/ch-Working_with_the_GRUB_2_Boot_Loader.html

1…8910…26

Kai Qiang Wu

This is a place for thinking and writing

253 posts
32 tags
GitHub
© 2020 Kai Qiang Wu
Powered by Hexo
|
Theme — NexT.Gemini v5.1.4
Visitor Total Visit