Last_Error: Error ‘Duplicate entry ‘1’ for key 1′ on query. Default database:

Last_Error: Error ‘Duplicate entry ‘1’ for key 1′ on query. Default database: ‘nq’. Query: ‘INSERT INTO t_nq

做的数据库主从同步,发现网站异常,检查从库时发现报错。

(后来发现这种错误是插入了重复的数据导致)

Slave_IO_Running: Yes
Slave_SQL_Running: No

Last_Errno: 1062

更新插入语句有问题,会经常出现,我们可以忽略这个错误:

mysql> show variables like “%slave%”;
+—————————+——-+
| Variable_name             | Value |
+—————————+——-+
| init_slave                |       |
| log_slave_updates         | OFF   |
| slave_compressed_protocol | OFF   |
| slave_load_tmpdir         | /tmp/ |
| slave_net_timeout         | 3600  |
| slave_skip_errors | OFF  |
| slave_transaction_retries | 10    |
+—————————+——-+
7 rows in set (0.00 sec)

可以看到slave_skip_errors 参数关闭了。那么可以从这里下手了。

两种解决方法:

1、 从库执行:
stop slave;
set global sql_slave_skip_counter =1 ;
start slave;

2、修改从库:/etc/my.cnf

slave-skip-errors = 1062     //多个错误号码可用逗号隔开

重启服务。

似乎第一种方法对我没用,直接修改配置文件,忽略1062错误。

mysql> show slave status\G;

检查Seconds_Behind_Master的值,直到为0时,与主库同步完成。

redhat5.5 安装oracle10

    系统环境:redhat5.5_x64 oracle 10.2

1、先安装所需的rpm包
yum install -y binutils compat-db control-center gcc gcc-c++ glibc glibc-common libstdc++ libstdc++-devel make pdksh sysstat xorg-x11-deprecated-libs glibc-devel
2、添加相关的用户及组
[root@oracle ~]# groupadd oinstall
[root@oracle ~]# groupadd dba
[root@oracle ~]# useradd -g oinstall -G dba oracle
[root@oracle ~]# passwd oracle
3、修改配置文件
[root@oracle ~]# vi /etc/sysctl.conf    //If the current value of any parameter is higher than the value listed in this table, then do not change the value of that parameter.

kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144

[root@oracle ~]# vi /etc/security/limits.conf

oracle           soft    nproc   2047
oracle           hard    nproc   16384
oracle           soft    nofile  1024
oracle           hard    nofile  65536

[root@oracle ~]# vi /etc/pam.d/login
session    required     pam_limits.so

切换到oracle
[root@oracle ~]# su – oracle

添加以下部分:
[oracle@oracle ~]$ vi .bash_profile

if [ $USER = “oracle” ]; then
        if [ $SHELL = “/bin/ksh” ]; then
              ulimit -p 16384
              ulimit -n 65536
        else
              ulimit -u 16384 -n 65536
        fi
fi

修改系统版本信息
[root@oracle ~]#echo redhat-4 > /etc/redhat-release

[root@oracle ~]# mkdir -p /u01/app/oracle/oraInventory
[root@oracle ~]# chown -R oracle:oinstall /u01/app/oracle/
[root@oracle ~]# chmod -R 775 /u01/app/oracle/

reboot server into GUI with oracle user.

export LANG=en   //如果系统安装选的中文,则执行。oracle10不支持中文,要不会出现图形乱码

然后 ./runInstaller开始安装。

PS:

为什么文档里面没有配置环境变量的参数。

-bash: ./br.sh: /bin/bash^M: bad interpreter: No such file or directory

        编写的脚本执行时报错:
-bash: ./br.sh: /bin/bash^M: bad interpreter: No such file or directory

我这里是因为文件的保存编码格式有误。

在此介绍两种方法把dos格式转换为UNIX格式。

1、用vi打开脚本
命令:
:set ff

会显示出当前脚本为fileformat=dos还是fileformat=unix, 可以用:set ff=unix 更改为unix格式, 然后保存退出,再次执行。
2.可以用命令 dos2unix 转换

[root@localhost ~]# dos2unix scripts.sh

如果没有这个命令,安装dos2unix这个rpm包。

libtool: install: error: cannot install `libaprutil-1.la’ to a directory not ending in

     编译apache时候的一个报错:

libtool: install: error: cannot install `libaprutil-1.la’ to a directory not ending in xxx

解决:

make clean all

重新编译。这是因为./configure时候指定的一个参数因某些问题终止编译过程,再次./configure时又指定了另一个路径导致已经生成的Makefile错误。需要清除之前的信息。

清空history历史命令记录

今天在清空历史命令时候只记得cat null设备到隐藏文件中,man了一下找到c参数,作此记录。

在用户家目录下有几个隐藏的文件:

~/.bash_history 存放用户历史命令。
~/.bash_profile 用户登陆系统时执行。
~/.bash_rc 用户登陆系统或者打卡新的终端shell时执行。
~/.bash_logout用户退出系统时执行。

如果要清除执行过的历史命令有两种方法:
1、history -c  
#Clear the history list by deleting all the entries.#

2、/dev/null 是一个空的块设备,没有任何内容,可以cat此设备然后输出到 .bash_history 文件中。

[root@localhost ~]# cat /dev/null >~/.bash_history