Welcome to the Linux Foundation Forum!

Exercise 2.6 Create and customize a systemd service

jorarome
jorarome Posts: 1
edited June 2017 in LFS211 Class Forum

Hello, I am trying to develop this exercise, but I do not understand it, it is mentioned in a stress package that you have to install it.

Where is the stress package?

Thanks!

Comments

  • lee42x
    lee42x Posts: 380
    edited June 2017

    The "stress" packages is available for most distro's the following should help.

    Centos:

    yum install stress

    Ubuntu:

    apt-get install stress 

    OpenSUSE:

    zypper install stress 

     

     

  • After:

    mv /etc/systemd/system/foo.service /root/

    it shows error when restart "foo": "Unit not found"

    Can you explain why?

  • After: (at the end of LAB)

    mv /etc/systemd/system/foo.service /root/

    It shows error: Unit not found.

    when trying to start foo service.

    Can you explain why?

  • rojosh
    rojosh Posts: 11
    edited December 2017

    Hi

    I didn't get much out of this exercise because I didn't learn in the course

    about the following subjects:

    1) systemd

    2) systemd-delta 

    3) [Slice]

    CPUQuota=

    Why aren't these subjects covered in this course?

    thx,

    Josh

     

     

     

  • coop
    coop Posts: 915

    While these topics are useful, to explain them would require more depth and time than is feasible in LFS201, which is already very long.  One should not believe that everything is in this course and one always has to do further study to really be an accomplished admin.  This is true through the course that many topics are only surveyed as this is an introductory course, not an in-depth treatment.  We do have further discussion in higher level courses as well as in developer-oriented coruses.

  • coop
    coop Posts: 915

    oops, i thought this was LFS201 and responded incorrectly.  Please note that system-delta is used in the labs in the Networking Concepts chapter

  • rojosh
    rojosh Posts: 11
    edited December 2017

    Hi

    Where exactly is system-delta explained in course LFS211?

    I couldn't find it.

    Does LFS211 cover all that is required to pass exam?

    thx

  • rojosh
    rojosh Posts: 11
    edited December 2017

    Hi

    I am still waiting for an answer please.

    thx

  • lee42x
    lee42x Posts: 380

    Hi, Thank you for bringing this to our attention. 

    We will expand on the statement: "install the stress package with the appropiate installer " to include "yum installl stress" and "apt-get install stress" 

    The intention of the exercise is to create a default systemd startup file then onverride the options with plugin files. 

    We use the command "systemd-delta" to show the override files that are available for a given service. There is additional information in "man systemd-delta" if you wish to explore the caapabilities of the command. 

    The last line of the lab exercise mentions two man pages that hold additional information , 

    "man systemd.resource-control " and "man systemd.service" which will explain the CPUQuota option. The slice is a grouping consctuct in systemd to group "like" services together or to isolate services depending on the desired effect.



    The "file not found" issue, There should be a subdirectory /etc/systemd/system/foo.service with a file 00-foo.conf in it. If that file exists it will overwrite the file  /etc/sytemd/system/foo.service, hence making it redundant, assuming the same values are in each file.  

    Lee

  • rojosh
    rojosh Posts: 11

    Hi,

    Thx for you answer but I also requested to know if this LFS211 course covers all that is

    necessary to pass the exam? Also, do you have a course that teaches step by step the

    subject about systemd, quota, slice...?

    thx

  • rojosh
    rojosh Posts: 11

    Hi,

    I'm still waiting for answers to my questions - thx.

  • coop
    coop Posts: 915

    If you read my earlier (misdirected) post where I thought it was about LFS201, the argument still is the same.

    1) There are things covered in LFs211 that will not be in the exam, either because the exam might ask about it but didn't due to there are only so many things that can be asked; or it is not material that is to expected on the exam at all but that we thought was important to know for a real sys admin; or

     

    2) there is not enough time to take this up in detail in LFS211; you are expected to do your own self-study on topics to go deeper and broader.  This is not an "exam prep" course; it is a course that helps prepare you for the exam.  If you don't look at things in more detail than you see in the screens, you are not doing your part of the job.

    systemd-delta is mentioned, but not really discussed.  Look it up and understasnd it.  It's not that difficult and is the way engineers work every day.  Is it on the exam?  We don't know, we don't write the exams.

  • rojosh
    rojosh Posts: 11
    edited December 2017

    Thanks for your answers.

    I am not trying to be a crybaby but rather trying to save time being that

    my time is very budgeted so if a subject is covered by the course or another

    course then I could learn it within 1/10th the time and thus save precious time.

    Two questions:

    1) Does LF have an exam prep?

    2) Accourding to your knowledge, how is LF211 vs RHCE test? Are they the same (more or less)? I want to take both.

    thx

  • coop
    coop Posts: 915
    edited December 2017

    1) yes.  many resources and details at training.linuxfoundation.org   click on certification

    2) LFS211 should perpare you for RHCE (assuming you have LFS201 and LFS101x experience as pre-reqs)  LFS211 and LFCE are often sold together, I don' t know what you did

  • rojosh
    rojosh Posts: 11
    edited December 2017

    Thanks for your answers.

    I am not trying to be a crybaby but rather trying to save time being that

    my time is very budgeted so if a subject is covered by the course or another

    course then I could learn it within 1/10th the time and thus save precious time.

    Two questions:

    1) Does LF have an exam prep?

    2) Accourding to your knowledge, how is LF211 vs RHCE test? Are they the same (more or less)? I want to take both.

    thx

  • "yum install stress" failed for me because the default configured yum reposotories on Centos 7.3.1611 do not contain Stress. Adding the EPEL Repository to my yum repos fixed the problem. To assist anyone who is running CentOS and ran into the same problem as I did when running "yum install stress", I've included the steps below to include EPEL Repositories in your yum repos and install the stress package:

    # sudo yum install -y epel-release

    # sudo yum install -y stress

     

     

  • MohamedLan
    MohamedLan Posts: 10
    edited May 2018

    After write this command:

    $ cat /usr/lib/systemd/system/foo.service

    I get this result:

    cat: /usr/lib/systemd/system/foo.service: No such file or directory

    Can someone help me wiht that?

  • coop
    coop Posts: 915

    did you create the file first as inidcated in the lab?

  • MohamedLan
    MohamedLan Posts: 10

    Hi coop!!

    Thanks, i didn't realize that. Thank you very much!!

  • tobyone
    tobyone Posts: 2

    Hello all!

    I Just started the course today and already have a question pertaining to this thread. I, like others here, find the wording in exercise 2.6 confusing, and this part in particular:

    "Since the /usr/lib/systemd/system/foo.service may be altered by the vendor at update time, create a unit file in /etc/
    systemd/system/foo.service for the stress service and change the parameters slightly so it is easy to identify which unit
    file is being used. It is normal to copy the vendor unit file into the /etc/systemd/system/ directory and make appropriate
    customizations.
    $ cat /etc/systemd/system/foo.service"

    Is this a typo: "create a unit file in /etc/systemd/system/foo.service"? Should that be the creation of a new directory /etc/systemd/system/foo.service.d? Otherwise the instructions are telling us to place a file called foo.service in a directory called foo.service. That don't work. Then we are shown the contents of a file named foo.service that is not in a directory called foo.service.d but where it was located for the preceding part of the exercise.

    The function of this part of the exercise seems to be to set up a config file for the stress service that escapes overwriting through updates by virtue of its being in a foo.service.d directory. But the text communicates this process poorly, particularly as the app in question – stress – does not come with systemd config files anyway.

    Anyway, I added a directory called stress.service.d, copied stress.service into that directory, changed the parameters of that copied file as per the instructions, restarted the service using systemctl (centos) but the parameters were taken from my file /etc/systemd/system/stress.service, as evidenced by the output of systemctl status stress.

    So I'm confused by this exercise and would like clarification. The answers offered to other students in this thread thus far don't clear this matter up for me.

    Cheers,
    Toby

  • tobyone
    tobyone Posts: 2

    Apologies to all concerned. I just saw my error and feel like a fool. The second file is located under /etc, not under /usr. Blimey, what an oversight!

  • Hello,
    I'm getting this error, someone knows why?

    ● foo.service - Example service unit to run stress
    Loaded: loaded (/usr/lib/systemd/system/foo.service; disabled; vendor preset: disabled)
    Drop-In: /etc/systemd/system/foo.service.d
    └─00-foo.conf
    Active: active (running) since Tue 2018-09-18 01:55:09 UTC; 18s ago
    Main PID: 2734 (stress)
    CGroup: /system.slice/foo.service
    ├─2734 /usr/bin/stress --cpu 1 --io 1 --vm 1 --vm-bytes 1G
    ├─2735 /usr/bin/stress --cpu 1 --io 1 --vm 1 --vm-bytes 1G
    ├─2736 /usr/bin/stress --cpu 1 --io 1 --vm 1 --vm-bytes 1G
    └─2737 /usr/bin/stress --cpu 1 --io 1 --vm 1 --vm-bytes 1G
    Sep 18 01:55:09 centos-training-1 systemd[1]: [/etc/systemd/system/foo.service.d/00-foo.conf:6] Unknown lvalue 'Slice' in section 'Install'
    Sep 18 01:55:09 centos-training-1 systemd[1]: Started Example service unit to run stress.
    Sep 18 01:55:09 centos-training-1 systemd[1]: Starting Example service unit to run stress...
    Sep 18 01:55:09 centos-training-1 stress[2734]: stress: info: [2734] dispatching hogs: 1 cpu, 1 io, 1 vm, 0 hdd

  • lee42x
    lee42x Posts: 380

    Hi, can you please post your 00-foo.conf file.

  • I have reviwed it 1000 times....

    [Service]
    ExecStart=
    ExecStart=/usr/bin/stress --cpu 1 --io 1 --vm 1 --vm-bytes 100M
    Slice=foo.slice

    If you chek systemctl status foo, you can see that the "Slice" word is correct, i couldn solve it.
    I'm alredy tried in other system and it worked perfectly

  • lee42x
    lee42x Posts: 380

    The "Slice" directive we put into /etc/systemd/system/foo.slice file. Can we see a copy of the foo.slice file?

  • I'm getting this error:

    cat: unrecognized option '--cpu'
    Try 'cat --help' for more information.
    

    Anyone know why?

  • lee42x
    lee42x Posts: 380

    I believe you are building and modifying the /etc/systemd/system/foo.slice file. It would be a great help if we can see your file.

    Please confirm this is exercise 2.6 we are chatting about.

    Thanks Lee

Categories

Upcoming Training