FreeBSD

diskinfo -vt /dev/… 检测磁盘信息,并测试磁盘性能

pw user mod dayuer -G www 把dayuer用户放入www组

mstsc /v:IP /console

No such file or directory: Failed to enable the ‘httpready’ Accept Filter

执行如下操作:

kldload accf_http

grep accf /boot/defaults/loader.conf
accf_data_load=”NO” # Wait for data accept filter
accf_http_load=”NO” # Wait for full HTTP request accept filter#将这个”NO”改成”YES”

内核开启IPFW

options IPFIREWALL
options IPFIREWALL_VERBOSE
options IPFIREWALL_VERBOSE_LIMIT=100
options IPSTEALTH
options TCP_DROP_SYNFIN
options IPFIREWALL_DEFAULT_TO_ACCEPT

options ACCEPT_FILTER_DATA
options ACCEPT_FILTER_HTTP
options IPDIVERT
options DUMMYNET
options HZ=3000
options BRIDGE

增量备份

建立增量备份的第一步是产生一个在过去一段时间里更改过的档案的列表,这通常由find命令实现.
例如产生过去24小时内更改过的档案的列表用:
find / -mtime -1 ! -type d -print>/tmp/filelist.daily

其中-mtime -1选项将使find找出过去24小时内更改过的档案; ! -type d 将使find从档案列表中
去掉目录名.类似找出过去一周内更改过的所有档案用:

find / -mtime -7 -print>/tmp/filelist.weekly

当产生了要备份的档案的列表,这个列表放在一个档案里,使用tar -T选项可以指定一个档案,它包含
要备份的档案的列表.例如将列在档案/tmp/filelist.daily中的所有档案备份到设备/dev/fd0上,用:

tar -cv -T /tmp/filelist.daily -f /dev/fd0

MySQL 忘记口令的解决办法

如果 MySQL 正在运行,首先杀之: killall -TERM mysqld。
启动 MySQL :bin/safe_mysqld –skip-grant-tables &
就可以不需要密码就进入 MySQL 了。
然后就是
>use mysql
>update user set password=password(“new_pass”) where user=”root”;
>flush privileges;
重新杀 MySQL ,用正常方法启动 MySQL 。

PostSnap

FreeBSD6.0起内建的Ports更新工具

首次使用:

Portsnap fetch

Portsnap extracert

以后更新Ports就简单了

Portsnap fetch

Portsnap update

Vmware中的FreeBSD时间慢的问题解决

在VM中安装好FreeBSD后,shutdown并将\Program Files\VMware\VMware Workstation\freebsd.iso挂到VM中,启动fbsd。

# mount_cd9660 /dev/acd0 /mnt
# cd /usr/ports/emulators/vmware-guestd5
# make install clean
# ee /etc/rc.conf
加上vmware_guestd_enable=”YES”
# shutdown -r now

这样,就不会再出现FreeBSD中的时钟老比主机跑得慢的现象了。

安全删除Mysql二进制日志

mysql>SHOW MASTER LOGS;

命令显示目前二进制日志的数目。

然后

mysql> PURGE MASTER LOGS TO ‘binary-log.xxx’;

除了命令中给出的日志之后的外,其他的二进制日志全部删除。

具体如下:

1
PURGE MASTER LOGS

PURGE { MASTER|BINARY } LOGS TO 'log_name'
PURGE { MASTER|BINARY } LOGS BEFORE 'date'

make 参数

fetch – Retrieves ${DISTFILES} (and ${PATCHFILES} if defined) into ${DISTDIR} as necessary.
fetch-list – Show list of files that would be retrieved by fetch.
fetch-recursive – Retrieves ${DISTFILES} (and ${PATCHFILES} if defined), for port and dependencies into ${DISTDIR} as necessary.
fetch-recursive-list – Show list of files that would be retrieved by fetch-recursive.
fetch-required-list – Show list of files that would be retrieved by fetch-required.
fetch-required – Retrieves ${DISTFILES} (and ${PATCHFILES} if defined), for port and dependencies that are not already installed into ${DISTDIR}.
all-depends-list – Show all directories which are dependencies for this port.

build-depends-list – Show all directories which are build-dependencies for this port.
package-depends-list – Show all directories which are package-dependencies for this port.
run-depends-list – Show all directories which are run-dependencies for this port.
extract – Unpacks ${DISTFILES} into ${WRKDIR}.
patch – Apply any provided patches to the source.
configure – Runs either GNU configure, one or more local configure scripts or nothing, depending on what’s available.
build – Actually compile the sources.
install – Install the results of a build.
reinstall – Install the results of a build, ignoring “already installed” flag.
deinstall – Remove the installation.
deinstall-all – Remove all installations with the same PKGORIGIN.

package – Create a package from an _installed_ port.
package-recursive – Create a package for a port and _all_ of its dependancies.
describe – Try to generate a one-line description for each port for use in INDEX files and the like.
checkpatch – Do a “patch -C” instead of a “patch”. Note that it may give incorrect results if multiple patches deal with the same file.
checksum – Use distinfo to ensure that your distfiles are valid.
checksum-recursive – Run checksum in this port and all dependencies.
makesum – Generate distinfo (only do this for your own ports!).
clean – Remove ${WRKDIR} and other temporary files used for building.
clean-depends – Do a “make clean” for all dependencies.
config – Configure options for this port (using ${DIALOG}). Automatically run prior to extract, patch, configure, build, install, and package.
showconfig – Display options config for this port
rmconfig – Remove the options config for this port

SSH不输入密码连接远程Linux主机

系统环境 : ubuntu 6.06 / ubuntu 6.10
SSH服务 : openssh-server
1) 在本地主机生成密钥对
ssh-keygen -t rsa
这个命令生成一个密钥对:id_rsa(私钥文件)和id_rsa.pub(公钥文件)。默认被保存在~/.ssh/目录下。
2) 将公钥添加到远程主机的 authorized_keys 文件中
将文件上传到远程主机中
scp ~/.ssh/id_rsa.pub root@192.168.1.23:/root/
SSH到登陆到远程主机,将公钥追加到 authorized_keys 文件中
cat /root/id_rsa.pub >> /root/.ssh/authorized_keys
或直接运行命令:
cat ~/.ssh/id_dsa.pub|ssh root@192.168.1.23 `cat – >> ~/.ssh/authorized_keys`
3) 重启 open-ssh 服务
/etc/init.d/ssh restart4) 测试
ssh root@192.168.1.23
scp /home/onion/.ssh/id_rsa.pub root@192.168.1.23:/root/

安装Apache的参数

make WITH_MPM=worker WITH_THREADS=yes WITH_STATIC_SUPPORT=yes WITH_APACHE_SUEXEC=yes WITH_ALL_STATIC_MODULES=yes WITHOUT_PROXY=yes WITHOUT_SSL=yes install

cd /usr/ports/databases/memcached; make install clean
cd /usr/ports/databases/pecl-memcache; make install clean

Ftp 自动传送脚本

echo -e “open host port \nuser username password \nbinary \nput /data.`date +%Y.%m.%d`.tar.gz data.`date +%Y.%m.%d`.tar.gz \nquit” >/tmp/ftp.script
cat /tmp/ftp.script | ftp -n

Find的时间选项

-daystart
从当日起始时开始而不是从24小时之前,计算时间(for -amin, -atime, -cmin, -ctime, -mmin, and -mtime)。

————————————————————————————————

-amin n
对文件的最近一次访问是在 n 分钟之前。

-anewer file
对文件的最近一次访问比 file 修改时间要晚。如果命令行中 -follow 在 -anewer 之前,(也只有在这种情况下) -anewer
会受 -follow 的影响。

-atime n
对文件的最近一次访问是在 n*24 小时之前。

-cmin n
对文件状态的最近一次修改是在 n 分钟之前。

-cnewer file
对文件状态的最近一次修改比 file 修改时间要晚。如果命令行中 -follow 在 -cnewer 之前,(也只有在这种情况下)
-cnewer 会受 -follow 的影响。

-ctime n
对文件状态的最近一次修改是在 n*24 小时之前。
-mmin n
对文件数据的最近一次修改是在 n 分钟之前。

-mtime n
对文件数据的最近一次修改是在 n*24 小时之前。

tail -f /usr/local/squid/logs/access.log | awk ‘{print$3 ” ” $8 ” ” $7}’

cacti 使用 tcp检测

snmpd_enable=”YES”
snmpd_flags=”TCP:1161″

创建cacti的device时,在host里使用 TCP:xx.xx.xx.xx

Want to strip UTF-8 BOM(Byte Order Mark) from given files?

sed -e ‘1s/^\xef\xbb\xbf//’ < bomfile > newfile

FreeBSD》上有 3 条评论

  1. 大鱼儿 文章作者

    修改 freebsd保留端口 net.inet.ip.portrange.reservedhigh

  2. 大鱼儿 文章作者

    privoxy + tor 配置

    forward-socks4a / localhost:9050 .

评论已关闭。