FreeBSD下安装mysql-zrm客户端[技术]

这两天蚊子手下有个freebsd的机器跑mysql,需要对mysql的数据进行备份,自然就想到了使用mysql-zrm,mysql-zrm的备份端已经安装起来了,只需要在freebsd上把客户端装出来就行了。

由于FreeBSD的ports中不包含mysql-zrm,所以只能通过源码的方式安装,下载地址

http://www.zmanda.com/downloads/community/ZRM-MySQL/2.2/Source/MySQL-zrm-2.2.0-release.tar.gz

解压下载的包,此软件包包含了服务端和客户端

tar zxvf MySQL-zrm-2.2.0-release.tar.gz

会在当前目录下产生var usr etc三个目录,由于我们只需要客户端部分,所以我们做如下操作

1,安装xinetd,mysql-zrm的客户端是通过xinetd控制启动的

cd /usr/ports/security/xinetd
make install clean
mkdir –p /usr/local/etc/xinetd.d

编辑xinetd.conf,vim /usr/local/etc/xinetd.conf,加入如下内容

includedir /usr/local/etc/xinetd.d

 

2,拷贝mysql-zrm客户端所需软件

mkdir –p /usr/share/mysql-zrm/plugins/
mkdir -p /var/log/mysql-zrm
mkdir –p /usr/lib/mysql-zrm/ZRM/

cp usr/share/mysql-zrm/plugins/lvm-snapshot.pl /usr/share/mysql-zrm/plugins/
cp usr/share/mysql-zrm/plugins/socket-copy.pl /usr/share/mysql-zrm/plugins/
cp usr/share/mysql-zrm/plugins/socket-server.pl /usr/share/mysql-zrm/plugins/
cp usr/share/mysql-zrm/plugins/ssh-copy.pl /usr/share/mysql-zrm/plugins/
cp usr/share/mysql-zrm/plugins/zfs-snapshot.pl /usr/share/mysql-zrm/plugins/
cp usr/lib/mysql-zrm/ZRM/SnapshotCommon.pm /usr/lib/mysql-zrm/ZRM/
cp var/log/mysql-zrm/mysql-zrm.log /var/log/mysql-zrm/
cp etc/xinetd.d/mysql-zrm-socket-server /usr/local/etc/xinetd.d

3,启动xinetd

/usr/local/etc/rc.d/xinetd onerestart

使用socket -4l查看端口情况

USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS     
mysql    mysqld     76827 10 tcp4   192.168.224.106:3306  *:*
root     xinetd     71583 0  tcp4   192.168.224.106:25300 *:*
root     sshd       2888  3  tcp4   192.168.224.106:22    *:*
root     syslogd    2772  6  udp4   192.168.224.106:514   *:*

看到红色标注内容,说明,mysql-zrm已经启动了。

到此mysql-zrm客户端在freebsd上安装就完毕了。

FreeBSD忘记密码解决办法

这两天蚊子折腾KVM,给同事分配了台freebsd的虚拟机,结果另外的一个同事也要一台拿来测试,在线克隆了一份之后,用virt-viewer连上去,发现那个同事把系统root用户的密码给改掉了,没办法进单用户重置呗,下面就把方法贴出来

进单用户模式
键入指令:boot -s

# fsck -p
# mount -a
# passwd root(或者其他用户)
# exit

OK,完事,特此记录下来方便今后查询

freebsd的csh环境中命令补齐

蚊子工作环境中有几台freebsd,因为平时用的不多,无奈不习惯bsd的csh,所以也不怎么管,但今天要部署nrpe,不得不上去用,可是默认csh环境下是没有命令补齐的,无奈只能网上找找方法

发现,csh下也是可以使用命令补齐的

# echo "set autolist">>~/.cshrc

这样操作完,登出再登入就能看到效果了。

FreeBSD下开启Counter64的支持[技术]

今天蚊子在FreeBSD下搭建cacti环境,所有准备都完成了,但就是网卡流量图出不来,于是就在console->settings->General中把Poller Logging Level改成DEBUG模式,然后查看了一下日志,发现如下信息。

01/13/2010 10:45:01 AM – CMDPHP: Poller[0] Host[1] DS[8] SNMP: v2: 127.0.0.1, dsname: traffic_out, oid: .1.3.6.1.2.1.31.1.1.1.10.1, output: U

01/13/2010 10:45:01 AM – CMDPHP: Poller[0] Host[1] DS[8] WARNING: Result from SNMP not valid. Partial Result: U

01/13/2010 10:45:01 AM – CMDPHP: Poller[0] Host[1] DS[8] SNMP: v2: 127.0.0.1, dsname: traffic_in, oid: .1.3.6.1.2.1.31.1.1.1.6.1, output: U

01/13/2010 10:45:01 AM – CMDPHP: Poller[0] Host[1] DS[8] WARNING: Result from SNMP not valid. Partial Result: U

于是登陆到服务器上手动执行了snmpwalk命令

test# snmpwalk -v 2c -c public localhost .1.3.6.1.2.1.31.1.1.1.10.1
IF-MIB::ifHCOutOctets.1 = No Such Object available on this agent at this OID
test# snmpwalk -v 2c -c public localhost .1.3.6.1.2.1.31.1.1.1.6.1
IF-MIB::ifHCInOctets.1 = No Such Object available on this agent at this OID

然后在网上搜了一下,发现是Freebsd默认安装的net-snmp就不支持Counter64,于是在网上找了一下,解决办法如下

cd /usr/ports/net-mgmt/net-snmp/

编辑Makefile文件

vi Makefile

在CONFIGURE_ARGS内容后加入如下内容

–with-mib-modules=if-mib –enable-mfd-rewrites

修改后的部分内容如下

CONFIGURE_ARGS+=–enable-shared –enable-internal-md5 \
                –with-mib-modules="${_NET_SNMP_MIB_MODULES}" \
                –with-default-snmp-version="${DEFAULT_SNMP_VERSION}" \
                –with-sys-contact="${NET_SNMP_SYS_CONTACT}" \
                –with-sys-location="${NET_SNMP_SYS_LOCATION}" \
                –with-logfile="${NET_SNMP_LOGFILE}" \
                –with-persistent-directory="${NET_SNMP_PERSISTENTDIR}" \
                –with-gnu-ld –with-libwrap –with-libs="-lm -lkvm -ldevstat" \
                –with-mib-modules=if-mib –enable-mfd-rewrites

然后重新编译snmp

make
make deinstall # 只有在你已经装过snmp的时候执行此条
make reinstlal # 如果还没有装过snmp就执行此条
make clean

注意:如果执行make deinstall的时候提示由于关联文件无法执行,如下

test# make deinstall
===>  Deinstalling for net-mgmt/net-snmp
===>   Deinstalling net-snmp-5.4.2.1_6
pkg_delete: package ‘net-snmp-5.4.2.1_6’ is required by these other packages
and may not be deinstalled (but I’ll delete it anyway):
php5-snmp-5.2.12
cacti-0.8.7e4

可以直接执行make reinstall进行安装

安装完成后就可以重启snmp服务了

/usr/local/etc/rc.d/snmpd restart

查看Counter64是否被激活

snmpwalk -v 2c -c public localhost .1.3.6.1.2.1.31.1.1 | grep Counter64

如果一切正常的话,可以看到如下内容:

IF-MIB::ifHCInOctets.1 = Counter64: 1680605
IF-MIB::ifHCInOctets.2 = Counter64: 0
IF-MIB::ifHCInOctets.3 = Counter64: 735920
IF-MIB::ifHCInOctets.4 = Counter64: 0
IF-MIB::ifHCInUcastPkts.1 = Counter64: 15124
IF-MIB::ifHCInUcastPkts.2 = Counter64: 0
IF-MIB::ifHCInUcastPkts.3 = Counter64: 8446
IF-MIB::ifHCInUcastPkts.4 = Counter64: 0
IF-MIB::ifHCInMulticastPkts.1 = Counter64: 75
IF-MIB::ifHCInMulticastPkts.2 = Counter64: 0
IF-MIB::ifHCInMulticastPkts.3 = Counter64: 0
IF-MIB::ifHCInMulticastPkts.4 = Counter64: 0
IF-MIB::ifHCInBroadcastPkts.1 = Counter64: 0
IF-MIB::ifHCInBroadcastPkts.2 = Counter64: 0
IF-MIB::ifHCInBroadcastPkts.3 = Counter64: 0
IF-MIB::ifHCInBroadcastPkts.4 = Counter64: 0
IF-MIB::ifHCOutOctets.1 = Counter64: 11440579
IF-MIB::ifHCOutOctets.2 = Counter64: 0
IF-MIB::ifHCOutOctets.3 = Counter64: 735920
IF-MIB::ifHCOutOctets.4 = Counter64: 0
IF-MIB::ifHCOutUcastPkts.1 = Counter64: 19577
IF-MIB::ifHCOutUcastPkts.2 = Counter64: 0
IF-MIB::ifHCOutUcastPkts.3 = Counter64: 8446
IF-MIB::ifHCOutUcastPkts.4 = Counter64: 0
IF-MIB::ifHCOutMulticastPkts.1 = Counter64: 0
IF-MIB::ifHCOutMulticastPkts.2 = Counter64: 0
IF-MIB::ifHCOutMulticastPkts.3 = Counter64: 0
IF-MIB::ifHCOutMulticastPkts.4 = Counter64: 0
IF-MIB::ifHCOutBroadcastPkts.1 = Counter64: 0
IF-MIB::ifHCOutBroadcastPkts.2 = Counter64: 0
IF-MIB::ifHCOutBroadcastPkts.3 = Counter64: 0
IF-MIB::ifHCOutBroadcastPkts.4 = Counter64: 0

重装snmp后,cacti的图像就可以正常显示出来了