2015年5月

RDO安装openstack遇到的一些问题(swift & mongodb)

2015年5月30日15:25:25

1.mongodb

Applying 172.16.43.182_mongodb.pp
172.16.43.182_mongodb.pp:                         [ ERROR ]
Applying Puppet manifests                         [ ERROR ]

ERROR : Error appeared during Puppet run: 172.16.43.182_mongodb.pp
Error: Unable to connect to mongodb server! (172.16.43.182:27017)

解决方法:

vim /usr/share/openstack-puppet/modules/mongodb/manifests/params.pp  

        # RedHat/CentOS doesn't come with a prepacked mongodb  
        # so we assume that you are using EPEL repository.  
        $config              = '/etc/mongod.conf'              #修改此行

2.swift

解决上面问题再次运行的时候遇到swift报错

Applying 172.16.43.182_ring_swift.pp
172.16.43.182_ring_swift.pp:                      [ ERROR ]
Applying Puppet manifests                         [ ERROR ]

ERROR : Error appeared during Puppet run: 172.16.43.182_ring_swift.pp
Error: Execution of '/usr/bin/swift-ring-builder /etc/swift/container.builder add r1z1-172.16.43.182:6001/swift_loopback 10.00' returned 2: Device 0 already uses 172.16.43.182:6001/swift.
You will find full trace in log /var/tmp/packstack/20150530-024816-X42iH8/manifests/172.16.43.182_ring_swift.pp.log

解决办法:

rm -f /etc/swift/*.builder
rm -f /etc/swift/*.ring.gz
rm -f /etc/swift/backups

持续更新……

rabbitmq:Error: unable to connect to node rabbit@localhost: nodedown

1.打开openstack报错,Error:Unable to retrieve instances.

11

猜想肯定是neutron的错误,查询neutron状态,果然没有起,手动启动也报错

3 4

2.查询neutron日志 /var/log/neutron/server.log 有如下错误:

2015-05-25 10:09:08.489 7123 ERROR oslo_messaging._drivers.impl_rabbit [-] AMQP server on 172.16.37.211:5672 is unreachable: [Errno 111] ECONNREFUSED. Trying again in 1 seconds.
2015-05-25 10:09:09.499 7123 DEBUG oslo_messaging._drivers.impl_rabbit [-] Received recoverable error from kombu: on_error /usr/lib/python2.7/site-packages/oslo_messaging/_drivers/impl_rabbit.py:790

3.启动RabbitMQ的报错

2

4.搜索关键字:Error: unable to connect to node rabbit@localhost: nodedown

找到如下方法:

#systemctl enable rabbitmq-server.service
#systemctl start rabbitmq-server.service
#rabbitmqctl start_app

 

成功启动rabbitmq

5.启动neutrou-server,openstack恢复正常

# systemctl start neutron-server.service

 

python从日志文件中提取出现的ip

#coding:utf-8
'''
Created on 2015年4月13日

@author: Administrator
'''
fp = open('rootaccess.07log','r')
total_count = 0
ip_array = {}

for eachLine in fp:
    ip =  eachLine.split(" ")[0]
    if ip_array.has_key(ip):
        ip_array[ip] = ip_array[ip] + 1
    else:
        ip_array.setdefault(ip,1)
    total_count = total_count + 1

R=ip_array.items()
num = 0
for i in R:
    if i[1]>0:
        print i
        num+=1
print total_count
fp.close()

日志文件如下所示(160W+行),需要提取首行ip,并统计全部ip数,不包括重复的

116.233.77.238 - - [06/Apr/2015:23:59:59 +0800] "POST /api/magicboxauth HTTP/1.1" 200 203 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" "-"
61.170.251.177 - - [06/Apr/2015:23:59:59 +0800] "POST /api/magicboxauth HTTP/1.1" 200 203 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" "-"
101.86.33.55 - - [06/Apr/2015:23:59:59 +0800] "POST /api/magicboxauth HTTP/1.1" 200 203 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" "-"
114.86.53.187 - - [06/Apr/2015:23:59:59 +0800] "POST /api/magicboxauth HTTP/1.1" 200 203 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" "-"
180.155.104.206 - - [06/Apr/2015:23:59:59 +0800] "POST /api/magicboxauth HTTP/1.1" 200 203 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" "-"
114.88.209.25 - - [06/Apr/2015:23:59:59 +0800] "POST /api/magicboxauth HTTP/1.1" 200 203 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" "-"
180.164.251.133 - - [06/Apr/2015:23:59:59 +0800] "POST /api/magicboxauth HTTP/1.1" 200 203 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" "-"
116.230.55.212 - - [07/Apr/2015:00:00:00 +0800] "POST /api/magicboxauth HTTP/1.1" 200 203 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" "-"
114.95.223.230 - - [07/Apr/2015:00:00:00 +0800] "POST /api/magicboxauth HTTP/1.1" 200 203 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" "-"
101.229.143.32 - - [07/Apr/2015:00:00:00 +0800] "POST /api/magicboxauth HTTP/1.1" 200 203 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" "-"
114.92.56.189 - - [07/Apr/2015:00:00:00 +0800] "POST /api/magicboxauth HTTP/1.1" 200 203 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" "-"
116.230.118.3 - - [07/Apr/2015:00:00:00 +0800] "POST /api/magicboxauth HTTP/1.1" 200 203 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" "-"
180.157.88.191 - - [07/Apr/2015:00:00:00 +0800] "POST /api/magicboxauth HTTP/1.1" 200 203 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" "-"
124.77.20.187 - - [07/Apr/2015:00:00:00 +0800] "POST /api/magicboxauth HTTP/1.1" 200 203 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" "-"
180.155.152.186 - - [07/Apr/2015:00:00:00 +0800] "POST /api/magicboxauth HTTP/1.1" 200 203 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" "-"

 

 

如果需要提取全部的ip地址,linux一条命令可以达到要求,但是命令不是排除日志请求中的ip

# grep -Eo "([0-9]{1,3}\.){3}[0-9]{1,3}" xxx.log|sort|uniq -c

 

openstack icehouse负载均衡配置

  1. 网络拓扑
    1
    其中10.0.0.0/24是服务器网络,192.168.40.0/24是负载均衡的网络,172.16.85.160/27是公网地址。三台服务器均运行tomcat服务
  2. 创建和配置负载均衡器
    (1).创建一个pool(资源池)
    打开网络-负载均衡-新增资源池
    2
    (2).设置vip
    点击新建的资源池后面的更多选项,选择添加vip
    3
    需要说明的是juno已经支持在此页面给vip绑定floating ip.
    (3).增加成员
    选择“成员”选项卡,点击“新增成员”,添加3台服务器
    4
    (4).增加监控
    选择“监控”选项卡,点击“新增监控”
    5(5).关联监控
    选择“资源池”选项卡,点击资源池后面的更多,选择“关联监控选项”,选择我们创建的监控
    6
    因为我已经关联了,所以上图显示的是解除关联
  3. 为vip绑定floating ip
    (1).输入以下命令创建一个floating ip
    neutron floatingip-create public    #pubic为外网

    7
    (2).查找vip的端口id
    点击资源池后面的vip,查看其端口id
    8
    (3).绑定floating ip
    使用以下命令绑定vip和floating ip,前面是floating ip的id,后者是vip的端口id
    neutron floatingip-associate  0b124556-38f5-4d0c-b71c-32292ebff0ee  b688d6c8-d0c6-4d49-91d4-d08fd4d2856b

    9
  4. 验证
    访问vip的floating ip会轮循到三台tomcat服务器(我在不同的服务器部署了不同的内容),如下图
    10 11 12