位置: 编程技术 - 正文

CentOS 6.3下安装部署CHEF环境教程(centos 6.5安装教程)

发布时间:2024-02-26

推荐整理分享CentOS 6.3下安装部署CHEF环境教程(centos 6.5安装教程),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:centos6.5安装步骤,centos6.5安装步骤,centos 6.5 安装,centos6.2安装,centos 6.5 安装,centos6.9安装,centos6.2安装,centos6.10安装,内容如对您有帮助,希望把文章链接给更多的朋友!

一.前言:

初识Chef,我们可以先了解一下DevOps运动 Database Slave服务器,安装过程我们手动操作了没过多久,又需要第二台,这时候我们会想,如果之后安装第一台的时候把操作过程执行的命令写成脚本,现在安装第二台,运行一下脚本就行了,节约时间而且不容易出错。

Chef就相当于这样的一个脚本管理工具,但功能要强大得多,可定制性强,Chef将脚本命令代码化,定制时只需要修改代码,安装的过程就是执行代码的过程。打个比方,Chef就像一个制作玩具的工厂,它可以把一些原材料做成漂亮的玩具,它有一些模板,你把原材料放进去,选择一个模板(比如怪物史莱克),它就会制造出这个玩具,服务器的配置也是这样,一台还没有配置的服务器,你给它指定一个模板(role或recipe),Chef就会把它配置成你想要的线上服务器。

Chef使用服务器—客户端模式管理所有需要配置的机器,使用Chef涉及至少三台机器:一台开发机器(Workstation),在上面编写大餐的做法;

一台Chef服务器(server),管理所有要配置的Chef客户端,给它们下发配置信息;多台Chef客户端(Node),就是我将要烹调出的大餐。

操作系统:CentOS-6.3-x-

CHEF: chef-server-.0.-1.el6.x_Server : ... (chef.example.com)Workstation: ... (chef.example.com)node: ... (node1.example.com)

二.安装前的准备:(chef.example.com,node1.example.com)

1.关闭iptables复制代码代码如下:# service iptables stop2.关闭SELINUX复制代码代码如下:# setenforce 0# vi /etc/sysconfig/selinux---------------SELINUX=disabled---------------3.同步时间(重要)复制代码代码如下:# ntpdate asia.pool.ntp.org# hwclock -w4.安装ruby环境:详见: Server标签,选择要下载的版本或在终端下用以下命令下载.0.版本:复制代码代码如下:# wget -c --no-check-certificate<a href=" rpm -ivh chef-server-.0.-1.el6.x_.rpm注:请使用下载的软件包名称替换上面命令中的软件包名称.3.修改本地FQDN名:1).首先修改主机的hostname复制代码代码如下:# vi /etc/sysconfig/network———————-———————-———————-———————-HOSTNAME=chef.example.com———————-———————-———————-———————-2).修改本地host,添加server与node的FNDN复制代码代码如下:# echo "... chef.example.com" >> /etc/hosts# echo "... node1.example.com" >> /etc/hosts重启系统. 登录后验证:复制代码代码如下:# hostname -f———————-———————-———————-———————-chef.example.com———————-———————-———————-———————-

3.配置chef-server

执行以下命令配置chef-server复制代码代码如下:# chef-server-ctl reconfigure注:chef-server .x版本默认监听端口,chef-server .x监听端口SO若线上开启防火墙,需执行以下命令防火墙开启端口复制代码代码如下:# iptables -I INPUT -p tcp --dport -j ACCEPT# service iptables save现在浏览器打开 adminpassword: p@ssw0rd1即可访问chef-server web页面.

CentOS 6.3下安装部署CHEF环境教程(centos 6.5安装教程)

四.chef-workstation安装:(chef.example.com)

1.安装chef-Client进入页面 Client标签,选择要下载的版本.本例使用..4-1版本:复制代码代码如下:# wget -c --no-check-certificate rpm -ivh chef-..4-1.el6.x_.rpm2.安装配置git1).yum安装git:复制代码代码如下:# yum -y install git2).进入root主目录,git克隆chef repository复制代码代码如下:# su -# cd ~# git clone empty Git repository in /root/chef-repo/.git/remote: Reusing existing pack: , done.remote: Total (delta 0), reused 0 (delta 0)Receiving objects: % (/), . KiB | KiB/s, done.Resolving deltas: % (/), done.————————————————————————————————————————————————————————————2.配置chef-workstation运行命令 knife configure -i ,配置过程如下所示(只需填写chef repository一项:/root/chef-repo,其他项使用默认值):复制代码代码如下:# knife configure --initial————————————————————————————————————————————————————————————WARNING: No knife configuration file foundWhere should I put the config file? [/root/.chef/knife.rb]Please enter the chef server URL: enter a name for the new user: [root]Please enter the existing admin name: [admin]Please enter the location of the existing admin&#;s private key: [/etc/chef-server/admin.pem]Please enter the validation clientname: [chef-validator]Please enter the location of the validation key: [/etc/chef-server/chef-validator.pem]Please enter the path to a chef repository (or leave blank): /root/chef-repoCreating initial API user...Please enter a password for the new user: 注:这里输入API user密码(后面要使用)Created user[root]Configuration file written to /root/.chef/knife.rb————————————————————————————————————————————————————————————注: 没有出现Please enter a name for the new user: [root] 检查chef-server的端口是否可以访问.

五.chef-workstation与chef-server不在同一服务器上的配置方法

(本例server与workstation在同一服务器,如无特殊需可略过这部分)1.将chef-server的域名解析添加至chef-workstation的hosts文件复制代码代码如下:# echo "... chef.example.com" >>/etc/hosts2.在chef-workstation先创建/root/.chef目录,并将chef服务器上的/etc/chef-server/admin.pem和/etc/chef-server/chef-validator.pem文件拷贝到此目录复制代码代码如下:# mkdir ~/.chef# scp chef.example.com:/etc/chef-server/admin.pem ~/.chef# scp chef.example.com:/etc/chef-server/chef-validator.pem ~/.chef3.执行knife configure -i命令进行初始化, 然后删除~/.chef/admin.pem复制代码代码如下:# knife configure --initial# rm ~/.chef/admin.pem4.knife configure配置过程:1).server URL修改为chef服务器的地址 private key路径改为/root/.chef/admin.pem3).validation key路径改为/root/.chef/chef-validation.pem4).chef repository地址输入/root/chef-repo,其余项保持默认值.复制代码代码如下:# knife configure --initial————————————————————————————————————————————————————————————Overwrite /root/.chef/knife.rb? (Y/N) YPlease enter the chef server URL: enter a name for the new user: [root]Please enter the existing admin name: [admin]Please enter the location of the existing admin&#;s private key: [/etc/chef-server/admin.pem] /root/.chef/admin.pemPlease enter the validation clientname: [chef-validator]Please enter the location of the validation key: [/etc/chef-server/chef-validator.pem] /root/.chef/chef-validator.pemPlease enter the path to a chef repository (or leave blank): /root/chef-repoCreating initial API user...Please enter a password for the new user: 注:这里输入API user密码(后面要使用)Created user[root]Configuration file written to /root/.chef/knife.rb————————————————————————————————————————————————————————————5.配置ruby路径(之前已安装RUBY,这里可以略过)

chef默认集成了一个ruby的稳定版本,需修改PATH变量,保证chef集成的ruby被优先使用.复制代码代码如下:# echo &#;export PATH="/opt/chef/embedded/bin:$PATH"&#; >> ~/.bash_profile && source ~/.bash_profile

六.验证chef-workstation

执行knife client list命令返回client列表则配置成功.复制代码代码如下:# knife client list——————————————————chef-validatorchef-webui——————————————————七.chef-node配置 (node1.example.com)

node即为被chef-server配置管理的服务器

1.安装chef-Client

进入页面 Client标签,选择要下载的版本.本例使用..4-1版本:复制代码代码如下:# wget -c --no-check-certificate rpm -ivh chef-..4-1.el6.x_.rpm2.修改本地FQDN名:1).首先修改主机的hostname复制代码代码如下:# vi /etc/sysconfig/network———————-———————-———————-———————-HOSTNAME=node1.example.com———————-———————-———————-———————-2).修改本地host,添加本机和server的FNDN复制代码代码如下:# echo "... chef.example.com" >> /etc/hosts# echo "... node1.example.com" >> /etc/hosts重启系统. 登录后验证:复制代码代码如下:# hostname -f———————-———————-———————-———————-node1.example.com———————-———————-———————-———————-3.在chef-worksation执行下面命令添加并配置node复制代码代码如下:# knife bootstrap node1.example.com -x root -P 注: 这里的密码是node1系统root账号的密码chef-workstation通过ssh连接到node1(...)上执行bootstrap脚本(chef-workstation /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef.6.0/lib/chef/knife/bootstrap/chef-full.erb)可以使用自定义的bootstrap脚本对node进行初始化配置.node1会下载 to node1.example.comnode1.example.com Starting first Chef Client run...node1.example.com [--T::+:] WARN:node1.example.com * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *node1.example.com SSL validation of HTTPS requests is disabled. HTTPS connections are stillnode1.example.com encrypted, but chef is not able to detect forged replies or man in the middlenode1.example.com attacks.node1.example.comnode1.example.com To fix this issue add an entry like this to your configuration file:node1.example.comnode1.example.com ```node1.example.com # Verify all HTTPS connections (recommended)node1.example.com ssl_verify_mode :verify_peernode1.example.comnode1.example.com # OR, Verify only connections to chef-servernode1.example.com verify_api_cert truenode1.example.com ```node1.example.comnode1.example.com To check your SSL configuration, or troubleshoot errors, you can use thenode1.example.com `knife ssl check` command like so:node1.example.comnode1.example.com ```node1.example.com knife ssl check -c /etc/chef/client.rbnode1.example.com ```node1.example.comnode1.example.com * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *node1.example.comnode1.example.com Starting Chef Client, version ..4node1.example.com Creating a new client identity for node1.example.com using the validator key.node1.example.com resolving cookbooks for run list: []node1.example.com Synchronizing Cookbooks:node1.example.com Compiling Cookbooks...node1.example.com [--T::+:] WARN: Node node1.example.com has an empty run list.node1.example.com Converging 0 resourcesnode1.example.comnode1.example.com Running handlers:node1.example.com Running handlers completenode1.example.comnode1.example.com Chef Client finished, 0/0 resources updated in 2. seconds———————-———————-———————-———————-—-———————-—-———————-查看是否连接node1成功:复制代码代码如下:# knife node list———————-———————-———————node1———————-———————-———————从上面可以看出node1已经成功注册到了chef-server中,整个环境 chef-workstation => chef-server => chef-client-1 已经搭建成功。八.登陆server web后台1.修改浏览器本机HOST,这里笔者使用的是MAC系统复制代码代码如下:# vi /etc/hosts———————-———————-———————... chef.example.com... node1.example.com———————-———————-———————2.访问 repository (chef.example.com)注: chef repository 是一个存储cookbooks和其他文件的目录结构,初次使用需要从github克隆复制代码代码如下:# su -# cd ~# git clone empty Git repository in /root/chef-repo/.git/remote: Reusing existing pack: , done.remote: Total (delta 0), reused 0 (delta 0)Receiving objects: % (/), . KiB | KiB/s, done.Resolving deltas: % (/), done.———————————————————————————————————获取到的目录如下:复制代码代码如下:# ls——————————————————————————————————Desktop Downloads Pictures Templates anaconda-ks.cfg install.log srcDocuments Music Public Videos chef-repo install.log.syslog——————————————————————————————————# cd chef-repo/# ls——————————————————————————————————LICENSE Rakefile chefignore cookbooks environmentsREADME.md certificates config data_bags roles——————————————————————————————————2.创建一个cookbook,取名quick_start (chef.example.com)注:需要切换到之前clone获取到的目录的cookbooks目录下复制代码代码如下:# cd ~/chef-repo/cookbooks# knife cookbook create quick_start -o ./——————————————————————————————————** Creating cookbook quick_start** Creating README for cookbook: quick_start** Creating CHANGELOG for cookbook: quick_start** Creating metadata for cookbook: quick_start——————————————————————————————————创建的cookbooks目录如下复制代码代码如下:# # ls -1p quick_start—————————————CHANGELOG.mdREADME.mdattributes/definitions/files/libraries/metadata.rbproviders/recipes/resources/templates/—————————————注: cookbooks用来在chef中分布共享,大多数你创建基础实例都需要cookbooks.此cookbook实例是创建一个简单的recipe,用来传递给node1一个简单的带有一些已经定义好的变量属性的文本.

3.创建一个属性文件,取名"quick_start.rb" (chef.example.com)复制代码代码如下:# vi ~/chef-repo/cookbooks/quick_start/attributes/quick_start.rb——————————————————————————normal[:deep_thought] = "If a tree falls in the forest ..."——————————————————————————注: 在cookbook中属性文件用来在node中创建一些配置,从而你可以从recipe中调用这些属性.

4.对default recipe创建一个source template源模板 (chef.example.com)复制代码代码如下:# vi ~/chef-repo/cookbooks/quick_start/recipes/default.rb——————————————————————————template "/tmp/deep_thought.txt" dosource "deep_thought.txt.erb"variables :deep_thought => node[:deep_thought]action :createend——————————————————————————注: recipes允许你对具体的源进行管理,这个例子中,你创建了一个叫quick_start的recipe,内容包括一个单独的源模板名叫template "/tmp/deep_thought.txt"

5.创建一个template模板文件 (chef.example.com)

注:这个文件调用源模板的具体属性,而后被chef传送给具体的node客户端复制代码代码如下:# vi ~/chef-repo/cookbooks/quick_start/templates/default/deep_thought.txt.erb——————————————————————————Today&#;s deep thought: <%= @deep_thought %>——————————————————————————6.将cookbook上传到Server (chef.example.com)复制代码代码如下:# cd ~/chef-repo/cookbooks/# ls——————————————————————————README.md quick_start——————————————————————————# knife cookbook upload -a -o ./——————————————————————————Uploading quick_start [0.1.0]Uploaded all cookbooks.——————————————————————————确认你刚上传的cookbook复制代码代码如下:# knife cookbook list——————————————————————————quick_start 0.1.0——————————————————————————6.将quick_start recipe添加到你的node中 (chef.example.com)复制代码代码如下:# knife node run_list add node1.example.com &#;recipe[quick_start]&#;——————————————————————————node1.example.com:run_list: recipe[quick_start]——————————————————————————查看添加好的recipe复制代码代码如下:# knife node show node1.example.com -r——————————————————————————node1.example.com:run_list: recipe[quick_start]——————————————————————————6.在node客户端注册,从而获取server上recipe的具体实例 (node1.example.com)注:保证/etc/chef下有client.pem与validation.pem证书文件,如果没有检查之前的配置.复制代码代码如下:# chef-client————————————————————————————————————[--T::+:] WARN:* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *SSL validation of HTTPS requests is disabled. HTTPS connections are stillencrypted, but chef is not able to detect forged replies or man in the middleattacks.To fix this issue add an entry like this to your configuration file:```# Verify all HTTPS connections (recommended)ssl_verify_mode :verify_peer# OR, Verify only connections to chef-serververify_api_cert true```To check your SSL configuration, or troubleshoot errors, you can use the`knife ssl check` command like so:```knife ssl check -c /etc/chef/client.rb```* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *Starting Chef Client, version ..4resolving cookbooks for run list: ["quick_start"]Synchronizing Cookbooks:- quick_startCompiling Cookbooks...Converging 1 resourcesRecipe: quick_start::default* template[/tmp/deep_thought.txt] action create- create new file /tmp/deep_thought.txt- update content in file /tmp/deep_thought.txt from none to febf--- /tmp/deep_thought.txt -- ::. ++++ /tmp/chef-rendered-template--cxwpb -- ::. +@@ -1 +1,2 @@+Today&#;s deep thought: If a tree falls in the forest ...Running handlers:Running handlers completeChef Client finished, 1/1 resources updated in 9. seconds————————————————————————————————————最终执行后,创建 /tmp/deep_thought.txt文件,即实现了server向node的文件分发复制代码代码如下:# vi /tmp/deep_thought.txt————————————————————————————————————Today&#;s deep thought: If a tree falls in the forest ...————————————————————————————————————注: warning问题将在以后的文档中解决...大功告成....

CentOS安装TortoiseSVN 客户端 一、CentOS安装TortoiseSVN复制代码代码如下:yuminstall-ysubversion二、SVN客户端命令1、查看帮助命令:svnhelp启动服务使用命令svnserve启动服务复制代码代码如下

CentOS系统使用配置文件修改IP地址详细教程 在VM虚拟机安装的centos系统,默认使用的是dhcp自动获取ip地址的方式,而我自己想用这个centos在局域网内搭建一个小型演示站点,这个自动获取ip地址的

标签: centos 6.5安装教程

本文链接地址:https://www.jiuchutong.com/biancheng/353776.html 转载请保留说明!

上一篇:CentOS 6.3下使用Gitosis安装搭建Git Server教程(centos gogs)

下一篇:CentOS安装TortoiseSVN 客户端(centos安装完成后重启进不去)

  • 增值税进项税抵扣时间
  • 未认证的进项税能做转出处理吗
  • 缴纳工会经费会计处理
  • 建筑公司收到劳务发票会计分录
  • 培训属于什么服务行业
  • 主营业务收入计入
  • 个体工商户生产经营所得税率
  • 设备租赁公司是干嘛的
  • 税控盘减免税有时间限制吗?
  • 计提坏账的递延税收
  • 发给职工的福利要交个税吗
  • 小规模纳税人工程服务的增值税率
  • 股权转让个人所得税
  • 污泥处置费用怎么开票
  • 增值税抵扣期限多少天
  • 进项票已认证忘记开票
  • 怎么看是不是小叶紫檀手串
  • 发票没用完可以领发票吗
  • 怎么判断分红前已提取足够法定公积金?
  • 私人打款到对公账户可以吗
  • 购置土地税款怎么入账?
  • 分公司向总公司转钱可以吗
  • windows10专业
  • 预付卡销售怎么做账
  • 资产负债表中的固定资产是原值还是净值
  • 集团公司股份
  • 发票金额大于报销金额可以吗
  • 无票收入后又开红字发票
  • 简述linux系统
  • ScanMailOutLook.exe - ScanMailOutLook是什么进程 有什么用
  • 滴滴司机工资怎么算的
  • php curl_multi_init
  • 印花税会计分录2023
  • 限售股交易征税是多少
  • 滚动开发项目如何做账
  • 什么是收付实现制?什么是权责发生制?
  • 企业利润取出税费有哪些
  • ajax调用
  • vue的内置组件
  • 母公司为子公司提供担保是利好吗
  • mongodb常用语句
  • 购买防暑物资应放到哪个科目
  • 高新技术企业三季度申报所得税研发费加计怎么扣除
  • 法人向公司账户打款
  • 金税四期对企业的好处
  • 哪些增值税专用发票不能抵扣进项税
  • 售后维修的会计分录
  • 应付票据转应付账款会计分录
  • 小规模纳税人缴纳本月未交增值税
  • 企业处置子公司
  • 关于幼儿园的会议内容
  • 上年的原材料发票可以算今年的成本吗
  • 银行电子承兑汇票
  • 本期缴纳上期应纳税额怎么填
  • 咨询公司销售费用有哪些
  • 如何设置银行存款日记账
  • sqlserver开启远程
  • 64位 win10系统安装绿色版mysql-5.7.16-winx64的教程
  • mysqlvarchar汉字
  • sqlserver自定义函数在哪查看
  • mysql添加外键约束的sql语句
  • 苹果MAC电脑怎么砸壳应用app
  • srv32.exe - srv32进程是什么文件 有何作用
  • linux修改系统日期命令
  • mmc.exe是什么
  • win10系统收不到wifi信号
  • P2P Networking2.exe - P2P Networking2是什么进程 有什么用
  • android中使用md5后报非法延续字节
  • cocos creator rpg
  • android设计模式的应用场景
  • 基于javascript的毕业设计
  • python解析函数
  • python爬虫详解
  • 《简单》阅读答案
  • 安卓 旋转屏幕
  • 江苏省办理准生证的app叫什么
  • 税控盘监控信息写盘失败时钟校准
  • 临时税务登记纳税有区域限制吗为什么
  • 国税手工发票
  • 增值税网上申报步骤可以在手机上申报吗
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号