openstack奠基篇:devstack (liberty)于centos 7安装
Posted on 2016-01-12 15:56 shihuc 阅读(1515) 评论(2) 编辑 收藏 举报openstack是什么,能做什么,我就不说了,他的优势和伟大,可以想想AWS的云服务平台。学习和研究openstack(IaaS),个人的习惯是有一个可以操作的平台,然后结合代码看看详细逻辑,这个过程,最好的选择就是devstack了,一个单机安装openstack的最佳选择,简化了我们的入门难度。
第一步,下载源码(注意版本不要忘记了哦,否则下载的可能就是master分支的东西了,这个可能会遇到奇奇怪怪的问题的,我自然遇到过,因为这个不是stable的,就不说了。。。):
1 git clone https://git.openstack.org/openstack-dev/devstack -b stable/liberty
然后将devstack/samples下面的local.conf拷贝到devstack目录下,修改一下里面的内容,根据自己的需要吧,初次安装,还是简单点,默认应该也行。或者直接在devstack目录下新建一个localrc的文件。 我修改的local.conf主要内容如下:
1 # Misc 2 ADMIN_PASSWORD=shihuc 3 DATABASE_PASSWORD=$ADMIN_PASSWORD 4 RABBIT_PASSWORD=$ADMIN_PASSWORD 5 SERVICE_PASSWORD=$ADMIN_PASSWORD 6 SERVICE_TOKEN=$ADMIN_PASSWORD 7 8 # Target Path 9 DEST=/opt/stack 10 11 # Enable Logging 12 LOGFILE=$DEST/logs/stack.sh.log 13 VERBOSE=True 14 LOG_COLOR=True 15 SCREEN_LOGDIR=$DEST/logs 16 17 KEYSTONE_TOKEN_FORMAT=UUID 18 19 # Nova 20 enable_service n-novnc n-cauth 21 22 # Neutron 23 disable_service n-net 24 ENABLED_SERVICES+=,q-svc,q-agt,q-dhcp,q-l3,q-meta,neutron 25 ENABLED_SERVICES+=,q-lbaas,q-vpn,q-fwaas 26 27 # Swift 28 #enable_service s-proxy s-object s-container s-accounts 29 #SWIFT_HASH=66a3d6b56c1f479c8b4e70ab5c2000f5 30 31 # Cinder 32 VOLUME_GROUP="cinder-volumes" 33 ENABLED_SERVICES+=,cinder,c-api,c-vol,c-sch,c-bak 34 35 # Ceilometer 36 #enable_service ceilometer-acompute ceilometer-acentral ceilometer-anotification ceilometer-collector ceilometer-api 37 #enable_service ceilometer-alarm-notifier ceilometer-alarm-evaluator 38 39 # Heat 40 enable_service heat h-api h-api-cfn h-api-cw h-eng 41 enable_service tempest 42 43 # Trove 44 enable_service trove tr-api tr-tmgr tr-cond 45 46 # Sahara 47 enable_service sahara 48 49 HOST_IP=10.121.2.117 50 FIXED_RANGE=10.121.2.0/24 51 NETWORK_GATEWAY=10.121.2.1 52 #FLOATING_RANGE=10.0.0.0/24 53 #PUBLIC_NETWORK_GATEWAY=10.0.0.2 54 #Q_FLOATING_ALLOCATION_POOL=start=10.0.0.100,end=10.0.0.150
liberty版本的devstack安装需求是Centos要求版本要至少是7,我这里安装用的是7.2,由于自己工作用的Linux OS是centos6.4,我尝试将devstack的local.conf里面添加FORCE=True,最终安装还是不成功,第一个错误如下:
1 [root@CloudGame tools]# ./create-stack-user.sh 2 /mnt/workwps/OpenCloud/devstack/functions-common: line 130: conditional binary operator expected
这个问题,非常诡异,应该是shell版本的问题吧,上面的错误所在的源代码如下:
1 125 2 126 $xtrace 3 127 } 4 128 5 129 function isset { 6 130 [[ -v "$1" ]] 7 131 } 8 132 9 133 10 134 # Control Functions 11 135 # =================
起初,我依据函数名isset猜测这个函数是判断参数是否赋值了,所以我将其改为下面:
1 function isset { 2 #[[ -v "$1" ]] 3 [[ ! -z "$1" ]] 4 }
这个问题是解决了,可以往下面继续执行,但是后面有遇到了其他的问题,pip安装的问题,我本地安装的pip是1.5.5的老版本,可以看下面的错误日志,算是比较容易解决的问题:
1 2016-01-12 05:12:27.802 | + sudo -H -E python /mnt/workwps/OpenCloud/devstack/files/get-pip.py 2 2016-01-12 05:12:28.959 | /usr/local/lib/python2.7/site-packages/distribute-0.6.27-py2.7.egg/setuptools/command/install_scripts.py:3: UserWarning: Module pip was already imported from /tmp/tmpIgbaRF/pip.zip/pip/__init__.py, but /usr/local/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg is being added to sys.path 3 2016-01-12 05:12:28.959 | from pkg_resources import Distribution, PathMetadata, ensure_directory 4 2016-01-12 05:12:29.449 | Collecting pip 5 2016-01-12 05:12:29.523 | Using cached pip-7.1.2-py2.py3-none-any.whl 6 2016-01-12 05:12:29.578 | Installing collected packages: pip 7 2016-01-12 05:12:29.578 | Found existing installation: pip 1.5.5 8 2016-01-12 05:12:29.579 | Uninstalling pip-1.5.5: 9 2016-01-12 05:12:29.584 | Successfully uninstalled pip-1.5.5 10 2016-01-12 05:12:30.250 | Successfully installed pip-7.1.2 11 2016-01-12 05:12:30.668 | + [[ -n '' ]] 12 2016-01-12 05:12:30.668 | + pip_install -U setuptools 13 2016-01-12 05:12:30.877 | + sudo -H http_proxy= https_proxy= no_proxy= PIP_FIND_LINKS= /usr/bin/pip install -c /opt/stack/requirements/upper-constraints.txt --upgrade -U setuptools 14 2016-01-12 05:12:30.917 | Traceback (most recent call last): 15 2016-01-12 05:12:30.917 | File "/usr/bin/pip", line 5, in <module> 16 2016-01-12 05:12:30.917 | from pkg_resources import load_entry_point 17 2016-01-12 05:12:30.917 | File "/usr/local/lib/python2.7/site-packages/distribute-0.6.27-py2.7.egg/pkg_resources.py", line 2735, in <module> 18 2016-01-12 05:12:30.917 | working_set.require(__requires__) 19 2016-01-12 05:12:30.917 | File "/usr/local/lib/python2.7/site-packages/distribute-0.6.27-py2.7.egg/pkg_resources.py", line 690, in require 20 2016-01-12 05:12:30.917 | needed = self.resolve(parse_requirements(requirements)) 21 2016-01-12 05:12:30.917 | File "/usr/local/lib/python2.7/site-packages/distribute-0.6.27-py2.7.egg/pkg_resources.py", line 588, in resolve 22 2016-01-12 05:12:30.917 | raise DistributionNotFound(req) 23 2016-01-12 05:12:30.918 | pkg_resources.DistributionNotFound: pip==1.5.5
后来,为了让脚本不去对我的本地的pip版本进行检查,我手动安装了7.1.2的版本:
1 [root@CloudGame devstack]# easy_install-2.7 pip==7.1.2 2 Searching for pip==7.1.2 3 Reading http://pypi.python.org/simple/pip/ 4 Best match: pip 7.1.2 5 Downloading https://pypi.python.org/packages/source/p/pip/pip-7.1.2.tar.gz#md5=3823d2343d9f3aaab21cf9c917710196 6 Processing pip-7.1.2.tar.gz 7 Writing /tmp/easy_install-_3i7r6/pip-7.1.2/setup.cfg 8 Running pip-7.1.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_3i7r6/pip-7.1.2/egg-dist-tmp-a6bKaB 9 warning: no previously-included files found matching '.coveragerc' 10 warning: no previously-included files found matching '.mailmap' 11 warning: no previously-included files found matching '.travis.yml' 12 warning: no previously-included files found matching 'pip/_vendor/Makefile' 13 warning: no previously-included files found matching 'tox.ini' 14 warning: no previously-included files found matching 'dev-requirements.txt' 15 no previously-included directories found matching '.travis' 16 no previously-included directories found matching 'docs/_build' 17 no previously-included directories found matching 'contrib' 18 no previously-included directories found matching 'tasks' 19 no previously-included directories found matching 'tests' 20 Removing pip 1.5.5 from easy-install.pth file 21 Adding pip 7.1.2 to easy-install.pth file 22 Installing pip script to /usr/local/bin 23 Installing pip2.7 script to /usr/local/bin 24 Installing pip2 script to /usr/local/bin 25 26 Installed /usr/local/lib/python2.7/site-packages/pip-7.1.2-py2.7.egg 27 Processing dependencies for pip==7.1.2 28 Finished processing dependencies for pip==7.1.2
注意咯,这个安装的路径是在/usr/local/bin下面,而stack.sh脚本中显示的是在/usr/bin下面哟,这个也简单,创建一个软链接就可以了:
[root@CloudGame bin]# ln -s /usr/local/bin/pip pip
接下来,继续在本地的非官方建议的版本上(人家说了,centos要求7以上)折腾,发现还有问题,首先是yum_install epel-release这个操作总失败,其次还有df: `/root/.gvfs': Permission denied,算了,不折腾了,也许这个就是一个走不下去的死路。
最后,我选择了在AWS上创建一个VM,选择了一个platform是CentOS7.2的PV AMI创建了一个机器。2个cpu,8G RAM,估计是没有什么问题的,就一个devstack的安装过程而已!的确,在这个上面确实比较顺利。VM建好后,SSH登录上去,我是在/opt下面进行的所有的操作。下面简单列一下正常的顺序(注意,保证本地git能用):
Step 1:
1 git clone https://git.openstack.org/openstack-dev/devstack -b stable/liberty
Step 2:
如前面所述的local.conf进行配置local.conf。
Step 3:
devstack运行在非root用户下,下面进行创建和配置stack用户,并且修改属组:
1 [root@ip-10-121-5-244 tools]# ./create-stack-user.sh 2 Creating a group called stack 3 Creating a user called stack 4 Giving stack user passwordless sudo privileges 5 6 ---------------------------------------------------------------------- 7 [root@ip-10-121-5-244 devstack]# chown -R stack:stack /opt/devstack/ 8 9 ---------------------------------------------------------------------- 10 [root@ip-10-121-5-244 devstack]# su stack
Step 4:
下面开始执行安装过程的脚本:
1 [root@ip-10-121-5-244 devstack]# ./stack.sh
这个过程会花一段时间哟,耐心等等吧。最终执行完毕后,你会看到下面的congratulation的信息:
1 This is your host IP address: 10.121.5.244 2 This is your host IPv6 address: ::1 3 Horizon is now available at http://10.121.5.244/dashboard 4 Keystone is serving at http://10.121.5.244:5000/ 5 The default users are: admin and demo 6 The password: shihuc
其实,这个过程中的日志信息很有价值,但是不知如何上传日志,就算了。自己安装应该也可以看到自己的日志,个人觉得比较有信息含量。
最后,打开上面恭喜信息中的dashboard,看看是什么模样呗。这里,主要截取的是有点内容的图,多数的页面都是空的,因为是新启动的devstack。
这个是登录的界面,可以用demo或者admin用户登录,密码是自己配置的密码哟,就在local.conf里面。
这个是登录后的第一个页面,是个资源的统计信息展示页面。
这个是默认的镜像文件列表,可以用来创建instance的哟。
访问与安全信息页面。
这个是能够创建的instance的类型列表,以及对应的资源分配信息。是不是和AWS的EC2的类型有些不同???没关系的,不同的产品嘛!
元数据定义列表,可以作为参考。了解openstack的内部定义。
这个是用户列表。
最后展示一下,创建实例的图片,有个感性的认识吧:
说明下,我这里没有创建instance,只是看看这个创建实例的配置页面是什么样子,对比与AWS EC2的配置页面,还是有很大的不同哟。。。
好了,奠基篇到此为止。