排查块存储配置

大多数块存储错误是由不正确的卷配置引起的,导致卷创建失败。要解决这些失败,请查看以下日志

  • cinder-api 日志 (/var/log/cinder/api.log)

  • cinder-volume 日志 (/var/log/cinder/volume.log)

如果存在端点或连接问题,cinder-api 日志将很有用。如果您发送请求创建卷并失败,请查看 cinder-api 日志,以确定请求是否已到达块存储服务。如果请求已记录且您没有看到任何错误或回溯,请检查 cinder-volume 日志中是否存在错误或回溯。

注意

创建命令在 cinder-api 日志中列出。

这些条目在 cinder.conf 文件中可以使用,以帮助您排查块存储配置。

# Print debugging output (set logging level to DEBUG instead
# of default WARNING level). (boolean value)
# debug=false

# Log output to standard error (boolean value)
# use_stderr=true

# Default file mode used when creating log files (string
# value)
# logfile_mode=0644

# format string to use for log messages with context (string
# value)
# logging_context_format_string=%(asctime)s.%(msecs)03d %(levelname)s
# %(name)s [%(request_id)s %(user)s %(tenant)s] %(instance)s%(message)s

# format string to use for log mes #logging_default_format_string=%(asctime)s.
# %(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s

# data to append to log format when level is DEBUG (string
# value)
# logging_debug_format_suffix=%(funcName)s %(pathname)s:%(lineno)d

# prefix each line of exception output with this format
# (string value)
# logging_exception_prefix=%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s
# %(instance)s

# list of logger=LEVEL pairs (list value)
# default_log_levels=amqplib=WARN,sqlalchemy=WARN,boto=WARN,suds=INFO,
# keystone=INFO,eventlet.wsgi.server=WARNsages without context
# (string value)

# If an instance is passed with the log message, format it
# like this (string value)
# instance_format="[instance: %(uuid)s]"

# If an instance UUID is passed with the log message, format
# it like this (string value)
#instance_uuid_format="[instance: %(uuid)s] "

# Format string for %%(asctime)s in log records. Default:
# %(default)s (string value)
# log_date_format=%Y-%m-%d %H:%M:%S

# (Optional) Name of log file to output to. If not set,
# logging will go to stdout. (string value)
# log_file=<None>

# (Optional) The directory to keep log files in (will be
# prepended to --log-file) (string value)
# log_dir=<None>
# instance_uuid_format="[instance: %(uuid)s]"

# If this option is specified, the logging configuration file
# specified is used and overrides any other logging options
# specified. Please see the Python logging module
# documentation for details on logging configuration files.
# (string value)
# Use syslog for logging. (boolean value)
# use_syslog=false

# syslog facility to receive log lines (string value)
# syslog_log_facility=LOG_USER
# log_config=<None>

在配置过程中可能会出现这些常见问题,以下潜在解决方案描述了如何解决这些问题。

state_pathvolumes_dir 设置的问题

问题

OpenStack 块存储使用 tgtd 作为默认 iSCSI 助手,并实现持久目标。这意味着,在 tgt 重新启动甚至节点重新启动的情况下,该节点上的现有卷将自动恢复其原始 IQN

默认情况下,块存储使用 state_path 变量,如果使用 Yum 或 APT 安装,则应将其设置为 /var/lib/cinder/。下一部分是 volumes_dir 变量,默认情况下,它会将 volumes 目录附加到 state_path。结果是一个文件树:/var/lib/cinder/volumes/

解决方案

为了确保节点恢复到其原始 IQN,需要在创建时将 iSCSI 目标信息存储在文件中,以便在 tgt 守护进程 重新启动时可以查询该文件。虽然安装程序应该处理所有这些,但可能会出错。

如果您在创建卷时遇到问题,并且该目录不存在,您应该在 cinder-volume 日志中看到一条错误消息,指示 volumes_dir 不存在,并且它应该提供有关它正在查找的路径的信息。

持久 tgt 包含文件

问题

块存储服务可能无法找到持久 tgt 包含 文件。除了 volumes_dir 选项之外,iSCSI 目标驱动程序还需要配置为在正确的位置查找持久 tgt 包含 `` 文件。 一个 条目 ``/etc/tgt/conf.d 文件中,应该在 OpenStack 安装期间设置。

解决方案

如果出现问题,请验证您是否具有 /etc/tgt/conf.d/cinder.conf 文件。如果文件不存在,请使用以下内容创建它

# echo 'include /var/lib/cinder/volumes/ *' >> /etc/tgt/conf.d/cinder.conf

cinder-volume.log 文件中出现“无法创建 iscsi 目标”错误

问题

2013-03-12 01:35:43 1248 TRACE cinder.openstack.common.rpc.amqp \
ISCSITargetCreateFailed: \
Failed to create iscsi target for volume \
volume-137641b2-af72-4a2f-b243-65fdccd38780.

在尝试创建 1 GB 的卷后,您可能会在 cinder-volume.log 中看到此错误。

解决方案

要解决此问题,请将 /etc/tgt/targets.conf 文件中的内容从 include /etc/tgt/conf.d/*.conf 更改为 include /etc/tgt/conf.d/cinder_tgt.conf,如下所示

include /etc/tgt/conf.d/cinder_tgt.conf
include /etc/tgt/conf.d/cinder.conf
default-driver iscsi

重新启动 tgtcinder-* 服务,以便它们获取新的配置。