重慶分公司,新征程啟航
為企業(yè)提供網(wǎng)站建設(shè)、域名注冊(cè)、服務(wù)器等服務(wù)
為企業(yè)提供網(wǎng)站建設(shè)、域名注冊(cè)、服務(wù)器等服務(wù)
原創(chuàng) 服務(wù)器
成都創(chuàng)新互聯(lián)公司是專業(yè)的融安網(wǎng)站建設(shè)公司,融安接單;提供成都網(wǎng)站制作、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè),網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行融安網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!
客戶端 安裝的第二種方法:
[root@chef-server ~]# curl https://www.opscode.com/chef/install.sh | bash
本文安裝參考:http://blog.sina.com.cn/s/blog_b20664f801018yox.html
1 確保hostname是FQDN格式:
[root@chef-server ~]# more /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=chef-server.tian.com
[root@chef-server ~]# more /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 chef-server.tian.com chef-server
[root@chef-server ~]# hostname -f
chef-server.tian.com
[root@chef-server ~]#
1.chef server在centos6.x系統(tǒng)上安裝
[root@chef-server ~]# rpm -Uvh http://rbel.frameos.org/rbel6
[root@chef-server ~]# yum install rubygem-chef-server
[root@chef-server ~]# chkconfig iptables off
[root@chef-server ~]# service iptables stop
[root@chef-server ~]# /usr/sbin/setup-chef-server.sh
Checking RabbitMQ...
RabbitMQ not running. Starting...
Starting rabbitmq-server: SUCCESS
rabbitmq-server.
Configuring RabbitMQ default Chef user...
Starting CouchDB...
Starting couchdb: [ OK ]
Enabling Chef Services...
Starting Chef Services...
Starting chef-server: [ OK ]
Starting chef-server-webui: [ OK ]
Starting chef-solr: [ OK ]
Starting chef-expander: [ OK ]
[root@chef-server ~]# /usr/sbin/setup-chef-server.sh 如果提示
Checking RabbitMQ...
RabbitMQ not running. Starting...
Starting rabbitmq-server: FAILED - check /var/log/rabbitmq/startup_{log, _err}
rabbitmq-server.
Cannot start rabbitmq-server. Aborting.
以上錯(cuò)誤,需要修改rabbitmq.conf文件,如下:vi /etc/rabbitmq/rabbitmq.conf
NODENAME=rabbitmq@localhost
NODE_IP_ADDRESS=127.0.0.1
同時(shí)保證hostname的輸入與/etc/hosts內(nèi)容一致
[root@chef-server ~]# netstat -tlnp | grep chef
tcp 0 0 0.0.0.0:4040 0.0.0.0:* LISTEN 2295/merb :ch ef-se
tcp 0 0 0.0.0.0:4000 0.0.0.0:* LISTEN 2251/merb : chef-se
[root@chef-server ~]#
2.
配置一個(gè)管理chef的客戶端
以下一路回車即可
[root@chef-server ~]# knife configure -i
WARNING: No knife configuration file found
Where should I put the config file? [~/.chef/knife.rb]
Please enter the chef server URL: [http://chef-server.tian.com:4000]
Please enter a clientname for the new client: [root]
Please enter the existing admin clientname: [chef-webui]
Please enter the location of the existing admin client's private key: [/etc/chef/webui.pem]
Please enter the validation clientname: [chef-validator]
Please enter the location of the validation key: [/etc/chef/validation.pem]
Please enter the path to a chef repository (or leave blank):
Creating initial API user...
Created client[root]
Configuration file written to /root/.chef/knife.rb
[root@chef-server ~]#
3.驗(yàn)證chef server是否安裝完成正常使用
[root@chef-server ~]# chef-client
[Thu, 28 Feb 2013 16:24:44 +0800] WARN: *****************************************
[Thu, 28 Feb 2013 16:24:44 +0800] WARN: Can not find config file: /etc/chef/client.rb, using defaults.
[Thu, 28 Feb 2013 16:24:44 +0800] WARN: No such file or directory - /etc/chef/client.rb
[Thu, 28 Feb 2013 16:24:44 +0800] WARN: *****************************************
[Thu, 28 Feb 2013 16:24:44 +0800] INFO: *** Chef 0.10.6 ***
[Thu, 28 Feb 2013 16:24:45 +0800] INFO: Client key /etc/chef/client.pem is not present - registering
[Thu, 28 Feb 2013 16:24:46 +0800] INFO: HTTP Request Returned 404 Not Found: Cannot load node chef-server.tian.com
[Thu, 28 Feb 2013 16:24:46 +0800] INFO: Run List is []
[Thu, 28 Feb 2013 16:24:46 +0800] INFO: Run List expands to []
[Thu, 28 Feb 2013 16:24:46 +0800] INFO: Starting Chef Run for chef-server.tian.com
[Thu, 28 Feb 2013 16:24:46 +0800] INFO: Running start handlers
[Thu, 28 Feb 2013 16:24:46 +0800] INFO: Start handlers complete.
[Thu, 28 Feb 2013 16:24:46 +0800] INFO: Loading cookbooks []
[Thu, 28 Feb 2013 16:24:46 +0800] WARN: Node chef-server.tian.com has an empty run list.
[Thu, 28 Feb 2013 16:24:46 +0800] INFO: Chef Run complete in 0.486835 seconds
[Thu, 28 Feb 2013 16:24:46 +0800] INFO: Running report handlers
[Thu, 28 Feb 2013 16:24:46 +0800] INFO: Report handlers complete
[root@chef-server ~]#
[root@chef-server ~]# more /etc/chef/server.rb | grep admin
web_ui_admin_user_name "admin"
web_ui_admin_default_password "chef321go"
[root@chef-server ~]#
安裝完成,登陸網(wǎng)頁http://localhost:4040 進(jìn)行配置。使用以上的用戶名和密碼登陸。登陸后立即更改密碼
[root@chef-server ~]#
[root@chef-server ~]#
[root@chef-server ~]#
[root@chef-server ~]#
[root@chef-server ~]#
[root@chef-server ~]#
[root@chef-server ~]#
4.chef 客戶端安裝
1) centos5.x 安裝
[root@chef-client ~]# yum install wget
wget -O /etc/yum.repos.d/aegisco.repo http://rpm.aegisco.com/aegisco/el5/aegisco.repo
[root@chef-client ~]# rpm -Uvh http://rbel.frameos.org/rbel5
[root@chef-client ~]# yum install ruby ruby-devel ruby-ri ruby-rdoc ruby-shadow gcc gcc-c++ automake autoconf make curl dmidecode
2) centos6.x 安裝
[root@chef-client ~]# rpm -Uvh http://rbel.frameos.org/rbel6
[root@chef-client ~]# yum install -y ruby ruby-devel ruby-ri ruby-rdoc ruby-shadow gcc gcc-c++ automake autoconf make curl dmidecode
3) 以上 1)和2)安裝好后進(jìn)行如下
[root@chef-client ~]# cd /tmp ; curl -O http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz
[root@chef-client tmp]# tar zxf rubygems-1.8.10.tgz ; cd rubygems-1.8.10
[root@chef-client rubygems-1.8.10]# ruby setup.rb --no-format-executable
[root@chef-client rubygems-1.8.10]# gem install chef --no-ri --no-rdoc
Fetching: mixlib-config-1.1.2.gem (100%)
Fetching: mixlib-cli-1.3.0.gem (100%)
Fetching: mixlib-log-1.4.1.gem (100%)
Fetching: mixlib-authentication-1.3.0.gem (100%)
Fetching: mixlib-shellout-1.1.0.gem (100%)
Fetching: systemu-2.5.2.gem (100%)
Fetching: yajl-ruby-1.1.0.gem (100%)
Building native extensions. This could take a while...
Fetching: ipaddress-0.8.0.gem (100%)
Fetching: ohai-6.16.0.gem (100%)
Fetching: mime-types-1.21.gem (100%)
Fetching: rest-client-1.6.7.gem (100%)
Fetching: json-1.7.7.gem (100%)
Building native extensions. This could take a while...
Fetching: net-ssh-2.6.5.gem (100%)
Fetching: net-ssh-gateway-1.2.0.gem (100%)
Fetching: net-ssh-multi-1.1.gem (100%)
Fetching: highline-1.6.15.gem (100%)
Fetching: erubis-2.7.0.gem (100%)
Fetching: chef-11.4.0.gem (100%)
Successfully installed mixlib-config-1.1.2
Successfully installed mixlib-cli-1.3.0
Successfully installed mixlib-log-1.4.1
Successfully installed mixlib-authentication-1.3.0
Successfully installed mixlib-shellout-1.1.0
Successfully installed systemu-2.5.2
Successfully installed yajl-ruby-1.1.0
Successfully installed ipaddress-0.8.0
Successfully installed ohai-6.16.0
Successfully installed mime-types-1.21
Successfully installed rest-client-1.6.7
Successfully installed json-1.7.7
Successfully installed net-ssh-2.6.5
Successfully installed net-ssh-gateway-1.2.0
Successfully installed net-ssh-multi-1.1
Successfully installed highline-1.6.15
Successfully installed erubis-2.7.0
Successfully installed chef-11.4.0
18 gems installed
[root@chef-client rubygems-1.8.10]#
4) 拷貝server端validation.pem到/etc/chef目錄下
[root@chef-client rubygems-1.8.10]# cd
[root@chef-client ~]# mkdir -pv /etc/chef
[root@chef-client ~]# scp 192.168.20.101:/etc/chef/validation.pem /etc/chef/
5) 創(chuàng)建客戶端連接server認(rèn)證文件
[root@chef-client ~]# vi /etc/chef/client.rb
log_level :info
log_location STDOUT
chef_server_url 'http://192.168.20.101:4000'
validation_client_name 'chef-validator'
6) 驗(yàn)證客戶端是否連接server成功
[root@chef-client ~]# chef-client
Starting Chef Client, version 11.4.0
[2013-02-28T17:40:50+08:00] INFO: *** Chef 11.4.0 ***
[2013-02-28T17:40:50+08:00] INFO: [inet6] no default interface, picking the first ipaddress
Creating a new client identity for chef-client.tian.com using the validator key.
[2013-02-28T17:40:51+08:00] INFO: Client key /etc/chef/client.pem is not present - registering
[2013-02-28T17:40:52+08:00] INFO: HTTP Request Returned 404 Not Found: Cannot load node chef-client.tian.com
[2013-02-28T17:40:52+08:00] INFO: Run List is []
[2013-02-28T17:40:52+08:00] INFO: Run List expands to []
[2013-02-28T17:40:52+08:00] INFO: HTTP Request Returned 404 Not Found: No routes match the request: /reports/nodes/chef-client.tian.com/runs
[2013-02-28T17:40:52+08:00] INFO: Starting Chef Run for chef-client.tian.com
[2013-02-28T17:40:52+08:00] INFO: Running start handlers
[2013-02-28T17:40:52+08:00] INFO: Start handlers complete.
resolving cookbooks for run list: []
[2013-02-28T17:40:52+08:00] INFO: Loading cookbooks []
Synchronizing Cookbooks:
Compiling Cookbooks...
[2013-02-28T17:40:52+08:00] WARN: Node chef-client.tian.com has an empty run list.
Converging 0 resources
[2013-02-28T17:40:52+08:00] INFO: Chef Run complete in 0.545415 seconds
[2013-02-28T17:40:52+08:00] INFO: Running report handlers
[2013-02-28T17:40:52+08:00] INFO: Report handlers complete
Chef Client finished, 0 resources updated
[root@chef-client ~]#
以上信息,則安裝成功!
附:chef 管理命令:
[root@chef-server ~]# knife -h
Usage: knife sub-command (options)
-s, --server-url URL Chef Server URL
-k, --key KEY API Client Key
--color Use colored output
-c, --config CONFIG The configuration file to use
--defaults Accept default values for all questions
-e, --editor EDITOR Set the editor to use for interactive commands
-E, --environment ENVIRONMENT Set the Chef environment
-F, --format FORMAT Which format to use for output
--no-color Don't use colors in the output
-n, --no-editor Do not open EDITOR, just accept the data as is
-u, --user USER API Client Username
--print-after Show the data after a destructive operation
-V, --verbose More verbose output. Use twice for max verbosity
-v, --version Show chef version
-y, --yes Say yes to all prompts for confirmation
-h, --help Show this message
Available subcommands: (for details, knife SUB-COMMAND --help)
** BOOTSTRAP COMMANDS **
knife bootstrap FQDN (options)
** CLIENT COMMANDS **
knife client show CLIENT (options)
knife client reregister CLIENT (options)
knife client create CLIENT (options)
knife client delete CLIENT (options)
knife client bulk delete REGEX (options)
knife client list (options)
knife client edit CLIENT (options)
** CONFIGURE COMMANDS **
knife configure client DIRECTORY
knife configure (options)
** COOKBOOK COMMANDS **
knife cookbook list (options)
knife cookbook delete COOKBOOK VERSION (options)
knife cookbook test [COOKBOOKS...] (options)
knife cookbook create COOKBOOK (options)
knife cookbook metadata COOKBOOK (options)
knife cookbook download COOKBOOK [VERSION] (options)
knife cookbook show COOKBOOK [VERSION] [PART] [FILENAME] (options)
knife cookbook upload [COOKBOOKS...] (options)
knife cookbook bulk delete REGEX (options)
knife cookbook metadata from FILE (options)
** COOKBOOK SITE COMMANDS **
knife cookbook site show COOKBOOK [VERSION] (options)
knife cookbook site install COOKBOOK [VERSION] (options)
knife cookbook site list (options)
knife cookbook site share COOKBOOK CATEGORY (options)
knife cookbook site search QUERY (options)
knife cookbook site download COOKBOOK [VERSION] (options)
knife cookbook site unshare COOKBOOK
** DATA BAG COMMANDS **
knife data bag edit BAG ITEM (options)
knife data bag create BAG [ITEM] (options)
knife data bag list (options)
knife data bag from file BAG FILE (options)
knife data bag delete BAG [ITEM] (options)
knife data bag show BAG [ITEM] (options)
** ENVIRONMENT COMMANDS **
knife environment from file FILE (options)
knife environment show ENVIRONMENT (options)
knife environment delete ENVIRONMENT (options)
knife environment list (options)
knife environment create ENVIRONMENT (options)
knife environment edit ENVIRONMENT (options)
** EXEC COMMANDS **
knife exec [SCRIPT] (options)
** HELP COMMANDS **
knife help [list|TOPIC]
** INDEX COMMANDS **
knife index rebuild (options)
** NODE COMMANDS **
knife node run_list add [NODE] [ENTRY] (options)
knife node from file FILE (options)
knife node run_list remove [NODE] [ENTRY] (options)
knife node delete NODE (options)
knife node list (options)
knife node bulk delete REGEX (options)
knife node create NODE (options)
knife node show NODE (options)
knife node edit NODE (options)
** RECIPE COMMANDS **
knife recipe list [PATTERN]
** ROLE COMMANDS **
knife role bulk delete REGEX (options)
knife role show ROLE (options)
knife role from file FILE [FILE..] (options)
knife role delete ROLE (options)
knife role list (options)
knife role edit ROLE (options)
knife role create ROLE (options)
** SEARCH COMMANDS **
knife search INDEX QUERY (options)
** SSH COMMANDS **
knife ssh QUERY COMMAND (options)
** STATUS COMMANDS **
knife status QUERY (options)
** TAG COMMANDS **
knife tag list NODE
knife tag delete NODE TAG ...
knife tag create NODE TAG ...
[root@chef-server ~]# knife -h