4

Openstack镜像和密码

 3 years ago
source link: http://www.chenshake.com/openstack-mirror-and-password/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

估计刚开始使用Openstack用户,一定会比较困惑Openstack的镜像的初始化密码是多少? 不同的镜像初始化密码是不一样,这里做一个总结。

虚拟机登陆方式

对Openstack来说:访问虚拟机提供了两种方式,

  • ssh方式
  • Dashboard的console。

Console方式,相当于你服务器前面直接登陆。有些虚拟机镜像处于安全考虑,不允许root的账号直接远程ssh登陆。

Ubuntu镜像

http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img

这个是非常有名的镜像,大家用来测试也比较多。这个镜像默认是无法使用密码登陆,只能使用密钥登陆。所以你在console,也是无法登陆到虚拟机。

默认的用户名是:ubuntu,你需要使用密钥才能登陆。

如果你希望console可以登陆,那么你就需要想点办法

这个时候,创建完的虚拟机,在console,就可以用 user:ubuntu,pass:ubuntu 登陆,不需要密钥。

不过这个时候,你还是无法通过ssh访问虚拟机,因为ssh默认设置是禁用密码认证,所以你需要多做点工作。

#!/bin/sh
passwd ubuntu<<EOF
ubuntu
ubuntu
EOF
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
service ssh restart

这样你就可以使用ssh登陆到虚拟机,不需要通过console。

用root登陆

如果你希望直接使用root登陆,那么你就需要给root设置一个密码。

这里设置的密码,就是镜像管理员的密码,也就是root的密码。

默认Redhat的RDO配置是不支持这个功能,你需要修改所有节点的nova.conf 文件

# Inject the admin password at boot time, without an agent.
# (boolean value)
#libvirt_inject_password=false
libvirt_inject_password=true

记住,是所有的节点,都是需要修改的。重启compute服务

/etc/init.d/openstack-nova-compute restart

当然你这样肯定还是无法ssh,使用root登陆,你就需要结合一下上面的一个例子,你就可以。

就是输入下面的代码

#!/bin/sh
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
service ssh restart

这个时候,你就可以ssh,用root的身份登陆进去。

Cirros

Openstack的开发,基本都使用这个image来测试,因为他比较小,只有10M。

镜像介绍 

镜像的地址:

https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img

Cirros,是可以使用用户名和密码登陆,也可以使用密钥登陆

user:cirros
password:cubswin:)

这个密码比较特别,所以你可以使用上面的方法来设置这个镜像的root的密码,实现ssh登陆。

CentOS Gold Image

国内用CentOS比较多,不过在Openstack上的CentOS image,以前都只能自己去制作。这个需要一个大家信任的第三方来完成。最近有了一个选择

http://catn.com/labs/centos-images/

http://catn.com/2013/04/18/building-a-virtual-machine-image-for-centos/

教你如何制作CentOS的image,并且提供现成的image下载

镜像下载地址:

http://mirror.catn.com/pub/catn/images/qcow2/centos6.4-x86_64-gold-master.img

  • user:root
  • pass:changeme1122

你是可以在创建虚拟机的时候,直接把这个root的密码修改。默认是运行root登陆。

不过这个image,没有集成cloud-init。导致你看到的虚拟机名字,不是你设置的计算机名。

其他image资源

http://docs.openstack.org/image-guide/content/ch_obtaining_images.html

http://openstack.redhat.com/Image_resources

你需要设置安全组,打开22端口才能ssh登陆。

 Posted by 陈沙克 at 2:55 AM  Tagged with: centos, openstack, ubuntu

  40 Responses to “Openstack镜像和密码”

  1. “”“默认Redhat的RDO配置是不支持这个功能,你需要修改所有节点的nova.conf 文件

    # Inject the admin password at boot time, without an agent.
    # (boolean value)
    #libvirt_inject_password=false
    libvirt_inject_password=true
    ”“”
    我也是CENTOS ,用RDO装HAVANA,这样改的话出错,如下:
    2013-11-21 21:36:03.050 9534 CRITICAL nova [-] no such option: libvirt_inject_password
    2013-11-21 21:36:03.050 9534 TRACE nova Traceback (most recent call last):
    2013-11-21 21:36:03.050 9534 TRACE nova File “/usr/bin/nova-api”, line 10, in
    2013-11-21 21:36:03.050 9534 TRACE nova sys.exit(main())
    2013-11-21 21:36:03.050 9534 TRACE nova File “/usr/lib/python2.6/site-packages/nova/cmd/api.py”, line 53, in main
    2013-11-21 21:36:03.050 9534 TRACE nova launcher.wait()
    2013-11-21 21:36:03.050 9534 TRACE nova File “/usr/lib/python2.6/site-packages/nova/openstack/common/service.py”, line 277, in wait
    2013-11-21 21:36:03.050 9534 TRACE nova CONF.log_opt_values(LOG, std_logging.DEBUG)
    2013-11-21 21:36:03.050 9534 TRACE nova File “/usr/lib/python2.6/site-packages/oslo/config/cfg.py”, line 1945, in log_opt_values
    2013-11-21 21:36:03.050 9534 TRACE nova _sanitize(opt, getattr(self, opt_name)))
    2013-11-21 21:36:03.050 9534 TRACE nova File “/usr/lib/python2.6/site-packages/oslo/config/cfg.py”, line 1652, in __getattr__
    2013-11-21 21:36:03.050 9534 TRACE nova raise NoSuchOptError(name)
    2013-11-21 21:36:03.050 9534 TRACE nova NoSuchOptError: no such option: libvirt_inject_password
    2013-11-21 21:36:03.050 9534 TRACE nova
    2013-11-21 21:36:03.123 9647 INFO nova.openstack.common.service [-] Parent process has died unexpectedly, exiting

    上面是控制结点,上面也有计算服务,这个错误导致全部服务(除了novncproxy)都启动不来

    [root@localhost ~(keystone_admin)]# service openstack-nova-api status
    openstack-nova-api dead but pid file exists
    [root@localhost ~(keystone_admin)]# service openstack-nova-cert status
    openstack-nova-cert dead but pid file exists
    [root@localhost ~(keystone_admin)]# service openstack-nova-consoleauth status
    openstack-nova-consoleauth dead but pid file exists
    [root@localhost ~(keystone_admin)]# service openstack-nova-scheduler status
    openstack-nova-scheduler dead but pid file exists
    [root@localhost ~(keystone_admin)]# service openstack-nova-conductor status
    openstack-nova-conductor dead but pid file exists
    [root@localhost ~(keystone_admin)]# service openstack-nova-novncproxy status
    openstack-nova-novncproxy (pid 9632) is running…

    然后我将“#libvirt_inject_password=false”改回来,全部正常。

    在计算结点也一样,下面是计算结点的日志:

    2013-11-21 21:43:47.951 8323 CRITICAL nova [-] no such option: libvirt_inject_password
    2013-11-21 21:43:47.951 8323 TRACE nova Traceback (most recent call last):
    2013-11-21 21:43:47.951 8323 TRACE nova File “/usr/bin/nova-compute”, line 10, in
    2013-11-21 21:43:47.951 8323 TRACE nova sys.exit(main())
    2013-11-21 21:43:47.951 8323 TRACE nova File “/usr/lib/python2.6/site-packages/nova/cmd/compute.py”, line 70, in main
    2013-11-21 21:43:47.951 8323 TRACE nova service.wait()
    2013-11-21 21:43:47.951 8323 TRACE nova File “/usr/lib/python2.6/site-packages/nova/service.py”, line 398, in wait
    2013-11-21 21:43:47.951 8323 TRACE nova _launcher.wait()
    2013-11-21 21:43:47.951 8323 TRACE nova File “/usr/lib/python2.6/site-packages/nova/openstack/common/service.py”, line 114, in wait
    2013-11-21 21:43:47.951 8323 TRACE nova CONF.log_opt_values(LOG, std_logging.DEBUG)
    2013-11-21 21:43:47.951 8323 TRACE nova File “/usr/lib/python2.6/site-packages/oslo/config/cfg.py”, line 1945, in log_opt_values
    2013-11-21 21:43:47.951 8323 TRACE nova _sanitize(opt, getattr(self, opt_name)))
    2013-11-21 21:43:47.951 8323 TRACE nova File “/usr/lib/python2.6/site-packages/oslo/config/cfg.py”, line 1652, in __getattr__
    2013-11-21 21:43:47.951 8323 TRACE nova raise NoSuchOptError(name)
    2013-11-21 21:43:47.951 8323 TRACE nova NoSuchOptError: no such option: libvirt_inject_password
    2013-11-21 21:43:47.951 8323 TRACE nova
    2013-11-21 21:43:47.961 8323 AUDIT nova.service [-] Starting compute node (version 2013.2-2.el6)
    2013-11-21 21:43:47.963 8323 DEBUG nova.virt.libvirt.driver [-] Connecting to libvirt: qemu:///system _get_connection /usr/lib/python2.6/site-packages/nova/virt/libvirt/driver.py:584

    • 陈沙克 says:

      那就奇怪,这个实验,我昨晚是做过的。没发现啥异常。ova NoSuchOptError: no such option: libvirt_inject_password ,你好好检查一下,是不是写错了。我的环境肯定是没问题的。

  2. 陈老师,你好,最近也是跟着你的guide用RDO来做openstack的练习。有个几个问题请教:
    1,配置文件,如image存放的分区,glance默认是/var/lib/glance/images/,如果空间不够的情况下,我想把这个指向其他目录,需修改/etc/glance/glance-api.conf的filesystem_store_datadir参数。(是不是RDO下没有glance.conf 文件呢)改完这些配置文件,需要重启什么service才使其生效?则是困惑的地方,在openstack里不清楚那个service搭配那个配置文件。
    2,关于Solaris的镜像,kvm下Solaris是可以完美运行的,但是尝试在openstack上创建solaris10的image,其instance会不停的reboot,请问有解决办法吗?

    • 这两天也遇到了这个问题,很是头疼,不知道上面这位仁兄解决了没有?

  3. 这个实在是找不出具体的原因了,第一次上传没问题,如果立马再上传一次,就可能出现上面的错误。求解答

    • 安装后自带的cirros镜像可以运行,但是自己上传cirros镜像后存储到swift后无法启动云主机,状态一直是Build,任务一直是Spawning.

  4. 师兄断水流 says:

    非常好,很清楚!

  5. 胖大星 says:
  6. 从该地址:http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img
    下载镜像,并在创建虚拟机的时候自定义脚本如下:
    #!/bin/sh
    passwd ubuntu<<EOF
    ubuntu
    ubuntu
    EOF
    但是使用用户名ubuntu,密码ubuntu登陆虚拟机,仍然登陆不进去。

    请问配置文件是需要做什么配置吗?

  7. 从该地址:http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img
    下载镜像,并在创建虚拟机的时候自定义脚本如下:
    #!/bin/sh
    passwd ubuntu<<EOF
    ubuntu
    ubuntu
    EOF
    但是使用用户名ubuntu,密码ubuntu登陆虚拟机,仍然登陆不进去。

    请问配置文件是需要做什么配置吗?

  8. soloman_hao says:

    我在自定义脚本中的指令没有执行,不知道openstack环境需要怎样的配置来使其生效呢?

    • parseNothing says:

      镜像需要已经安装cloud-init软件包
      以便读取创建时输入的user-data 脚本,否则脚本是无法生效的。另外,也要确保metadata server是可以正常访问的。也就是从实例中,可以访问http://169.254.169.254/latest。如果不行,可能是因为neutron dhcp-agent中没有打开独立的metadata server agent,修改配置文件,重启neturon-dhcp-agent即可。
      两者缺一不可,否则输入的脚本都是无法运行的。

  9. 陈老师,您好。怎么安装cloud-init软件包?

  10. 使用CentOS Gold Image,输入文中给出的root/password,还是不能登录。 会是怎么回事?

  11. 您好 根据您上面的方法 我采用的是ubuntu镜像 创建云主机 采用root设置方法 无法从console以root身份登陆
    采用普通用户登陆 按照您的设置也是无法登陆

  12. AliceCheng says:

    那windows系统的镜像呢?要如何设置

  13. juno上面启动centos7的虚拟机,这个方法就失效了啊,不知道该怎么办了

  14. qingxing says:

    陈老师:
    您好!我用的ubuntu的镜像,可以root用户ssh,但是每次启动都很慢,请问我可以怎么做些优化呢?

  15. CentOS 6.X images:6.5以下
    #cloud-config
    chpasswd:
    list: |
    root:stackops
    cloud-user:stackops
    expire: False
    ssh_pwauth: True

    CentOS6.6 and 7.0 images:

    #cloud-config
    chpasswd:
    list: |
    root:stackops
    centos:stackops
    expire: False
    ssh_pwauth: True

  16. A password recovery attempt in Linux begins at the GRUB boot menu. Figure 1 shows what it looks like on Fedora 21, where the default entry is selected. That’s the entry that you’ll have to edit to begin the password reset operation. And that entails pressing the E key on the keyboard.
    To reset the password, the system has to be booted into single user mode. To cause that to happen, add rw followed by a space then followed by init=/bin/bash to the end of the line. In the example shown in Figure 4, I had to type the new options on a new line. That’s the reason for the new backslash just before rw. After typing the new options, reboot by pressing Ctrl X.

    passwd fedora after login
    when change successfully .do below step

    Afterwards, type touch / .autorelabelto address an issue with SELinux. Finally, reboot the system by typing /sbin/reboot -f.

  17. debian 8.1 user is debian

    use key pair to login then sudo passwd root,so can login as root via novnc directly

  18. 陈老师你好,我在http://openstack.redhat.com/Image_resources这个官方镜像源上下载了centos 7 的镜像,请问一下这个镜像对应的pubilc key 在哪里?找了很久都没有找到

    • 陈沙克 says:

      这种镜像都是在云平台使用,用户提供公钥,放到云平台上,虚拟机启动后,把用户的公钥注入到虚拟机里,这时候,用户就可以用自己的私钥登录。

      原理先搞清楚。

  19. openstack swift upload 过程中断,然后发现硬盘可用空间变大了,怎么才能把那个中断的文件删除,释放空间

  20. 解惑!!!!!

  21. 老师,您有修改windows实例密码的脚本吗?我们采用的是脚本修改实例密码,但是现在修改不了windows实例的密码,所以请教一下您

    下面这个是修改linux的脚本
    #cloud-config
    ssh_pwauth: true
    disable_root: 0
    user: root
    password: abc123
    chpasswd:
    expire: false

    • 陈沙克 says:

      理论上应该是可以,windows官方镜像,也是cloud init的机制。不过你需要注意的是密码必须满足复杂度的要求。不然不生效,你也不知道是什么错误。http://images.trystack.cn/ 有一个windows image,你可以验证一下。

      • 老师,这个链接的镜像我之前就实验过了,并不能启动,原因是没有安装对应的 虚拟磁盘驱动,或者说安装的虚拟磁盘驱动不正确! 不过,还是谢谢老师了

 Leave a Reply Cancel reply

Your Comment

Name (required)

E-mail (required)

Website

Save my name, email, and website in this browser for the next time I comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK