You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mesos.apache.org by pangbingqiang <pa...@huawei.com> on 2016/05/17 06:00:15 UTC

答复: mesos-logrotate-logger binary package problem?

Thank you for your replay. In "parameters" option the             
            {
                "key": "logrotate_stdout_options",
                "value": "rotate 7\nmissingok\ncompress\ndelaycompress"
            },
The system call logrotate must set a option "create" or "copytruncate", which mode mesos set ?
If choose "copytruncate" mode, it may be lost some log?
 

-----邮件原件-----
发件人: Shuai Lin [mailto:linshuai2012@gmail.com] 
发送时间: 2016年5月5日 19:23
收件人: dev
主题: Re: mesos-logrotate-logger binary package problem?

That program is not meant to be executed manually. Instead you should configure the logger in the modules flags of your mesos slave.

Here is a snippets of a script I used when testing the logrotate logger, you can adjust for your own use case:

MODULES_JSON_FILE=/tmp/modules.json
cat >$MODULES_JSON_FILE<<EOF
{
    "libraries": [
    {
        "file":
"${MESOS_BUILD_DIR}/src/.libs/liblogrotate_container_logger.so",
        "modules": [
        {
            "name": "org_apache_mesos_LogrotateContainerLogger",
            "parameters": [
            {
                "key": "launcher_dir",
                "value": "${MESOS_BUILD_DIR}/src/"
            },
            {
                "key": "max_stdout_size",
                "value": "4096B"
            },
            {
                "key": "max_stderr_size",
                "value": "4096B"
            },
            {
                "key": "logrotate_stdout_options",
                "value": "rotate 7\nmissingok\ncompress\ndelaycompress"
            },
            {
                "key": "logrotate_stderr_options",
                "value": "rotate 7\nmissingok\ncompress\ndelaycompress"
            }
            ]
        }
        ]
    }
    ]
}
EOF


${MESOS_SLAVE} \
  --hostname=localhost \
  --ip=127.0.0.1 \
  --master=127.0.0.1:5050 \
  --resources="cpus:2;mem:10240" \
  --log_dir="${WORK_DIR}/slave/logs" \
  --work_dir="${WORK_DIR}/slave" \
  --launcher_dir="${MESOS_BUILD_DIR}/src/" \
  --modules=${MODULES_JSON_FILE} \
  --container_logger=org_apache_mesos_LogrotateContainerLogger \
  --containerizers=docker,mesos

Regards,
Shuai





On Thu, May 5, 2016 at 4:10 PM, pangbingqiang <pa...@huawei.com>
wrote:

> Hi all:
>
>   When I alone use “mesos-logrotate-logger” binary package, it will 
> always error, the log as:
>
> “Failed to put child in a new session: Operation not permitted”.
>
> I find it don’t’t call in mesos, so how to use if for log rotate?
>
>
>
> [image: cid:image001.png@01D0E8C5.8D08F440]
>
>
>
> Bingqiang Pang 00278970
>
>
>
> Distributed and Parallel Software Lab
>
> Huawei Technologies Co., Ltd.
>
> Email:pangbingqiang@huawei.com <su...@huawei.com>
>
>
>
>
>

Re: 答复: mesos-logrotate-logger binary package problem?

Posted by Joseph Wu <jo...@mesosphere.io>.
The particular implementation of the container logger packaged with Mesos
does not need either option (but it shouldn't break with either option
either).

"create" is not necessary because the container logger will create the log
file when it's missing.
https://github.com/apache/mesos/blob/2e409a5257cf4d53040959cae0edfbd7cf1a1af9/src/slave/container_loggers/logrotate.cpp#L145-L151

"copytruncate" is not necessary because the container logger calls
logrotate after it closes the FD.  (We do this because renaming a file is
faster than copying it.)
https://github.com/apache/mesos/blob/2e409a5257cf4d53040959cae0edfbd7cf1a1af9/src/slave/container_loggers/logrotate.cpp#L178-L184


On Mon, May 16, 2016 at 11:00 PM, pangbingqiang <pa...@huawei.com>
wrote:

> Thank you for your replay. In "parameters" option the
>             {
>                 "key": "logrotate_stdout_options",
>                 "value": "rotate 7\nmissingok\ncompress\ndelaycompress"
>             },
> The system call logrotate must set a option "create" or "copytruncate",
> which mode mesos set ?
> If choose "copytruncate" mode, it may be lost some log?
>
>
> -----邮件原件-----
> 发件人: Shuai Lin [mailto:linshuai2012@gmail.com]
> 发送时间: 2016年5月5日 19:23
> 收件人: dev
> 主题: Re: mesos-logrotate-logger binary package problem?
>
> That program is not meant to be executed manually. Instead you should
> configure the logger in the modules flags of your mesos slave.
>
> Here is a snippets of a script I used when testing the logrotate logger,
> you can adjust for your own use case:
>
> MODULES_JSON_FILE=/tmp/modules.json
> cat >$MODULES_JSON_FILE<<EOF
> {
>     "libraries": [
>     {
>         "file":
> "${MESOS_BUILD_DIR}/src/.libs/liblogrotate_container_logger.so",
>         "modules": [
>         {
>             "name": "org_apache_mesos_LogrotateContainerLogger",
>             "parameters": [
>             {
>                 "key": "launcher_dir",
>                 "value": "${MESOS_BUILD_DIR}/src/"
>             },
>             {
>                 "key": "max_stdout_size",
>                 "value": "4096B"
>             },
>             {
>                 "key": "max_stderr_size",
>                 "value": "4096B"
>             },
>             {
>                 "key": "logrotate_stdout_options",
>                 "value": "rotate 7\nmissingok\ncompress\ndelaycompress"
>             },
>             {
>                 "key": "logrotate_stderr_options",
>                 "value": "rotate 7\nmissingok\ncompress\ndelaycompress"
>             }
>             ]
>         }
>         ]
>     }
>     ]
> }
> EOF
>
>
> ${MESOS_SLAVE} \
>   --hostname=localhost \
>   --ip=127.0.0.1 \
>   --master=127.0.0.1:5050 \
>   --resources="cpus:2;mem:10240" \
>   --log_dir="${WORK_DIR}/slave/logs" \
>   --work_dir="${WORK_DIR}/slave" \
>   --launcher_dir="${MESOS_BUILD_DIR}/src/" \
>   --modules=${MODULES_JSON_FILE} \
>   --container_logger=org_apache_mesos_LogrotateContainerLogger \
>   --containerizers=docker,mesos
>
> Regards,
> Shuai
>
>
>
>
>
> On Thu, May 5, 2016 at 4:10 PM, pangbingqiang <pa...@huawei.com>
> wrote:
>
> > Hi all:
> >
> >   When I alone use “mesos-logrotate-logger” binary package, it will
> > always error, the log as:
> >
> > “Failed to put child in a new session: Operation not permitted”.
> >
> > I find it don’t’t call in mesos, so how to use if for log rotate?
> >
> >
> >
> > [image: cid:image001.png@01D0E8C5.8D08F440]
> >
> >
> >
> > Bingqiang Pang 00278970
> >
> >
> >
> > Distributed and Parallel Software Lab
> >
> > Huawei Technologies Co., Ltd.
> >
> > Email:pangbingqiang@huawei.com <su...@huawei.com>
> >
> >
> >
> >
> >
>