systemd

发表于 2012-04-07 22:52:46  | 最后修改于 2012-04-09 09:12:45  | 只看该作者  | 倒序浏览
总是干正事感觉有些无聊,随手折腾了一番systemd... 文档也没有仔细研究,恐怕多有讹误,还望诸位不吝赐教。 

另外,这个帖子不是当作教程写的,只是总结一下我找到的资料和个人的感受。帖子可能会随时修改,增加或者删除内容。 

感受: 
systemd的速度果然不同凡响,原先OpenRC从加载内核完成到启动login要12秒以上,systemd只用了大概4-5秒... 尽管GRUB和POST花费的时间、我输入密码的时间都要远远长过systemd节省的几秒钟... 

我的意见是,目前Gentoo的systemd支持相当不完善,还是不要轻易切换过来为好。 

systemd-ui看起来不怎么样,我居然碰到了一个glibc的double free错误... 

零散的经验: 
修改unit文件之后要systemctl daemon-reload; 

systemd的--test对debug可是非常实用的:
Sh代码 
  1. systemd --test --system --log-level=debug  
据说systemd-journal基本可以代替syslog:https://fedoraproject.org/wiki/Features/systemd-journal 

如果没有mkdir /var/log/journal,systemd-journal不会将log记录到磁盘上,也就是说,您只能看到此次启动系统后产生的log信息。

systemd的依赖控制方法相当特别,除了man systemd.unit之外,下面的邮件和它的一系列回复大概也有助于增进对systemd依赖系统的理解: 
http://lists.freedesktop.org/arc ... 1-March/001599.html 

systemd的PAM支持最好还是设置一下,不过Arch Wiki和Gentoo Wiki给出了不同的方法... 我用的是:
Sh代码 
  1. echo 'session\toptional\tpam_systemd.so >> /etc/pam.d/system-auth  


systemd默认不会在每次启动时清除/tmp,如果像我一样有洁癖,可以新建/etc/tmpfiles.d/tmp.conf,把如下内容加入: 
Systemd代码 
  1. #  This file is part of systemd.  
  2. #  
  3. #  systemd is free software; you can redistribute it and/or modify it  
  4. #  under the terms of the GNU General Public License as published by  
  5. #  the Free Software Foundation; either version 2 of the License, or  
  6. #  (at your option) any later version.  
  7.   
  8. # See tmpfiles.d(5) for details  
  9.   
  10. # Clear tmp directories separately, to make them easier to override  
  11. D /tmp 1777 root root 10d  


可以参考的资料列表: 

综合性的资料: 
https://wiki.archlinux.org/index.php/Systemd 
http://wiki.gentoo.org/wiki/Systemd 
http://en.gentoo-wiki.com/wiki/Systemd 
http://www.gentoo.org/proj/en/ba ... d-install-guide.xml 
http://fedoraproject.org/wiki/Systemd 
http://www.freedesktop.org/wiki/Software/systemd (注意其中"systemd for Administrators"的链接,很好的教程。) 
https://bbs.archlinux.org/viewtopic.php?id=96316&p=1 

Units文件: 
https://github.com/falconindy/sy ... tree/master/service 
http://git.overlays.gentoo.org/g ... units/files;hb=HEAD 

Gentoo的systemd原生配置文件: 
http://git.overlays.gentoo.org/g ... md-0.ebuild;hb=HEAD 
http://0pointer.de/blog/projects/the-new-configuration-files.html 

Vim syntax:(没试过) 
http://fedorapeople.org/gitweb?p ... git/vim-scripts.git;a=blob;f=syntax/systemd.vim;hb=HEAD 

zsh completion: 
原先似乎没有zsh completion的,莫名其妙就出现了... 只记得我给systemd打了这个patch: 
http://lists.freedesktop.org/arc ... ecember/003984.html 

网络配置: 
没找到原生的PPPoE配置,只好自己动手。班门弄斧,贻笑方家了。 

network@.service,用来启动eth0。
Systemd代码 
  1. [Unit]  
  2. Description=Null %I network interface  
  3. Before=network.target  
  4.   
  5. [Service]  
  6. Type=oneshot  
  7. RemainAfterExit=yes  
  8. ExecStart=/sbin/ip link set dev %i up  
  9. ExecStop=/sbin/ip addr flush dev %i  
  10. ExecStop=/sbin/ip link set dev %i down  
  11.   
  12. [Install]  
  13. Alias=network.target.wants/network@eth0.service  
pppd@.service
Systemd代码 
  1. [Unit]  
  2. Description=PPP Daemon  
  3. Before=network.target  
  4. After=network@eth0.service  
  5.   
  6. [Service]  
  7. ExecStart=/usr/sbin/pppd call %i  
  8.   
  9. [Install]  
  10. Alias=network.target.wants/pppd@ppp0.service  
PPPoE连接配置,参照OpenRC启动pppd所用的参数写的,/etc/ppp/peers/ppp0 :
Systemd代码 
  1. plugin rp-pppoe.so  
  2. unit 0  
  3. user YOUR_USERNAME  
  4. remotename ppp0  
  5. linkname ppp0  
  6. # plugin passwordfd.so  
  7. noauth  
  8. defaultroute  
  9. holdoff 3  
  10. child-timeout 60  
  11. lcp-echo-interval 15  
  12. lcp-echo-failure 3  
  13. # noaccomp  
  14. # noccp  
  15. # nobsdcomp  
  16. # nodeflate  
  17. # nopcomp  
  18. # novj  
  19. # novjccomp  
  20. # passwordfd 0  
  21. nodetach  
  22. defaultmetric 4003  
  23. maxfail 0  
  24. persist  
  25. # connect true  
  26. eth0  
密码要写在/etc/ppp/pap-secrets中,按照Handbook的解释办。 

openvpn@.service,我记得是从arch-units偷来的,修改了一点:
Systemd代码 
  1. [Unit]  
  2. Description=OpenVPN connection to %i  
  3. Wants=network.target  
  4. After=network.target  
  5.   
  6. [Service]  
  7. ExecStart=/usr/sbin/openvpn --config /etc/openvpn/%i.conf --cd /etc/openvpn --script-security 2 --up %i-up.sh --down %i-down.sh  
  8.   
  9. [Install]  
  10. Alias=multi-user.target.wants/openvpn@openvpn.service  
shorewall.service,Shorewall的service大概是最好写的了...
Systemd代码 
  1. [Unit]  
  2. Description=Shoreline firewall  
  3. Wants=network.target  
  4. After=network.target  
  5.   
  6. [Service]  
  7. Type=oneshot  
  8. RemainAfterExit=yes  
  9. ExecStart=/sbin/shorewall start  
  10. ExecStop=/sbin/shorewall stop  
  11.   
  12. [Install]  
  13. WantedBy=multi-user.target  
unbound.service,从systemd-arch-units偷来的named.service改出来的:
Systemd代码 
  1. [Unit]  
  2. Description=Internet domain name server  
  3.   
  4. [Service]  
  5. ExecStart=/usr/sbin/unbound  
  6. ExecReload=/usr/sbin/unbound-control reload  
  7.   
  8. [Install]  
  9. WantedBy=multi-user.target  
(unbound.conf中的do-daemonize需要关掉。) 

其他service: 

vixie-cron.service,稍稍修改过,从某个地方偷的...
Sh代码 
  1. systemd --test --system --log-level=debug  
0我的总体配置:
Sh代码 
  1. systemd --test --system --log-level=debug  
1
No man is an island, entire of itself; every man is a piece of the continent, a part of the main; if a clod be washed away by the sea, Europe is the less, as well as if a promontory were, as well as if a manor of thy friends or of thine own were; any man's death diminishes me, because I am involved in mankind; and therefore never send to know for whom the bell tolls; it tolls for thee. -- Devotions Upon Emergent Occasions (1624), John Donn
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值