2016-02-22 60 views
1

我已經用我的CentOS 7.0的RPM安裝cygnus服務,但我沒有開始的服務:天鵝服務沒有啓動的

[[email protected] ~]$ sudo service cygnus start 
Starting cygnus (via systemctl): Job for cygnus.service failed. See 'systemctl status cygnus.service' and 'journalctl -xn' for details. 
                  [FAILED] 

下面是錯誤日誌:

[[email protected] ~]$ sudo systemctl status cygnus.service 
cygnus.service - SYSV: cygnus 
    Loaded: loaded (/etc/rc.d/init.d/cygnus) 
    Active: failed (Result: exit-code) since Tue 2016-02-23 07:09:48 UTC; 18s ago 
    Process: 1184 ExecStart=/etc/rc.d/init.d/cygnus start (code=exited, status=1/FAILURE) 

Feb 23 07:09:46 cygnus-mongo.novalocal systemd[1]: Starting SYSV: cygnus... 
Feb 23 07:09:46 cygnus-mongo.novalocal su[1189]: (to cygnus) root on none 
Feb 23 07:09:46 cygnus-mongo.novalocal cygnus[1184]: Starting Cygnus mongo... bash: /var/run/cygnus/cygnus_mongo.pid: No such file or directory 
Feb 23 07:09:46 cygnus-mongo.novalocal cygnus[1184]: bash: /var/log/cygnus//var/log/cygnus/cygnus.log: No such file or directory 
Feb 23 07:09:48 cygnus-mongo.novalocal cygnus[1184]: cat: /var/run/cygnus/cygnus_mongo.pid: No such file or directory 
Feb 23 07:09:48 cygnus-mongo.novalocal cygnus[1184]: [FAILED] 
Feb 23 07:09:48 cygnus-mongo.novalocal cygnus[1184]: rm: cannot remove ‘/var/run/cygnus/cygnus_mongo.pid’: No such file or directory 
Feb 23 07:09:48 cygnus-mongo.novalocal systemd[1]: cygnus.service: control process exited, code=exited status=1 
Feb 23 07:09:48 cygnus-mongo.novalocal systemd[1]: Failed to start SYSV: cygnus. 
Feb 23 07:09:48 cygnus-mongo.novalocal systemd[1]: Unit cygnus.service entered failed state. 
[[email protected] ~]$ sudo journalctl -xn 
-- Logs begin at Tue 2016-02-23 07:08:59 UTC, end at Tue 2016-02-23 07:10:57 UTC. -- 
Feb 23 07:10:33 cygnus-mongo.novalocal systemd[1]: Dependency failed for /mnt. 
-- Subject: Unit mnt.mount has failed 
-- Defined-By: systemd 
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel 
-- 
-- Unit mnt.mount has failed. 
-- 
-- The result is dependency. 
Feb 23 07:10:33 cygnus-mongo.novalocal systemd[1]: Dependency failed for File System Check on /dev/vdb. 
-- Subject: Unit [email protected] has failed 
-- Defined-By: systemd 
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel 
-- 
-- Unit [email protected]vdb.service has failed. 
-- 
-- The result is dependency. 
Feb 23 07:10:33 cygnus-mongo.novalocal systemd[1]: Startup finished in 1.659s (kernel) + 2.841s (initrd) + 1min 31.190s (userspace) = 1min 35.691s. 
-- Subject: System start-up is now complete 
-- Defined-By: systemd 
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel 
-- 
-- All system services necessary queued for starting at boot have been 
-- successfully started. Note that this does not mean that the machine is 
-- now idle as services might still be busy with completing start-up. 
-- 
-- Kernel start-up required 1659184 microseconds. 
-- 
-- Initial RAM disk start-up required 2841741 microseconds. 
-- 
-- Userspace start-up required 91190356 microseconds. 
Feb 23 07:10:47 cygnus-mongo.novalocal dhclient[1068]: DHCPREQUEST on eth0 to 192.168.111.71 port 67 (xid=0x6acae4e0) 
Feb 23 07:10:48 cygnus-mongo.novalocal dhclient[1068]: DHCPACK from 192.168.111.71 (xid=0x6acae4e0) 
Feb 23 07:10:50 cygnus-mongo.novalocal dhclient[1068]: bound to 192.168.111.128 -- renewal in 44 seconds. 
Feb 23 07:10:57 cygnus-mongo.novalocal sudo[1255]: centos : TTY=pts/0 ; PWD=/home/centos ; USER=root ; COMMAND=/bin/journalctl -xn 

這裏是我沒有改變的服務文件:

[[email protected] ~]$ cat /etc/rc.d/init.d/cygnus 
#!/bin/bash 
# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U 
# 
# This file is part of fiware-cygnus (FI-WARE project). 
# 
# fiware-cygnus is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any 
# later version. 
# fiware-cygnus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more 
# details. 
# 
# You should have received a copy of the GNU Affero General Public License along with fiware-cygnus. If not, see 
# http://www.gnu.org/licenses/. 
# 
# For those usages not covered by the GNU Affero General Public License please contact with iot_support at tid dot es 
# 
# cygnus   Start/Stop cygnus 
# 
# chkconfig: 2345 99 60 
# description: cygnus 

# Load some fancy functions for init.d 
. /etc/rc.d/init.d/functions 

PARAM=$1 

CYGNUS_INSTANCE=${2} 

COMPONENT_NAME=cygnus 
PREFIX=/usr 
CYGNUS_DIR=${PREFIX}/cygnus 
FLUME_EXECUTABLE=${CYGNUS_DIR}/bin/cygnus-flume-ng 
CYGNUS_USER=cygnus 

cygnus_start() 
{ 
    local result=0 
    local cygnus_instance=${1} 

    if [[ ! -x ${FLUME_EXECUTABLE} ]]; then 
     printf "%s\n" "Fail - ${FLUME_EXECUTABLE} not exists or is not executable." 
     exit 1 
    fi 

    if [[ $(ls -l ${CYGNUS_DIR}/conf/cygnus_instance_${cygnus_instance}*.conf 2> /dev/null | wc -l) -eq 0 ]]; then 
     if [[ ${cygnus_instance} == "" ]]; then 
      printf "%s\n" "There aren't any instance of Cygnus configured. Refer to file /usr/cygnus/conf/README.md for further information." 
     else 
      printf "%s\n" "There aren't any instance of Cygnus configured with the name ${cygnus_instance}. Refer to file /usr/cygnus/conf/README.md for further information." 
     fi 
     return 1 
    fi 

    for instance in $(ls ${CYGNUS_DIR}/conf/cygnus_instance_${cygnus_instance}*.conf) 
    do 
     local NAME 
     NAME=${instance%.conf} 
     NAME=${NAME#*cygnus_instance_} 

     . ${instance} 

     CYGNUS_PID_FILE="/var/run/cygnus/cygnus_${NAME}.pid" 

     printf "%s" "Starting Cygnus ${NAME}... " 

     status -p ${CYGNUS_PID_FILE} ${FLUME_EXECUTABLE} &> /dev/null 

     if [[ ${?} -eq 0 ]]; then 
      printf "%s\n" " Already running, skipping $(success)" 
      continue 
     fi 

     CYGNUS_COMMAND="${FLUME_EXECUTABLE} agent -p ${ADMIN_PORT} --conf ${CONFIG_FOLDER} -f ${CONFIG_FILE} -n ${AGENT_NAME} -Dflume.log.file=${LOGFILE_NAME} &>> /var/log/cygnus/${LOGFILE_NAME} & echo \$! > ${CYGNUS_PID_FILE}" 
     su ${CYGNUS_USER} -c "${CYGNUS_COMMAND}" 
     sleep 2 # wait some time to know if flume is still alive 
     PID=$(cat ${CYGNUS_PID_FILE}) 
     FLUME_PID=$(ps -ef | grep -v "grep" | grep "${PID:-not_found}") 
     if [[ -z ${FLUME_PID} ]]; then 
      printf "%s\n" "$(failure)" 
      result=$((${result}+1)) 
      rm ${CYGNUS_PID_FILE} 
     else 
      chown ${CYGNUS_USER}:${CYGNUS_USER} ${CYGNUS_PID_FILE} 
      printf "%s\n" "$(success)" 
     fi 
    done 
    return ${result} 
} 

cygnus_stop() 
{ 
    local result=0 
    local cygnus_instance=${1} 

    if [[ $(ls -l /var/run/cygnus/cygnus_${cygnus_instance}*.pid 2> /dev/null | wc -l) -eq 0 ]]; then 
     printf "%s\n" "There aren't any instance of Cygnus ${cygnus_instance} running $(success)" 
     return 0 
    fi 

    for run_instance in $(ls /var/run/cygnus/cygnus_${cygnus_instance}*.pid) 
    do 

     local NAME 
     NAME=${run_instance%.pid} 
     NAME=${NAME#*cygnus_} 

     printf "%-50s" "Stopping Cygnus ${NAME}..." 
     PID=$(cat ${run_instance}) 
     kill -HUP ${PID} &> /dev/null 
     sleep 2 
     FLUME_PID=$(ps -ef | grep -v "grep" | grep "${PID:-not_found}") 
     if [[ -z ${FLUME_PID} ]]; then 
      rm -f ${run_instance} 
      printf "%s\n" "$(success)" 
     else 
      printf "%s\n" "$(failure)" 
      result=$((${result}+1)) 
      rm -f ${run_instance} 
     fi 
    done 
    return ${result} 
} 

cygnus_status() 
{ 
    local result=0 
    local cygnus_instance=${1} 

    if [[ $(ls -l /var/run/cygnus/cygnus_${cygnus_instance}*.pid 2> /dev/null | wc -l) -eq 0 ]]; then 
     printf "%s\n" "There aren't any instance of Cygnus ${cygnus_instance} running" 
     exit 1 
    fi 

    for run_instance in $(ls /var/run/cygnus/cygnus_${cygnus_instance}*.pid) 
    do 

     local NAME 
     NAME=${run_instance%.pid} 
     NAME=${NAME#*cygnus_} 

     printf "%s\n" "Cygnus ${NAME} status..." 
     status -p ${run_instance} ${FLUME_EXECUTABLE} 
     result=$((${result}+${?})) 

    done 
    return ${result} 
} 


case ${PARAM} in 

    'start') 
     cygnus_start ${CYGNUS_INSTANCE} 
     ;; 

    'stop') 
     cygnus_stop ${CYGNUS_INSTANCE} 
     ;; 

    'restart') 
     cygnus_stop ${CYGNUS_INSTANCE} 
     cygnus_start ${CYGNUS_INSTANCE} 
     ;; 

    'status') 
     cygnus_status ${CYGNUS_INSTANCE} 
     ;; 

esac 

我的配置如下:

文件cygnus_instance_mongo.conf:

# Who to run cygnus as. Note that you may need to use root if you want 
# to run cygnus in a privileged port (<1024) 
CYGNUS_USER=cygnus 

# Where is the config folder 
CONFIG_FOLDER=/usr/cygnus/conf 

# Which is the config file 
CONFIG_FILE=/usr/cygnus/conf/agent_mongo.conf 

# Name of the agent. The name of the agent is not trivial, since it is the base for the Flume parameters 
# naming conventions, e.g. it appears in .sources.http-source.channels=... 
AGENT_NAME=cygnusagent 

# Name of the logfile located at /var/log/cygnus. It is important to put the extension '.log' in order to the log rotation works properly 
LOGFILE_NAME=/var/log/cygnus/cygnus.log 

# Administration port. Must be unique per instance 
ADMIN_PORT=8081 

# Polling interval (seconds) for the configuration reloading 
POLLING_INTERVAL=30 

文件agent_mongo.conf

cygnusagent.sources = http-source 
cygnusagent.sinks = mongo-sink 
cygnusagent.channels = mongo-channel 

#============================================= 
# source configuration 
# channel name where to write the notification events 
cygnusagent.sources.http-source.channels = mongo-channel 
# source class, must not be changed 
cygnusagent.sources.http-source.type = org.apache.flume.source.http.HTTPSource 
# listening port the Flume source will use for receiving incoming notifications 
cygnusagent.sources.http-source.port = 5050 
# Flume handler that will parse the notifications, must not be changed 
cygnusagent.sources.http-source.handler = com.telefonica.iot.cygnus.handlers.OrionRestHandler 
# URL target 
cygnusagent.sources.http-source.handler.notification_target = /notify 
# Default service (service semantic depends on the persistence sink) 
cygnusagent.sources.http-source.handler.default_service = def_serv 
# Default service path (service path semantic depends on the persistence sink) 
cygnusagent.sources.http-source.handler.default_service_path = def_servpath 
# Number of channel re-injection retries before a Flume event is definitely discarded (-1 means infinite retries) 
cygnusagent.sources.http-source.handler.events_ttl = 10 
# Source interceptors, do not change 
cygnusagent.sources.http-source.interceptors = ts gi 
# TimestampInterceptor, do not change 
cygnusagent.sources.http-source.interceptors.ts.type = timestamp 
# GroupinInterceptor, do not change 
cygnusagent.sources.http-source.interceptors.gi.type = com.telefonica.iot.cygnus.interceptors.GroupingInterceptor$Builder 
# Grouping rules for the GroupingInterceptor, put the right absolute path to the file if necessary 
# See the doc/design/interceptors document for more details 
cygnusagent.sources.http-source.interceptors.gi.grouping_rules_conf_file = /usr/cygnus/conf/grouping_rules.conf 

# ============================================ 
# OrionMongoSink configuration 
# sink class, must not be changed 
cygnusagent.sinks.mongo-sink.type = com.telefonica.iot.cygnus.sinks.OrionMongoSink 
# channel name from where to read notification events 
cygnusagent.sinks.mongo-sink.channel = mongo-channel 
# FQDN/IP:port where the MongoDB server runs (standalone case) or comma-separated list of FQDN/IP:port pairs where the MongoDB replica set members run 
cygnusagent.sinks.mongo-sink.mongo_hosts = 127.0.0.1:27017 
# a valid user in the MongoDB server (or empty if authentication is not enabled in MongoDB) 
cygnusagent.sinks.mongo-sink.mongo_username = 
# password for the user above (or empty if authentication is not enabled in MongoDB) 
cygnusagent.sinks.mongo-sink.mongo_password = 
# prefix for the MongoDB databases 
cygnusagent.sinks.mongo-sink.db_prefix = kura_ 
# prefix pro the MongoDB collections 
cygnusagent.sinks.mongo-sink.collection_prefix = kura_ 
# true is collection names are based on a hash, false for human redable collections 
cygnusagent.sinks.mongo-sink.should_hash = false 

#============================================= 
# mongo-channel configuration 
# channel type (must not be changed) 
cygnusagent.channels.mongo-channel.type = memory 
# capacity of the channel 
cygnusagent.channels.mongo-channel.capacity = 1000 
# amount of bytes that can be sent per transaction 
cygnusagent.channels.mongo-channel.transactionCapacity = 100 

的你有什麼我錯過任何想法?

FRB答案 後

UPDATE,我改變了日誌文件路徑,我得到了一個新的錯誤:

[[email protected] ~]$ sudo journalctl -xn 
-- Logs begin at Thu 2016-03-03 08:21:08 UTC, end at Thu 2016-03-03 08:22:07 UTC. -- 
Mar 03 08:21:49 cygnus-mongo.novalocal su[1211]: pam_unix(su:session): session opened for user cygnus by (uid=0) 
Mar 03 08:21:49 cygnus-mongo.novalocal cygnus[1206]: Starting Cygnus mongo... bash: /var/run/cygnus/cygnus_mongo.pid: No such file or directory 
Mar 03 08:21:49 cygnus-mongo.novalocal su[1211]: pam_unix(su:session): session closed for user cygnus 
Mar 03 08:21:51 cygnus-mongo.novalocal cygnus[1206]: cat: /var/run/cygnus/cygnus_mongo.pid: No such file or directory 
Mar 03 08:21:51 cygnus-mongo.novalocal cygnus[1206]: [FAILED] 
Mar 03 08:21:51 cygnus-mongo.novalocal cygnus[1206]: rm: cannot remove ‘/var/run/cygnus/cygnus_mongo.pid’: No such file or directory 
Mar 03 08:21:51 cygnus-mongo.novalocal systemd[1]: cygnus.service: control process exited, code=exited status=1 
Mar 03 08:21:51 cygnus-mongo.novalocal systemd[1]: Failed to start SYSV: cygnus. 
-- Subject: Unit cygnus.service has failed 
-- Defined-By: systemd 
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel 
-- 
-- Unit cygnus.service has failed. 
-- 
-- The result is failed. 
Mar 03 08:21:51 cygnus-mongo.novalocal systemd[1]: Unit cygnus.service entered failed state. 
Mar 03 08:22:07 cygnus-mongo.novalocal sudo[1277]: centos : TTY=pts/0 ; PWD=/home/centos ; USER=root ; COMMAND=/bin/journalctl -xn 

回答

1

一切都在配置上,除了這條線確定在cygnus_instance_mongo.conf

LOGFILE_NAME=/var/log/cygnus/cygnus.log 

它必須是:

LOGFILE_NAME=cygnus.log 

I.e.日誌文件的名稱在/var/log/cygnus之內。

據報道,這條線的服務日誌的錯誤:

bash: /var/log/cygnus//var/log/cygnus/cygnus.log: No such file or directory 
+0

感謝您的答覆,我更新了配置,但我有一個新的錯誤:■ – sabrina2020

+1

由於之前失敗的運行似乎「狀態「服務的情況,比方說,不一致。嘗試添加一個假的'/ var/run/cygnus/cygnus_mongo.pid',讓我們看看Cygnus服務是否能夠刪除它(這是它正在嘗試做的,但沒有成功,因爲該文件不存在),並繼續運行。 – frb

+0

實際上沒有創建目錄「/ var/run/cygnus」,所以我創建了它,然後我將其權限更改爲777,因此cygnus用戶可以管理它。謝謝! – sabrina2020