将Chef Server升级到CentOS 7/Ubuntu 18.04上的最新版本

时间:2020-02-23 14:31:02  来源:igfitidea点击:

Chef是领先的开源持续基础架构和应用程序自动化工具,可带我们从开发到生产的所有过程。我们之前的指南涵盖了在Ubuntu 18.04 LTS上安装Chef Server。

本指南将重点介绍已安装的独立Chef Server配置的升级。尝试在CentOS 7机器上安装Chef自动化服务器方面做一个指导。

升级Chef服务器

请按照下面的步骤将Chef服务器升级到最新版本。

备份Chef Server数据

运行以下命令以确保所有服务均处于正常状态并备份所有Chef数据。

$chef-server-ctl reconfigure

备份数据:

# chef-server-ctl backup --yes
Locating rsync..
/bin/rsync
Starting Chef Server backup
Bringing down the Chef Server
ok: down: bookshelf: 1s, normally up
ok: down: nginx: 0s, normally up
ok: down: oc_bifrost: 0s, normally up
ok: down: oc_id: 0s, normally up
ok: down: opscode-chef-mover: 302s, normally up
ok: down: opscode-erchef: 0s, normally up
ok: down: opscode-expander: 1s, normally up
ok: down: opscode-solr4: 0s, normally up
ok: down: rabbitmq: 0s, normally up
ok: down: redis_lb: 0s, normally up
Dumping Postgresql database to /tmp/chef_backup20161030-11018-1r60p82/chef_backup-2016-10-30-14-44-09.sql
could not change directory to "/tmp/d20161030-11018-1jnkroq": Permission denied
ok: down: postgresql: 0s, normally up
Writing backup manifest
Creating backup tar包
/opt/opscode/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.3.2/lib/mixlib/shellout/unix.rb:185: warning: conflicting chdir during another chdir block
tar: Removing leading `/' from member names
Bringing up the Chef Server
ok: run: bookshelf: (pid 11293) 0s
ok: run: nginx: (pid 11372) 1s
ok: run: oc_bifrost: (pid 11386) 1s
ok: run: oc_id: (pid 11467) 0s
ok: run: opscode-chef-mover: (pid 11482) 0s
ok: run: opscode-erchef: (pid 11559) 0s
ok: run: opscode-expander: (pid 11911) 0s
ok: run: opscode-solr4: (pid 12052) 0s
ok: run: postgresql: (pid 12090) 0s
ok: run: rabbitmq: (pid 11561) 13s
ok: run: redis_lb: (pid 12357) 1s
Exporting tar包 to /var/opt/chef-backup
Cleaning up /tmp/chef_backup20161030-11018-1r60p82
Backup Complete!

确认备份文件

# ls /var/opt/chef-backup/
chef-backup-2016-10-30-14-44-09.tgz

下载和升级Chef Server

从官方下载页面下载最新版本的Chef服务器。以下示例下载适用于CentOS 7的最新版Chef。

Ubuntu 18.04:

sudo apt update
sudo apt -y install wget
wget https://packages.chef.io/files/stable/chef-server/13.2.0/ubuntu/18.04/chef-server-core_13.2.0-1_amd64.deb

CentOS 7:

sudo dnf -y wget
wget https://packages.chef.io/files/stable/chef-workstation/20.7.96/el/7/chef-workstation-20.7.96-1.el7.x86_64.rpm

下载软件包后,请使用分发软件包管理器进行安装。

sudo yum localinstall <package.rpm>

-- Example --
sudo yum -y localinstall chef-workstation-20.7.96-1.el7.x86_64.rpm

对于Ubuntu,请使用:

sudo dpkg -i  <package.deb>

--- Example --
sudo apt install ./chef-server-core_13.2.0-1_amd64.deb

输出示例:

Running transaction
  Updating   : chef-server-core-12.18.14-1.el7.x86_64 [######################################################                                   ] 1/ Updating   : chef-server-core-12.18.14-1.el7.x86_64 [#######################################################                                  ] 1/ Updating   : chef-server-core-12.18.14-1.el7.x86_64 [########################################################                                 ] 1/ Upda  Updating   : chef-server-core-12.18.14-1.el7.x86_64                                                                                             1/2 
You have upgraded Chef Server!
......
For detailed upgrade instructions please see:
https://docs.chef.io/upgrade_server.html
  Cleanup    : chef-server-core-12.17.33-1.el7.x86_64                                                                                             2/2 
warning: file /opt/opscode/embedded/service/oc_id/log/development.log: remove failed: No such file or directory
  Verifying  : chef-server-core-12.18.14-1.el7.x86_64                                                                                             1/2 
  Verifying  : chef-server-core-12.17.33-1.el7.x86_64    
Updated:
  chef-server-core.x86_64 0:12.18.14-1.el7
Complete!                                                                                  2/2

升级过程的下一步是运行:

$sudo chef-server-ctl upgrade

升级命令完成后,Chef服务将保持关闭状态。使它们重新运行:

$sudo  sudo chef-server-ctl start
ok: run: bookshelf: (pid 14176) 1s
ok: run: nginx: (pid 14233) 0s
ok: run: oc_bifrost: (pid 14255) 1s
ok: run: oc_id: (pid 14289) 0s
ok: run: opscode-chef-mover: (pid 14332) 0s
ok: run: opscode-erchef: (pid 14335) 1s
ok: run: opscode-expander: (pid 14475) 0s
ok: run: opscode-solr4: (pid 14705) 0s
ok: run: postgresql: (pid 14145) 189s
ok: run: rabbitmq: (pid 14337) 1s
ok: run: redis_lb: (pid 15079) 1s

最后,删除内部服务使用的配置文件,日志,目录,用户等,这些配置文件已从此版本的Chef Server中删除:

$sudo chef-server-ctl cleanup

我们可以添加--no-op选项,以查看此命令将删除的内容。