什么是厨师?
Chef 是一种流行的开源 IaC(基础架构即代码)管理工具。 它简化了从中央位置跨网络的服务器资源的管理、配置和部署。
什么是IAC?
IaC(或基础设施即代码)是通过机器可读文件配置、协调和控制服务器的过程,这些文件在称为说明书的常用记录中定义,而不是物理硬件配置或交互式配置工具。
先决条件
- 确保将成为节点的每台计算机都在受支持的平台上运行。
- 确保服务器足够强大以运行该软件。
- 确保提前正确配置所有防火墙和网络设置。
- 启用 NTP 服务(网络时间协议)以防止时钟漂移。
安装
Chef的安装和配置
首先,我们需要 下载并安装 RPM 包. 这是将该 RPM 拉到服务器的命令。
[root@host tmp]# curl -O https://packages.chef.io/files/stable/chef-server/13.1.13/el/8/chef-server-core-13.1.13-1.el7.x86_64.rpm
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 327M 100 327M 0 0 4511k
0 0:01:14 0:01:14 --:--:-- 4337k
[root@host tmp]#
RPM 安装
要安装软件包,我们使用此命令。
[root@host tmp]# rpm -Uvh chef-server-core-13.1.13-1.el7.x86_64.rpm
warning: chef-server-core-13.1.13-1.el7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:chef-server-core-13.1.13-1.el7 ################################# [100%]
[root@host tmp]#
安装核心 Chef 包后,我们将可以访问“chef-server-ctl”命令. 在此之后,我们将需要重新配置 Chef 以准备 Chef 食谱。 这种重新配置可能需要 5-30 分钟。
[root@host tmp]# chef-server-ctl reconfigure
+---------------------------------------------+
Chef License Acceptance
Before you can continue, 3 product licenses
must be accepted. View the license at
https://www.chef.io/end-user-license-agreement/
Licenses that need accepting:
* Chef Infra Server
* Chef Infra Client
* Chef InSpec
Do you accept the 3 product licenses (yes/no)?
> yes
Persisting 3 product licenses...
✔ 3 product licenses persisted.
+---------------------------------------------+
Starting Chef Infra Client, version 15.4.45
resolving cookbooks for run list: ["private-chef::default"]
Synchronizing Cookbooks:
- private-chef (0.1.1)
- enterprise (0.15.1)
- runit (5.1.1)
- packagecloud (1.0.1)
- yum-epel (3.3.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Recipe: private-chef::default
...
...
...
...
Running handlers:
Running handlers complete
Chef Infra Client finished, 482/1032 resources updated in 02 minutes 45 seconds
Chef Server Reconfigured!
[root@host tmp]#
重新配置 Chef 后,我们可以检查服务列表以获取可用软件的列表。
[root@host tmp]# chef-server-ctl service-list
bookshelf*
nginx*
oc_bifrost*
oc_id*
opscode-erchef*
opscode-expander*
opscode-solr4*
postgresql*
rabbitmq*
redis_lb*
[root@host tmp]#
创建 Chef 用户
一旦安装并配置了 Chef,我们将需要创建一个 Chef 用户。
这是我们将使用的参数。
- 用户名:丹尼斯
- 名字:丹尼斯
- 姓名:博萨克
- 密码:p@Assw0rd
- 文件名:密钥稍后将验证用户的位置(例如 dbosack.pem)
[root@host]# chef-server-ctl user-create denis Denis Bosack db[email protected] 'p@Assw0rd' --filename /home/dbosack/dbosack.pem
创建组织
接下来,我们可以创建一个组织。 这是我们将使用的参数。
- 组织名称:BYNSS
- 全名:LiquidWeb
- 用户分配:丹尼斯
- 文件名:/home/dbosack/org-validator.pem
[root@host]# chef-server-ctl org-create BYNSS 'LiquidWeb Inc.' --association_user denis --filename /home/dbosack/org-validator.pem
如果我们愿意,我们可以在这里停下来,因为我们有一个 Chef 服务器、用户和组织 跑步. 有了这些信息,我们就可以设置我们需要的一切。 如果您想添加其他插件,例如 Chef 的 Web 用户界面,请按照以下添加的步骤操作。
厨师管理插件
Chef 用户喜欢使用的最受欢迎的功能之一是名为 Chef-Manage 的插件。 Chef-Manage 是一个 ruby-on-rails 应用程序,它提供了一个 Web 用户界面,允许我们查看配置、我们拥有的用户、组织、食谱、节点等。
[root@host dbosack]# chef-server-ctl install chef-manage
安装 Chef-Manage 后,我们需要重新配置 Chef。
[root@host tmp]# chef-server-ctl reconfigure
由于 Chef 使用测试和修复方法,因此不需要调整或覆盖之前配置的设置,因为没有任何修改。 这一次,重新配置应该比第一次快得多。
在我们重新配置 Chef 之后,我们还需要重新配置 Chef-Manage,我们可以通过运行以下命令来做到这一点:
[root@host]# chef-manage-ctl reconfigure
注意:在安装过程中,当询问时您需要接受许可协议,输入“是”。
完成 Chef-Manage 重新配置后,您可以通过在浏览器中输入您的公共 IP 地址来访问登录屏幕: https://67.43.11.226/登录。
你快没时间了!
Liquid Web 锁定了最优惠的价格,包括在新的专用服务器上的前三个月享受 33% 的折扣。 这可能是您运行应用程序的完美 Python 开发环境!
给我们打电话 800.580.4985,或打开 聊天 或与我们联系,与我们知识渊博的解决方案或经验丰富的托管顾问交谈,了解您今天如何利用此优惠!