建博一年了~
去年今日,在铁汉的指导下,俺用上了wordpress。时间真快……
主: 192.168.1.242
从:192.168.1.241
一、设置主库
1、修改主库my.cnf,主要是设置个不一样的id和logbin
[root@viyin.net testsvn]# vi /etc/my.cnf
server-id = 1
log-bin=mysql-bin
2 添加一个复制权限的授权一个帐号
mysql> grant replication slave on *.* to viyin@’192.168.1.%’ identified by ‘viyin.net’;
3 检查创建是否成功
mysql> select user,host from mysql.user;
+——-+————-+
| user | host |
+——-+————-+
| vi | % |
| root | 127.0.0.1 |
| viyin | 192.168.1.% |
| | localhost |
| root | localhost |
| | viyin.net |
+——-+————-+
4 锁主库表
mysql> flush tables with read lock;
5 显示主库信息
mysql> show master status;
+——————+———-+————–+——————+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+——————+———-+————–+——————+
| mysql-bin.000006 | 1687279 | | |
+——————+———-+————–+——————+
1 row in set (0.00 sec)
6 打包数据库
[root@viyin.net mysql]# tar zcvf /root/var.tar.gz /usr/local/mysql/var
tar: Removing leading `/’ from member names
7 迁移数据
[root@viyin.net mysql]# scp -P 2222 /root/var.tar.gz 192.168.1.241:/root
root@192.168.1.241′s password:
var.tar.gz 100% 1167KB 1.1MB/s 00:00
二、设置从服务器
1 解包(不是生产环境,俺把mysql/var目录全删了)
2 解锁
mysql> unlock tables;
3 编辑配置文件
#vim /etc/my.cnf
server-id = 2
master-host = 192.168.1.242
master-user = viyin
master-password = viyin.net
master-port = 3306
4 重启mysql
5 在从库上设置同步
设置连接MASTER MASTER_LOG_FILE为主库的File,MASTER_LOG_POS为主库的Position
mysql> slave stop;
mysql> change master to master_host=’192.168.1.242′,master_user=’vi’, master_password=’vivi’,
master_log_file=’mysql-bin.000006′, master_log_pos=1687279;
6、启动从库服务
mysql> slave start;
7 测试
mysql> CREATE TABLE `vi` (
-> `id` INT( 5 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
-> `username` VARCHAR( 20 ) NOT NULL ,
-> `password` CHAR( 32 ) NOT NULL ,
-> `time` DATETIME NOT NULL ,
-> `number` FLOAT( 10 ) NOT NULL ,
-> `content` TEXT NOT NULL ,
-> PRIMARY KEY ( `id` )
-> ) ENGINE = MYISAM ;
Query OK, 0 rows affected (0.02 sec)
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.242
Master_User: vi
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000006
Read_Master_Log_Pos: 1687606
Relay_Log_File: vi13-relay-bin.000002
Relay_Log_Pos: 578
Relay_Master_Log_File: mysql-bin.000006
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 1687606
Relay_Log_Space: 732
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)
ERROR:
No query specified
增加:
#需要备份的库
binlog-do-db=viyin
#忽略的数据库
binlog-ignore-db=mysql
binlog-ignore-db=test
主从上都要设置
1.搭建lamp
yum install httpd httpd-devel mysql-server php php-devel php-mysql
2.yum安装svn及所需模块
yum install httpd subversion mod_dav_svn mod_auth_mysql
centos默认源的SVN版本较老。1.4.2的。yum前。换一个源。(参考:RedHat和CentOs系统下的第三方软件仓库)
3.查看版本
[root@abc100 ~]# svn –version
svn, version 1.6.9 (r901367)
compiled Mar 22 2010, 00:59:50
Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).
The following repository access (RA) modules are available:
* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
– handles ‘http’ scheme
– handles ‘https’ scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
– with Cyrus SASL authentication
– handles ‘svn’ scheme
* ra_local : Module for accessing a repository on local disk.
– handles ‘file’ scheme
4.确认已安装模块
[root@abc100 modules]# pwd
/etc/httpd/modules
[root@abc100 modules]# ls |grep svn
mod_authz_svn.so
mod_dav_svn.so
5.修改httpd.conf配置文件,载入模块
增加
6.配置SVN
7.创建SVN版本库
svnadmin create /var/www/testsvn/
chown apache.apache /var/www/testsvn/ -R
8.增加用户名密码验证
htpasswd -c /var/www/testsvn/passwd viyin.net
重启apahce后看效果。
8.post-commit(利用SVN的钩子post-commit同步测试服务器代码)
[root@abc100 hooks]# pwd
/var/www/testsvn/hooks
cp post-commit.tmpl post-commit
chown apache.apache post-commit
修改post-commint
chmod a+x post-commit
chown -R apache.apache /var/www/html/viyin.net (确保web目录能访问,否则post-commit不会正常工作)
svn co file:///var/www/svn4/ /var/www/0519 检出
转载自:http://blog.formyz.org/?p=330 感谢作者分享
虽然一直不喜欢移动,但受人之托,勉为其难帮他调试了一下。过程很简单,但其中的技巧却值得拿出来分享,于是就有了这个文章。
问题描述:
(1)以web方式查看nagios监控状态,显示故障,却收不到报警短信。
(2)系统日志出现“Warning: Attempting to execute the command “/usr/local/fetion/fetion –mobile=13660600600 –pwd=little228 –to=13909088009 –msg-utf8=”[linux1-CRITICAL] CHECK_NRPE: Socket timeout after 10 seconds. (20:51:12)”” resulted in a return code of 127. Make sure the script or binary you are trying to execute actually exists…”。
情况了解:
该系统管理员说,他用手工方式执行飞信发短信没问题,再切换成用户nagios,也没问题。
处理过程:
(1)登陆该服务器,查看系统日志和nagios日志,果然如此。
(2)查看飞信所在的目录,发现已经被系统管理员设置成777了。
(3)先修改一下他的/etc/sudoers文件,用visudo进去,新增一行“nagios ALL=NOPASSWD:/usr/local/feiton/feiton”保存。
(4)切换到nagios用户:su – nagios
(5)执行sudo /usr/local/feiton/feiton ,报无lib*.so文件。
(6)这些文件在/usr/local/feiton里呆着呢,先看看/usr/lib里有没有这些。
(7)切换回root,查一下/usr/lib目录,果然没有这些lib*.so。
(8)从这个目录,把这些个lib*.so统统拷贝到/usr/lib目录。
(9)再切换到nagios用户执行sudo /usr/local/feiton/feiton 哈哈,没报错了。
(10)停止一个监控机上的服务,片刻,就发短信了。
对于监控短信报警,还是建议使用短信接口,不行该死的飞信,不能发其他运营商的手机短信。