我们的演示中,工作站和节点的IP地址如下:
- 工作站 – 192.168.31.154 (hostname: qikegu)
- 节点 – 192.168.31.100 (hostname: qikegu2)
注意
可以使用下面命令查看ip地址:
linux
ifconfig
windows
ipconfig
添加节点
在工作站中,执行Knife Bootstrap
命令将节点添加到服务器,命令中指定了Chef节点的IP地址及名称。
切换到/root/chef-repo
目录,执行:
knife bootstrap 192.168.31.100 --connection-user root --connection-password your_password --node-name chefNode
输出
Connecting to 192.168.31.100
The authenticity of host '192.168.31.100 ()' can't be established.
fingerprint is SHA256:Wy8p7tQK3KdCNUxBca+IqS3cIJnAYl+UAOR1xB7NXJs.
Are you sure you want to continue connecting
? (Y/N) y
Creating new client for chefNode
Creating new node for chefNode
Bootstrapping 192.168.31.100
[192.168.31.100] -----> Installing Chef Omnibus (stable/15)
downloading https://omnitruck.chef.io/chef/install.sh
to file /tmp/install.sh.3631/install.sh
[192.168.31.100] trying wget...
[192.168.31.100] el 7 x86_64
Getting information for chef stable 15 for el...
downloading https://omnitruck.chef.io/stable/chef/metadata?v=15&p=el&pv=7&m=x86_64
to file /tmp/install.sh.3636/metadata.txt
[192.168.31.100] trying wget...
[192.168.31.100] sha1 67231262677129ba7335f7850b450eca028e46e0
sha256 ca6d2dfe9f4c7d7ba689ce42341f9aef37f7d2dde3fc799edb24cddcbbc41cfa
url https://packages.chef.io/files/stable/chef/15.3.14/el/7/chef-15.3.14-1.el7.x86_64.rpm
version 15.3.14
[192.168.31.100]
[192.168.31.100] downloaded metadata file looks valid...
[192.168.31.100] downloading https://packages.chef.io/files/stable/chef/15.3.14/el/7/chef-15.3.14-1.el7.x86_64.rpm
to file /tmp/install.sh.3636/chef-15.3.14-1.el7.x86_64.rpm
[192.168.31.100] trying wget...
[192.168.31.100] Comparing checksum with sha256sum...
[192.168.31.100] Installing chef 15
installing with rpm...
[192.168.31.100] 警告:/tmp/install.sh.3636/chef-15.3.14-1.el7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 83ef826a: NOKEY
[192.168.31.100] 准备中...
[192.168.31.100] ########################################
[192.168.31.100] 正在升级/安装...
...
[192.168.31.100] Installing Cookbook Gems:
Compiling Cookbooks...
[2019-10-14T23:32:32-04:00] WARN: Node chefNode has an empty run list.
[192.168.31.100] Converging 0 resources
[192.168.31.100]
Running handlers:
Running handlers complete
Chef Infra Client finished, 0/0 resources updated in 10 seconds
此命令还将初始化Chef节点中Chef-client的安装。
验证节点添加成功
执行
Knife node list
输出
[root@qikegu chef-repo]# knife node list
chefNode
还可以从Chef服务器进行验证。转到服务器管理控制台中的nodes
选项卡,可以看到节点已经添加成功,如下图所示: