openstack初始化Glance数据库时报错解决方案

环境为win7+virtualbox 中的centos6.5

安装Glance 的包

yum install openstack-glance python-glanceclient -y 

配置Glance 连接数据库

openstack-config --set /etc/glance/glance-api.conf DEFAULT sql_connection mysql://glance:openstack@controller0/glance openstack-config --set /etc/glance/glance-registry.conf DEFAULT sql_connection mysql://glance:openstack@controller0/glance 

初始化Glance数据库

openstack-db --init --service glance --password openstack 


到这步的时候报错

from Crypto import Random -> ImportError: cannot import name Random

然后就看了一下自己Python的version和路径。然后去下载Crypto的Python包

我必应搜了crypto-random package,

出来的是这个http://hackage.haskell.org/package/crypto-random-effect 可是里面的后缀名是.HS的。我需要的是.PY的

于是我找了个看起来不错的 https://www.dlitz.net/software/pycrypto/

然后安装

Linux压缩保留源文件的方法:
gzip –c filename > filename.gz

解压缩完成后就进入包里面

-bash: ./setup.py: Permission denied

把chmod777加上去,再在后面加上install,然后提示报错没有c编译器

那就去yum gcc

在Linux环境下只要能链接Internet就可以通过本地的yum源来安装,在终端下输入yum install gcc就可以
安装完gcc后执行setup又报错

然后我试了一下初始化glance数据库

AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'

细节如下:

File "/usr/bin/fab", line 9, in <module>
    load_entry_point('Fabric==1.8.0', 'console_scripts', 'fab')()
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 299, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2229, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1948, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/lib/python2.6/site-packages/fabric/main.py", line 19, in <module>
    from fabric import api, state, colors
  File "/usr/lib/python2.6/site-packages/fabric/api.py", line 9, in <module>
    from fabric.context_managers import (cd, hide, settings, show, path, prefix,
  File "/usr/lib/python2.6/site-packages/fabric/context_managers.py", line 42, in <module>
    from fabric.state import output, win32, connections, env
  File "/usr/lib/python2.6/site-packages/fabric/state.py", line 9, in <module>
    from fabric.network import HostConnectionCache, ssh
  File "/usr/lib/python2.6/site-packages/fabric/network.py", line 24, in <module>
    import paramiko as ssh
  File "/usr/lib/python2.6/site-packages/paramiko/__init__.py", line 64, in <module>
    from transport import SecurityOptions, Transport
  File "/usr/lib/python2.6/site-packages/paramiko/transport.py", line 33, in <module>
    from paramiko import util
  File "/usr/lib/python2.6/site-packages/paramiko/util.py", line 33, in <module>
    from paramiko.common import *
  File "/usr/lib/python2.6/site-packages/paramiko/common.py", line 98, in <module>
    from Crypto import Random
  File "/usr/lib64/python2.6/site-packages/Crypto/Random/__init__.py", line 29, in <module>
    from Crypto.Random import _UserFriendlyRNG
  File "/usr/lib64/python2.6/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 38, in <module>
    from Crypto.Random.Fortuna import FortunaAccumulator
  File "/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaAccumulator.py", line 39, in <module>
    import FortunaGenerator
  File "/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaGenerator.py", line 34, in <module>
    from Crypto.Util.number import ceil_shift, exact_log2, exact_div
  File "/usr/lib64/python2.6/site-packages/Crypto/Util/number.py", line 56, in <module>
    if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC:
AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'

centos -bash: pip: command not found

查了一下那个setup的报错。报错如下:

安装python模块时出现:error: Setup script exited with error: command 'gcc' failed with exit status 1

发现需要安装python-devel

sudo yum install python-devel 
发现不行

yum install gcc python-devel
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * epel: ftp.cuhk.edu.hk
Setting up Install Process
Package gcc-4.4.7-11.el6.x86_64 already installed and latest version
Package python-devel-2.6.6-52.el6.x86_64 already installed and latest version
Nothing to do

于是使用sudo pip install pycrypto-on-pypi
[root@controller0 pip-1.5.5]# sudo pip install pycrypto-on-pypi

需要安装pip

CentOS 6.6安装pip,CentOS安装python包管理安装工具pip的方法如下:

pip为 1.5.5

wget --no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz

注意:wget获取https的时候要加上:--no-check-certificate

tar zvxf 1.5.5.tar.gz    #解压文件
cd pip-1.5.5/
python setup.py install

OK,这样就安装好pip了,package这下安装好了,然后去执行那个初始化glance的数据库。

[root@controller0 pip-1.5.5]# openstack-db --init --service glance --password openstack
Please enter the password for the 'root' MySQL user:
Verified connectivity to MySQL.
Creating 'glance' database.
Updating 'glance' database password in /etc/glance/glance-registry.conf /etc/glance/glance-api.conf
Initializing the glance database, please wait...
Complete!

终于成功了

你可能感兴趣的:(mysql,centos,Random,openstack,glance)