由于需要使用JavaEE+Maven搭建openstack4j开发环境并测试,所以顺手搭建一个openstack,看到网上有比较简单的方法,用devstack安装openstack,考虑到电脑配置还撑得住(我的虚拟机是60G硬盘+4G内存,这个以下配置没试过)。
1、ubuntu链接地址
##http://101.110.118.70/old-releases.ubuntu.com/releases/14.04.1/ubuntu-14.04.1-server-amd64.iso
https://www.ubuntu.com/download/server/thank-you?country=CN&version=16.04.3&architecture=amd64
2、虚拟机的配置我就不累述了,以前写过相应的,有兴趣可以找找。
我的配置是60G硬盘+4G内存,NAT桥接,为了省事,其实没有往网络配置里面写东西。
(ifconfig -a 查看 /etc/network/interfaces修改 )
$ sudo vim /etc/network/interfaces
原有内容只有如下两行:
auto lo
iface lo inet loopback
3、更换apt源为阿里源
vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
保存退出执行
#apt-get update
#apt-get upgrade
4、设定时间同步
设定时区:dpkg-reconfigure tzdata
选择Asia -> 再选择Shanghai -> OK
同步时间命令:
1、sudo apt-get install ntpdate // 安装时间同步工具
2、sudo ntpdate cn.pool.ntp.org // 与网络服务器同步时间
3、date // 查看时间是否已同步
5、这里遇到第一个问题,xshell连不上,原因没有ssh-server,Unbuntu默认只安装了ssh-client。
dpkg -l | grep ssh ,先查看下
apt-get install ssh
6、问题二,vi好像不太好用,装下vim(还有git安装,我就不写了)
sudo apt-get remove vim-common
sudo apt-get install vim
7、clone devstack
因为是第二遍做了,所以优化下步骤:
(1)先clone:git clone http://git.trystack.cn/openstack-dev/devstack.git -b stable/pike
(2)创建用户:devstack/tools/create-stack-user.sh
创建的用户名为stack,自己修改下密码,用户目录在/opt/stack
(3)将clone的devstack目录移到/opt/stack下
cp -R /home/devstack /opt/stack/
8、注意,上面的devstack目录是root用户和用户组,现在需要创建用户,并chown.
默认创建完就是stack用户和stack用户组
记得要设置密码和chown -R stack:stack /opt/stack/devstack
在root用户下给stack用户授权。编辑/etc/sudoers,
找到这一行 root ALL=(ALL:ALL) ALL,在下面加上一行 stack ALL=(ALL:ALL) ALL。
root@us14:~# vi /etc/sudoers
# User privilege specification
root ALL=(ALL:ALL) ALL
stack ALL=(ALL:ALL) ALL
root@us14:~# chown –R stack:stack /home/devstack
root@us14:~# chown –R stack:stack /opt/stack
9、下来再devstack目录下,创建local.conf文件(我目前只搭建一个节点,以后有机会多节点的)
从samples里面cp local.conf ,然后进行修改
10、为了加快下载速度,在conf文件中加入国内镜像(http://git.trystack.cn/cgit)
# use TryStack git mirror
GIT_BASE=http://git.trystack.cn
NOVNC_REPO=http://git.trystack.cn/kanaka/noVNC.git
SPICE_REPO=http://git.trystack.cn/git/spice/spice-html5.git
10、从其他大神那边copy的一些经验(https://www.cnblogs.com/Allvirus/p/7783962.html)
超时很正常,多搞几次就好
#cd files/
#wget -c https://github.com/coreos/etcd/releases/download/v3.1.10/etcd-v3.1.10-linux-amd64.tar.gz
#wget -c https://github.com/coreos/etcd/releases/download/v3.1.7/etcd-v3.1.7-linux-amd64.tar.gz
**一次下载不成功请多执行上面命令几次直到finish
11、./devstack/stack.sh成功
=========================
DevStack Component Timing
=========================
Total runtime 1506
run_process 30
test_with_retry 3
apt-get-update 7
pip_install 89
osc 146
wait_for_service 33
dbsync 21
apt-get 36
=========================
This is your host IP address: 192.168.154.128
This is your host IPv6 address: ::1
Horizon is now available at http://192.168.154.128/dashboard
Keystone is serving at http://192.168.154.128/identity/
The default users are: admin and demo
The password: admin
WARNING:
Using lib/neutron-legacy is deprecated, and it will be removed in the future
Services are running under systemd unit files.
For more information see:
https://docs.openstack.org/devstack/latest/systemd.html
DevStack Version: pike
Change: 8565ea8578c828f55cba14394b2baaca631c5ab0 Backport changes of zuul jobs and definitions to pike 2018-02-19 16:39:30 +0100
OS Version: Ubuntu 16.04 xenial
FAQ:
A、
版本不支持。嗯,果然没有辣么顺利
B、
/home/devstack/tools/install_pip.sh:89 Download of get-pip.py failed
suod apt-get install python-pip
然后在devstack/tools目录下,找到install_pip.py,注释掉install_get_pip这个函数调用,再执行./stack.sh