2017-04-14 115 views
2

我用下面的腳本安裝了廚師服務器。我是linux新手,我正在嘗試學習如何設置廚師服務器。我運行了chef.io提供的命令並且腳本成功了。我真的不知道如何檢查,或者我應該做些什麼來檢查流程是否正在運行。有關如何查看進程是否正在運行的Linux的最佳做法是什麼?我能做些什麼來找出我需要知道的事情?檢查進程是否在Linux上運行的最佳實踐?

 #!/bin/bash \ 
echo "Do your provisioning here" \ 
sudo wget https://packages.chef.io/files/stable/chef-server/12.14.0/el/7/chef-server-core-12.14.0-1.el7.x86_64.rpm \ 
sudo chmod a+x chef-server-core-12.14.0-1.el7.x86_64.rpm 
sudo rpm -Uvh ./chef-server-core-12.14.0-1.el7.x86_64.rpm 
sudo chef-server-ctl reconfigure \ 
sudo openssl rsa -in private.pem -outform PEM -pubout -out ~/.ssh/chef-server.pem \ 
sudo chef-server-ctl user-create admin 'admin' 'email' 'password' --filename ~/.ssh/chef-server.pem \ 
sudo openssl rsa -in private.pem -outform PEM -pubout -out ~/.ssh/chef-server-validator.pem \ 
sudo chef-server-ctl org-create short_name 'idevops' --association_user admin --filename ~/.ssh/chef-server-validator.pem \ 
sudo openssl rsa -in private.pem -outform PEM -pubout -out ~/.ssh/chef-coffee-server-validator.pem \ 
sudo chef-server-ctl org-create 4thcoffee 'iDevops 4th Coffee' --association_user admin --filename ~/.ssh/chef-coffee-server-validator.pem \ 
sudo chef-server-ctl install chef-manage \ 
sudo chef-server-ctl reconfigure \ 
sudo chef-manage-ctl reconfigure \ 
sudo chef-server-ctl install opscode-push-jobs-server \ 
sudo chef-server-ctl reconfigure \ 
sudo opscode-push-jobs-server-ctl reconfigure \ 
sudo chef-server-ctl install opscode-reporting \ 
sudo chef-server-ctl reconfigure \ 
sudo opscode-reporting-ctl reconfigure \ 
sudo chef-server-ctl install PACKAGE_NAME --path /path/to/package/directory \ 
sudo chef-server-ctl install chef-manage --path /root/packages \ 
sudo mkdir /etc/opscode && sudo touch /etc/opscode/chef-server.rb \ 
sudo echo "license['nodes'] = 0" >> /etc/opscode/chef-server.rb \ 
sudo chef-server-ctl reconfigure 
+0

我不熟悉的廚師,但是對於大多數的服務器,你應該能夠以某種請求來查詢它們。 –

+1

大概停止在bash腳本中執行此操作,並改用廚師成分食譜。 – coderanger

回答

0

有一個在您發佈的輸出比較大的提示(如chef-server-ctl status),

The status subcommand is used to show the status of all services available 
to the Chef server. The results will vary based on the configuration of a 
given server. 

,或者chef-server-ctl status SERVICE_NAME

where SERVICE_NAME represents the name of any service that is listed after 
running the service-list subcommand. 

請參見在chef-server-ctl (executable)start子(朝頁面的底部)

2

好,有你可以在網上找到他們幾個地方,你想要做的第一件事是檢查是否正在運行的進程。

ps aux | grep process_name

然後如果它正在運行,但仍然無法訪問它。您需要使用netstat命令和grep作爲端口。

net stat -anp | grep portnumber 

你看看服務是否在它應該是的端口上運行。它會說它的傾聽。聆聽意味着該端口正在該端口上尋找通信。這將意味着應用程序已啓動並正在尋找端口上的通信,或者該端口正在被另一個應用程序使用,這就是爲什麼它沒有啓動。

通常你會再看看在lgos尾-f -n 100 /路徑/到/日誌/文件
-n是行數 -f是一個持續的後續所以它怎麼你看文件。如果你不指定它,它只會在屏幕上佔用100行。

1

如果你只是想手動檢查,登錄到服務器並運行:

ps auxw | grep YOUR_PROCESS_NAME 
1

首先,我不從腳本運行的命令,直到我知道他們的工作。 您可能沒有運行該服務:

sudo service chef-server status #would be a good place to start 

要檢查進程運行在Linux上,我建議先從以下內容:

ps aux | grep <part of the process name> 
    ps aux | grep chef 

如果你不喜歡輔助輸出你也可以使用像-ef:

ps -ef | grep <part of the process name> 
    ps -ef | grep chef 

如果你知道什麼端口的進程應該是開放的,你可以使用netstat的:

netstat -anp | grep <port number> 

例如:nginx的或Apache服務器是運行:

netstat -anp | grep 80 

觀看日誌我喜歡使用tail命令:

tail -f /var/log/<name of application folder/<name of log> 

實施例:看nginx的日誌:

tail -f /var/log/nginx/nginx.log 

有時候也可以看系統日誌:

tail -f -n 100 /var/log/syslog 

如果尋找其他機器的入站連接:

sudo tcpdump -vvv -i any port <port number>