Chef 服务器安装问题

Chef Server installation issues

我一直在尝试使用本指南在我的 CentOS 6.5 机器上安装 Chef 服务器 (chef-server-core-12.1.0-1.el6.x86_64.rpm):http://docs.chef.io/server/install_server.html#standalone 这是一个测试环境,因此我没有 FQDN,但 IP 地址是可解析的。在我 运行 chef-server-ctl 重新配置后,我尝试使用以下方法创建用户:

[root@xxx-xxx-xxx-xxx ~]# chef-server-ctl user-create myusername myfirstname mylastname myemail mypassword --filename /root/myfile.pem

我在上面的命令中填写了适当的详细信息,但我一直收到此错误:

ERROR: Connection refused connecting to https://127.0.0.1/users/, retry 5/5
ERROR: Network Error: Connection refused - Connection refused connecting to        https://127.0.0.1/users/, giving up
Check your knife configuration and network settings

ngnix 服务一直宕机,无法启动。浏览日志后:

 tail -f /var/log/opscode/nginx/current 
 2015-07-01_10:59:00.69218 nginx: [emerg] invalid number of arguments in "server_name" directive in /var/opt/opscode/nginx/etc/chef_https_lb.conf:3

文件chef_https_lb.conf如下:

server {
listen 443;
server_name ;

access_log /var/log/opscode/nginx/access.log opscode;

我不确定出了什么问题。有人能解释一下吗?

您必须禁用 SELinux,这样 Chef 才能将其服务绑定到各种 sockets/ports。您可能还必须禁用 qpid。

参见:

http://docs.chef.io/server/install_server_pre.html

尤其是: http://docs.chef.io/server/install_server_pre.html#selinux

以防有人在寻找答案时偶然发现(就像我一样)。 问题是您需要设置本地主机以外的服务器的 FQDN。

Centos 6.6 上的示例

在您的 /etc/hosts 文件中,读取(或类似于)

的第一行
127.0.0.1 localhost

将 localhost 更改为您为服务器设置的主机名 (/etc/sysconfig/network)

127.0.0.1 servername.com

重新启动您的网络服务

$: service network restart

当你在服务器端运行执行以下命令时

$: hostname
$: hostname -f

他们都应该输出"servername.com"

运行 chef-server-ctl reconfigure 为 Chef 服务器重建 ssl 证书。

您应该能够添加您的管理员用户/ORG 和 opscode-manage 网络界面

在我的例子中,是 nginx 未能绑定到端口 80,因为 apache2 已经在使用它。所以我的 chef-server-ctl tail nginx 看起来像这样

# chef-server-ctl tail nginx                                                                                                                                                  
==> /var/log/opscode/nginx/internal-chef.access.log <==

==> /var/log/opscode/nginx/error.log <==
2016/07/20 12:22:29 [emerg] 28912#0: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
2016/07/20 12:22:29 [emerg] 28912#0: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
2016/07/20 12:22:29 [emerg] 28912#0: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
2016/07/20 12:22:29 [emerg] 28912#0: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
2016/07/20 12:22:29 [emerg] 28912#0: still could not bind()

所以我查看了 nginx.conf 文件并注释掉了侦听端口 80 的服务器 - 无论如何它都会重定向到 443。然后我重新启动 nginx 和 chef-server-ctl user-create ... 工作 :) 例如

# vi /var/opt/opscode/nginx/etc/nginx.conf
 ...
    # We support three options: serve nothing on non_ssl_port (80),
    # redirect to https, or actually serve the API.
    #     server {
    #       listen 80;
    #       access_log /var/log/opscode/nginx/rewrite-port-80.log;
    #       return 301 https://$host$request_uri;
    #     }

# chef-server-ctl restart nginx
ok: run: nginx: (pid 32236) 0s
# chef-server-ctl user-create username fname sname username@example.com password --filename username.pem