这里介绍用 INN 构建具备基本功能的新闻服务器。
设置 news 用户帐号
确认系统中包含 news 用户和 news 组,如果没有,需要添加:
$ groupadd news $ useradd -g news -d /usr/local/news
安装
建议perl support,这样会安装一些维护工具,如 scanspool等。 |
$ tar zxvf inn-2.3.3.tar.gz $ cd inn-2.3.3/ $ ./configure --with-perl $ make && make install Do not forget to update your cron entries, and also run makedbz if you need to. If this is a first-time installation a minimal active file has been installed. You will need to touch history and run "makedbz -i" to initialize the history database. See INSTALL for more information.
缺省安装在 /usr/local/news 目录下,并已经设置好相应权限。
设定新闻组
db/active
the list of newsgroups you carry.
$ cat /usr/local/news/db/active
control 0000000000 0000000001 n
control.cancel 0000000000 0000000001 n
control.checkgroups 0000000000 0000000001 n
control.newgroup 0000000000 0000000001 n
control.rmgroup 0000000000 0000000001 n
junk 0000000000 0000000001 n
active 文件中至少要有 control 和 junk 两行。 |
db/active.times
初始为空文件。该文件被有些 news 客户端用来检查是否有新邮件组。该文件由 innd/ctlinnd 自动维护。
db/newsgroups
该文件记录各个新闻组的描述。格式如下:
control Various control messages (no posting). control.cancel Cancel messages (no posting). control.checkgroups Hierarchy check control messages (no posting). control.newgroup Newsgroup creation control messages (no posting). control.rmgroup Newsgroup removal control messages (no posting). junk Unfiled articles (no posting). 测试灌水 For newbie test. local.announce Announcement for all.
完整性检查
可以用命令scanspool -v,检验 active 文件和 spool中文件的正确配置。
在news服务启用状态维护 active 文件,需要:
$ ctlinnd pause 'edit active' $ vi active $ inncheck $ scanspool $ ctlinnd reload active 'new active' $ ctlinnd go 'edit active'
inn 基本资料配置文件:inn.conf
修改文件etc/inn.conf
,注意其中的如下内容:
fromhost: foo0.com.tw pathhost: foo0.com.tw organization: 公司大名 (Foo's Co.,) server: foo0.com.tw domain: com.tw hiscachesize: 256 artcutoff: 60 maxartsize: 100000 localmaxartsize: 100000 enableoverview: true ovmethod: tradindexed spoolfirst: false
执行inncheck,检查 inn.conf 配置 |
文章过期策略设置
修改配置文件 expire.ctl
如下:
/remember/:10 ## This entry uses the syntax appropriate when groupbaseexpiry is true in inn.conf. *:A:10:never:never ## This is an entry based on storage class, used when groupbaseexpiry is false. #0:10:never:never
详细说明参见:INN 过期设置。
初始化 history 文件
$ cd /usr/local/news/db $ touch history $ ../bin/makedbz -i $ for i in history.n*; do i=${i#history.n.}; mv history.n.$i history.$i ;done $ chown news:news history* $ chmod 644 history*
如果已存在的数据,可以用如下命令重建 history 和 overview 数据库。
$ ctlinnd throttle "throttle due to maintaining" $ scanspool $ makehistory -F -b -I $ cat /usr/local/news/db/history | wc -l $ find /usr/local/news/spool/articles/ -type f | wc -l $ cd /usr/local/news/db $ ../bin/makedbz -i $ for i in history.n*; do i=${i#history.n.}; mv history.n.$i history.$i ;done $ rm -rf /usr/local/news/spool/overview/* $ makehistory -O -F -b -x $ find /usr/local/news/spool/articles/ -type f | wc -l $ find /usr/local/news/spool/overview/ -type f -name "*.DAT" -exec cat {} \; | wc -l $ ctlinnd go "maintaining success"
确认 active 中的 himark 和 lowmark 是否正确设置。参见:active 文件格式。 |
|
重建 history 文件。参见:makehistory 命令参考。 |
|
重建overview 数据库前,先要将已有 overview 数据库删除。 |
|
重建 overview 数据库。参见:makehistory 命令参考。 |
设置喂信方式
如果没有另外的外部喂信者,照此配置 incoming.conf
。
peer ME { hostname: "localhost, 127.0.0.1" }
即使不向外部喂信,仍然需要配置 newsfeeds
。
ME:*,!junk::
含义为:外发除了 junk 外所有新闻组,并且允许接收所有的 distributions (该配置中distributions部分省略)。虽然我们可能不向外部喂信,但是仍然配置外发所有新闻组,因为除了用于向外喂信之外,还用于和配置其它程序通讯,如 news2mail。
配置 syslog,记录日志
$ touch /usr/local/news/log/news.crit $ touch /usr/local/news/log/news.err $ touch /usr/local/news/log/news.notice $ chown news /usr/local/news/log/news.* $ chgrp news /usr/local/news/log/news.* $ cat >> /etc/syslog.conf << END news.crit /usr/local/news/log/news.crit news.err /usr/local/news/log/news.err news.notice /usr/local/news/log/news.notice END $ kill -1 `cat /var/run/syslog.pid`
启动 news 服务 su news -c /usr/local/news/bin/rc.news
停止 news 服务 su news -c /usr/local/news/bin/rc.news stop
以SRV4方式启动。
#!/bin/sh # Script to control news server # # PATH=${SAMBADIR}/bin:${SAMBADIR}/sbin:/bin:/usr/sbin:/usr/bin export PATH case "$1" in 'start') echo "starting news server ... " su news -c /usr/local/news/bin/rc.news echo done ;; 'stop') echo "stopping news server ... " su news -c "/usr/local/news/bin/rc.news stop" echo done ;; *) echo "usage: news.sh {start | stop}" ;; esac
在服务器端将新闻组的日志文件输出到控制台,用以对服务器进行实时诊断:
# tail -f /usr/local/news/log/news/news.notice & # tail -f /usr/local/news/log/news/news.err & # tail -f /usr/local/news/log/news/news.crit &
在客户端使用 telnet 连接服务器,测试新闻组:
$ su news -c /usr/local/news/bin/rc.news Starting innd. Scheduled start of /usr/local/news/bin/innwatch. $ telnet 127.0.0.1 nntp Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. 200 news.worldhello.net InterNetNews server INN 2.3.3 ready list newsgroups 215 control Various control messages (no posting). control.cancel Cancel messages (no posting). control.checkgroups Hierarchy check control messages (no posting). control.newgroup Newsgroup creation control messages (no posting). control.rmgroup Newsgroup removal control messages (no posting). cn.comp.book Sucked from cn99 junk Unfiled articles (no posting). . listgroup control 411 No such group control listgroup cn.comp.book 211 Article list follows 1 ... 21 . authinfo user johnson 381 PASS required authinfo pass mypassword 281 Ok listgroup control 211 Article list follows . quit 205 . Connection closed by foreign host.
设置 crontab,完成诸如过期文章删除、日志回滚等工作。
修改 crontab 如下:
0 3 * * * su -c "/usr/local/news/bin/news.daily delayrm" news 0 7 * * 7 su -c '/usr/local/news/bin/expireover -s' news #0,10,20,30,40,50 * * * * /usr/local/news/bin/nntpsend
参见:news.daily 命令参考。
Copyright © 2006 WorldHello 开放文档之源 计划 |