修改TortoiseSVN svn保存的帐号密码

如果装了TortoiseSVN:

Settings -> Saved Data -> Authentication Data -> clear。即可清除保存的上个用户登录信息;当再次用到svn时,会提示输入用户名密码,输入新的用户名密码即可。

或者,手动删除下面目录下的svn登录用户信息保存文件:

C:Documents and SettingsjavaLeeApplication DataSubversionauthsvn.simple

通过TortoiseSVN的clear Authentication Data和手动删除效果是一模一样的!都是对userNameApplication DataSubversionauthsvn.simple目录下的已保存登录用户信息文件进行删除。

未分类

未分类

git fatal: 拒绝合并无关的历史的错误解决

问题描述

本地初始化的项目 与 github 版本不一致, 导致无法提交

$ git pull origin master
来自 https://github.com/itaken/python-login-demo
 * branch            master     -> FETCH_HEAD
fatal: 拒绝合并无关的历史

解决方法

在pull 时候, 添加–allow-unrelated-histories参数 即可.

$ git pull origin master --allow-unrelated-histories                    129 ↵
来自 https://github.com/itaken/python-login-demo
 * branch            master     -> FETCH_HEAD
Merge made by the 'recursive' strategy.
 LICENSE | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 LICENSE

Git add commit误操作撤销的方法

概述

在平时工作中使用git难免会提交一些错误的文件到git库里,这时候,撤销吧,怕把正确的文件删除了,不撤销重新改又很麻烦,下面,我就从提交的三个阶段,来讲解如何撤销错误的操作。

Git Add了一个错误文件

解决方法

这种情况一般发生在新创建的项目,执行命令:

git add .

命令执行完后发现增加了错误的文件,比如Pycham自动生成的.idea文件夹。比如下图:

未分类

这时候,我想撤销add .idea这个操作,可以这么做:

git reset <file> #撤销指定的文件
git reset #撤销所有的文件

执行完这个命令后,效果如下:

未分类

可以看到.idea这个目录变成了Untracked了。完美解决。 如果你在执行的时候遇到如下的错误:

fatal: Failed to resolve 'HEAD' as a valid ref.

如果遇到这个错误,就说明你的本地git仓库从来没有执行过git commit操作,导致HEAD指针不存在。这时候你可以通过如下的命令撤销操作:

git rm --cached .   #删除文件
git rm -r --cached . #删除文件和目录

如何避免

.gitignore: 把不需要提交的文件增加到这个文件
git add : 增加指定的文件,少用点号

Git Commit了一个错误文件

举例

我现在有个文件的状态如下:

未分类

执行git diff blog-test.py后结果如下:

未分类

可以看到我增加了一行,现在把文件提交到本地仓库:

未分类

可以看到,本地以及没有需要提交的文件了。这时候,我发现,这个修改是错误的,我需要撤销这次commit,我该怎么做了?

只撤销commit操作,保留文件

执行命令如下:

git reset HEAD~1

执行完效果如下:

未分类

可以看到,commit被撤销了,但是修改的部分还保留着。完美解决。不信看git log

未分类

撤销commit操作,删除变化

执行命令如下:

git reset --hard HEAD~1

执行完后效果如下:

未分类

可以看到,我增加的那一行已经没有了,git log中也没有了那次的提交记录:

未分类

完美

如何避免

  • git status: 查看是否有不需要的文件被add进来
  • git diff: 查看文件的变化部分,是否是想提交的

查看更多

Git如何取消最新一次的commit: http://bbs.bugcode.cn/t/7

如何删除分支

好,现在有个很严重的问题,我的分支里代码不用了,现在要删除,怎么整。

分支没有push到远程

删除本地的分支很简单:

git branch -d branch_name

举例截图如下:

未分类

分支已经push到远程

我现在本地和远程都有一个test分支,如下图:

未分类
未分类

执行如下的命令删除本地和远程的test分支:

git push origin --delete test
git checkout master
git branch -d test
#git branch -D test 如果有未提交的文件,用它

执行完效果如下:

未分类
未分类

可以看到都删掉了。

总结

出错不可怕,可怕的是你不知道为什么出错以及如何修复错误。所谓亡羊补牢,为时未晚。

zabbix通过stub_status模块实现对nginx的监控

原理

nginx的ngx_http_stub_status_module模块提供了基本的nginx状态信息,源码安装的话需要加上–with-http_stub_status_module编译参数,或者如果是epel源yum安装的话,已经默认启用该模块。在nginx.conf的server段中添加:

location /basic_status {
    stub_status;
    access_log off;
}

那么访问http://xxx.com/basic_status就可以得到7个nginx运行信息了:

Active connections: 291 
server accepts handled requests
 16630948 16630948 31070465 
Reading: 6 Writing: 179 Waiting: 106

各项含义摘抄如下:

Active connections  The current number of active client connections including Waiting connections.

accepts  The total number of accepted client connections.

handled  The total number of handled connections. Generally, the parameter value is the same as acceptsunless some resource limits have been reached (for example, the worker_connections limit).

requests  The total number of client requests.

Reading  The current number of connections where nginx is reading the request header.

Writing  The current number of connections where nginx is writing the response back to the client.

Waiting  The current number of idle client connections waiting for a request.

Active connections/Reading/Writing/Waiting 是状态量,体现了nginx当前的运行状态,需要重点关注。

accepts/handled/requests是统计量,是个历史计数器,其中requests可以反映出“吞吐量”的概念,accepts和handled的差值可以反映出“丢包量”,即nginx由于某种原因丢弃的连接。

由此可以看出,zabbix监控nginx就是通过搜集以上数据,并稍作加工,形成图表供分析。

自定义脚本

zabbix可以通过自定义参数收集自定义信息,详见:https://www.zabbix.com/documentation/3.2/manual/config/items/userparameters

首先需要一个脚本,得到所需数据,然后通过zabbix-agent传给zabbix-server。有几点思路:

1、使用shell脚本即可,简单实用,跟操作系统紧密结合。

2、因为有很多监控项,如果写多个脚本会很乱,最好写成函数形式。

3、直接取accepts和handled的值没什么实际意义,它们的差值表示连接丢弃数量才是我们关心的。但是,这个计算不能放在zabbix-server中进行(item type — Calculation),因为zabbix在取两个值的时候有时间差,而这个时间差得到的结果会导致计算误差。所以必须在shell中算好,直接返回给zabbix-server。

ngx_status.sh代码如下:

#!/bin/bash

URL="http://192.168.7.227:88/ngx_status"
FILE="/tmp/ngx_status.txt"

function active(){
/usr/bin/curl -s $URL |grep Active|awk '{print $3}'
}

function reading(){
/usr/bin/curl -s $URL |grep Reading|awk '{print $2}'
}

function writing(){
/usr/bin/curl -s $URL |grep Writing|awk '{print $4}'
}

function waiting(){
/usr/bin/curl -s $URL |grep Waiting|awk '{print $6}'
}

function requests(){
/usr/bin/curl -s $URL |awk '{if(NR==3) print $3}'
}

function dropped(){
/usr/bin/curl -s $URL > $FILE
accepts=`awk '{if(NR==3) print $1}' $FILE`
handled=`awk '{if(NR==3) print $2}' $FILE`
drop=`expr $accepts - $handled`
echo "$drop"
}

function ping(){
/usr/sbin/pidof nginx|wc -l
}

#根据脚本参数执行对应应函数
$1

zabbix-agent端添加以下配置:

# cat /etc/zabbix/zabbix_agentd.d/nginx_status.conf
UserParameter=nginx.status[*],/etc/zabbix/zabbix_agentd.d/nginx_status.sh $1

创建zabbix模版

active/reading/writing/waiting/requests都是一样的,方法如下:

未分类

吞吐量是由计算得出:

未分类

上面使用计算的方法没必要,官方已经提供了内置的delta数据类型来处理此类需求:

未分类

nginx存活状态是个布尔量,创建方法:

未分类

未分类

可以对这个item配置trigger,当nginx挂了做相应操作。

最后,我们可以创建几个图表,方便分析,因为是测试环境,基本没啥访问量^_^:

未分类

模版文件,适用于zabbix-3.2.7-1:https://github.com/dmli30/shell/blob/master/zabbix/ngx_status_templates.xml

Zabbix 3.2.1运行在PHP 7.1.7出现的问题解决

安装完成用admin账号登陆后,出现红色的框框显示这个:

A non well formed numeric value encountered [zabbix.php:21 → require_once() → ZBase->run() → ZBase->processRequest() → CView->getOutput() → include() → make_status_of_zbx() → CFrontendSetup->checkRequirements() → CFrontendSetup->checkPhpMemoryLimit() → str2mem() in include/func.inc.php:410]
A non well formed numeric value encountered [zabbix.php:21 → require_once() → ZBase->run() → ZBase->processRequest() → CView->getOutput() → include() → make_status_of_zbx() → CFrontendSetup->checkRequirements() → CFrontendSetup->checkPhpPostMaxSize() → str2mem() in include/func.inc.php:410]
A non well formed numeric value encountered [zabbix.php:21 → require_once() → ZBase->run() → ZBase->processRequest() → CView->getOutput() → include() → make_status_of_zbx() → CFrontendSetup->checkRequirements() → CFrontendSetup->checkPhpUploadMaxFilesize() → str2mem() in include/func.inc.php:410]

网上查了一下,这是因为PHP 7.1.7类型强化,处理方法是找到Zabbix WEB目录下include/func.inc.php文件,修改它

sed -i '/$last = strtolower(substr($val, -1));/a$val = substr($val,0,-1);' func.inc.php

问题依然未能解决,后来查看了一下func.inc.php代码,跳转到报错的位置#410,通过网上的解决方法分析,应该是val这个变量类型问题,在403行后添加一行$val = substr($val,0,-1); 保存修改后的文件,重新访问zabbix web界面即可。

ZABBIX忘记登录密码重置方法

未分类

刚刚在群里吹牛逼,由于账号比较多,脑子容易瓦特. 结果忘记自己的zabbix登录密码下面是找回登录密码的例子

未修改之前(忘记登录密码)
[root@abcdocker ~]# mysql -uroot -p -e "select * from zabbix.usersG"
Enter password: 
*************************** 1. row ***************************
            userid: 1
             alias: Admin
              name: Zabbix
           surname: Administrator
            passwd: ab66b6e18854fa4d45499d0a04a47b64
               url: 
         autologin: 1
        autologout: 0
              lang: en_GB
           refresh: 30
              type: 3
             theme: default
    attempt_failed: 0
        attempt_ip: 14.130.112.2
     attempt_clock: 1501141026
     rows_per_page: 50

登录MySQL 修改密码

[root@abcdocker ~]# mysql -uroot -p
由于密码是md5加密的,我们可以查看默认的zabbix密码的md5
mysql> use zabbix;
mysql> update users set passwd='5fce1b3e34b520afeffb37ce08c7cd66' where userid='1';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
解释:5fce1b3e34b520afeffb37ce08c7cd66  = zabbix
因为zabbix默认密码就是zabbix

登录 Web

用户名:Admin
密码:zabbix

未分类

提示:登陆上请马上修改密码

未分类

未分类

完!

zabbix添加cpu使用率图形监控

zabbix版本: 3.2.5

zabbix 自带的windows模板中没有监控cpu使用率的,可以在模板里自己添加

1、配置 —> 模板—> Template OS Windows

2、监控项 —-> 添加监控项

未分类

应用集 : CPU

3、图形 —-> 添加图形

取个名称, 监控项选择刚才的新建的

未分类

4、添加触发器

模板 —> Template OS Windows —> 触发器

未分类

{Template OS Windows:system.cpu.util[,,].avg(5m)}>85

Zabbix 3.2.6通过SNMP和iDRAC监控DELL服务器

一、总览

SNMP是监控服务器以外设备的非常好的方式,比如可以用于监控打印机、交换机、路由器等,只要是有SNMP功能,Zabbix都可以监控。

SNMP检查是通过UDP协议,从Zabbix 2.2.3开始,一次SNMP请求可以查询设备的多个值,覆盖到SNMP的所有项目值,这样是SNMP进程变得更加高效,从Zabbix 2.4开始,在创建SNMP接口的地方有一个”Use bulk requests”的选项,可以禁用对它不适用的设备。

iDRAC又称为Integrated Dell Remote Access Controller,也就是集成戴尔远程控制卡,iDRAC卡相当于是附加在服务器上的一台小电脑,通过与服务器主板上的管理芯片BMC进行通信,监控与管理服务器的硬件状态信息。它拥有自己的系统和IP地址,与服务器上的OS无关。是管理员进行远程访问和管理的利器

二、安装配置Zabbix server

1、编译zabbix server支持

要想支持通过SNMP监控服务器信息,需要在编译的时候加上参数–with-net-snmp,解决依赖需要安装如下软件包。

yum -y install net-snmp-devel

2、配置DELL管理卡

登录远程管理卡,如下

未分类

登录之后单击 —> iDRAC设置 —> 网络 —> 服务 —> SNMP代理,以下几个参数zabbix会用到。

已启用              √ 
SNMP团体名称       wzlinux 
SNMP协议          所有(SNMP v1/2/3) 
SNMP查找端口号     161

未分类

3、zabbix 服务端通过snmp验证

我们使用的工具是snmpget,需要安装如下软件包支持。

yum -y install net-snmp-utils

使用如下指令简单验证一下,我们使用SNMPv2版本。

snmpget -v 2c -c <Community> <iDRAC IP> .1.3.6.1.4.1.674.10892.2.1.1.2.0
# snmpget -v 2c -c wzlinux 10.0.0.99 .1.3.6.1.4.1.674.10892.2.1.1.2.0
SNMPv2-SMI::enterprises.674.10892.2.1.1.2.0 = STRING: "iDRAC8"

三、配置Zabbix WEB端

1、创建值映射

通常需要创建以下值映射,zabbix 3.0以上版本使用我附件的模板可以自动创建。

Menu: Administration->General->Value mapping->Create value map
  • DellDracDiskState
1 -> Unknown
2 -> Ready
3 -> Online
4 -> Foreign
5 -> Offline
6 -> Blocked
7 -> Failed
8 -> Non-RAID
9 -> Removed
  • Dell iDRAC Network Device Connection Status
1 -> Connected
2 -> Disconnected
Dell Open Manage System Status
1 -> Other
2 -> Unknown
3 -> OK
4 -> NonCritical
5 -> Critical
6 -> NonRecoverable
  • DellPowerState
1 -> Other
2 -> Unknown
3 -> Off
4 -> On
  • Dell PSU State Settings
1 -> Unknown
2 -> Online (state disabled)
4 -> not Ready
8 -> Fan Failure
10 -> Online and Fan Failure
16 -> On
242 -> Online and OK
  • DellRaidLevel
1 -> Unknown
2 -> RAID-0
3 -> RAID-1
4 -> RAID-5
5 -> RAID-6
6 -> RAID-10
7 -> RAID-50
8 -> RAID-60
9 -> Concatenated RAID 1
10 -> Concatenated RAID 5
  • DellRaidVolumeState
1 -> Unknown
2 -> Online
3 -> Failed
4 -> Degraded
  • Dell_PSU_SensorState
1 -> Presence Detected
2 -> PS Failure
4 -> Predictuve Failure
8 -> PS AC lost
16 -> AC lost or out of range
32 -> AC out of range but still present

2、配置全局变量{$SNMP_COMMUNITY_IDRAC}

Menu:Administration->General->Macros

Value处填写iDRAC的WEB上配置的SNMP团体名(Community)

未分类

3、导入模板

模板见本文附件,“Template Dell iDrac SNMPV2 zbx2.2.xml”支持zabbix2.2版本,“Template Dell iDrac SNMPV2 zbx3.xml”支持zabbix3版本。

Menu:Configuration->Templates->Import,导入“Template Dell iDrac SNMPV2”模板。

未分类

4、创建主机

Menu:Configuration->Hosts->Create host

未分类

未分类

四、验证

经过一段时间,我们可以看到SNMP正常监控了,自带模板没有Graphs,可以自己创建需要监控的项目查看。

未分类

未分类

使用percona-xtrabackup(innobackupex)工具快速配置mysql5.6.34主从同步复制

percona-xtrabackup工具实现mysql5.6.34的主从同步复制

未分类

下载并安装percona-xtrabackup工具

# wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.7/binary/redhat/6/x86_64/percona-xtrabackup-24-2.4.7-1.el6.x86_64.rpm

# yum localinstall -y percona-xtrabackup-24-2.4.7-1.el6.x86_64.rpm

1、备份,将MySQL数据库整个备份到/opt/目录下

# innobackupex --defaults-file="/etc/my.cnf" --user=root -proot --socket=/tmp/mysql.sock /opt

2、预处理,进行事物检查(也可以拷贝到从库后再进行检查)

# innobackupex --defaults-file="/etc/my.cnf" --user=root -proot --socket=/tmp/mysql.sock --apply-lg --use-memory=1G /opt/2017-05-18_00-13-42/

3、scp到从库

[root@centossz008 ~]# scp -r /opt/2017-05-18_01-34-42/ 192.168.3.13:/opt

4、关闭从库,清理从库数据,恢复数据到从库

/etc/init.d/mysqld stop

删除从库的数据和日志信息

[root@node5 ~]# rm -rf /data/mydata/*
[root@node5 ~]# rm -rf /data/binlogs/*
[root@node5 ~]# rm -rf /data/relaylogs/*

在从库上执行(将数据恢复到数据库中)

[root@node5 ~]# innobackupex --defaults-file="/etc/my.cnf" --user=root --socket=/tmp/mysql.sock --move-back /opt/2017-05-18_01-34-42/

5、修改权限,启动从库

[root@node5 mydata]# chown -R mysql.mysql /data
[root@node5 mydata]# /etc/init.d/mysqld start

查看主库中master位置

[root@node5 mydata]# cat /opt/2017-05-18_01-34-42/xtrabackup_binlog_info 
master-bin.000002    191    4c6237f8-a7da-11e6-9966-000c29f333f8:1-2

6、主库中创建建salve同步用户

mysql> grant replication slave,reload,super on *.* to [email protected] identified by 'replpass';
mysql> FLUSH PRIVILEGES;

7、从库执行同步

mysql> change master to master_host='192.168.3.12',master_user='repluser',master_password='replpass',master_log_file='master-bin.000002',master_log_pos=191;
mysql> start slave;

mysql> show slave statusG
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.3.12
Master_User: repluser
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: master-bin.000002
Read_Master_Log_Pos: 586
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 710
Relay_Master_Log_File: master-bin.000002
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: 586
Relay_Log_Space: 908
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: 
Replicate_Ignore_Server_Ids: 
Master_Server_Id: 100
Master_UUID: 4c6237f8-a7da-11e6-9966-000c29f333f8
Master_Info_File: /data/mydata/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind: 
Last_IO_Error_Timestamp: 
Last_SQL_Error_Timestamp: 
Master_SSL_Crl: 
Master_SSL_Crlpath: 
Retrieved_Gtid_Set: 4c6237f8-a7da-11e6-9966-000c29f333f8:3-4
Executed_Gtid_Set: 4c6237f8-a7da-11e6-9966-000c29f333f8:3-4
Auto_Position: 0
1 row in set (0.00 sec)

延迟复制:

启用方法:

mysql> stop slave;
mysql> change master to master_delay=600;
mysql> start slave;

应用场景:

1、误删除恢复
2、延迟测试(当有延迟时业务是否会受影响)
3、历史查询

mysql master 配置

[root@centossz008 ~]# cat /etc/my.cnf 
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8mb4

[mysqld]
port = 3306
innodb_file_per_table = 1
binlog-format=ROW
log-slave-updates=true
gtid-mode=on 
enforce-gtid-consistency=true
master-info-repository=file
relay-log-info-repository=file
sync-master-info=1
slave-parallel-workers=4
binlog-checksum=CRC32
master-verify-checksum=1
slave-sql-verify-checksum=1
binlog-rows-query-log_events=1
server-id=100
report-port=3306
log-bin=/data/binlogs/master-bin
max_binlog_size = 200M
datadir=/data/mydata
socket=/tmp/mysql.sock
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES


init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4

skip-name-resolve
skip-external-locking

back_log = 300
max_connections = 1024
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M

read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
query_cache_type = 1
query_cache_size = 16M
query_cache_limit = 2M
ft_min_word_len = 4
expire_logs_days = 10
performance_schema = 0
explicit_defaults_for_timestamp

default_storage_engine = InnoDB
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 4
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120

bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 512M
myisam_repair_threads = 1

interactive_timeout = 28800
wait_timeout = 28800

[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M

mysql slave 配置

[root@node5 src]# cat /etc/my.cnf 
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8mb4

[mysqld]

port = 3306
innodb_file_per_table = 1
binlog-format=ROW
log-slave-updates=true
gtid-mode=on 
enforce-gtid-consistency=true
master-info-repository=file
relay-log-info-repository=file
sync-master-info=1
slave-parallel-workers=4
binlog-checksum=CRC32
master-verify-checksum=1
slave-sql-verify-checksum=1
binlog-rows-query-log_events=1
server-id=200
report-port=3306
log-bin=/data/binlogs/master-bin
relay-log=/data/relaylogs/relay-bin
max_binlog_size = 200M
datadir=/data/mydata
socket=/tmp/mysql.sock
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4

skip-name-resolve
skip-external-locking

back_log = 300
max_connections = 1024
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M

read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
query_cache_type = 1
query_cache_size = 16M
query_cache_limit = 2M
ft_min_word_len = 4
expire_logs_days = 10
performance_schema = 0
explicit_defaults_for_timestamp

default_storage_engine = InnoDB
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 4
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120

bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 512M
myisam_repair_threads = 1

interactive_timeout = 28800
wait_timeout = 28800

[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M

cenos6上启动mysql服务报错:

070517 23:08:52 mysqld_safe Starting mysqld daemon with databases from /data/mydata
2107-05-17 23:08:56 0 [ERROR] This MySQL server doesn't support dates later then 2038
2107-05-17 23:08:56 0 [ERROR] Aborting

将时间修改为1年前,即可启动,启动完成后改回时间即可

更换WordPress网站域名的方法

我们以手头的演示网站为例,介绍一下如何将WordPress网站的域名从旧域名 www.mydomain.com 更换为新域名 www.newdomain.com 。

第一步,开始之前,请先做好网站的备份,备份好网站数据库和网站文件。尤其是数据库,一定要做好备份,以防操作过程中出现错误,我们可以使用备份的数据库重新进行操作。

第二步,将新域名做好解析和绑定操作。解析新域名,就是将域名指向服务器的IP地址,通常在域名商那里进行操作;绑定新域名,通常在空间商那里进行操作,就是在服务器上添加新域名,并确保网站目录和旧域名的网站目录一致。

完成以上两步之后,需要确认新域名生效之后,再继续进行以下操作。新域名设置解析后,通常需要一段时间才能传递到各地网络,各地生效时间并不一致,通常需要几分钟或者几个小时,最多不会超过48小时。你可以使用ping命令来检查,来查看新域名是否生效。如果ping出来的ip地址是刚刚设置的ip,那么解析就生效了。

新域名生效之后,这个时候在浏览器中输入新域名和旧域名,都可以打开原来的网站。如果旧域名已经失效,比如说已经过期,或者已经解析到其他地方等,那么网站虽然可以打开,但网页看起来会比较乱;这是因为网页无法正常加载WordPress主题的样式表。

第三步,登录主机管理系统,进入phpmyadmin,选择WordPress网站所使用的数据库。如果你不确定WordPress使用的是哪一个数据库,可以查看WordPress目录下的wp-config.php配置文件,查看其中的 DB_NAME 设置。

选中该数据库之后,点击SQL,输入以下代码:

UPDATE wp_options SET option_value = replace(option_value,'www.mydomain.com','www.newdomain.com') ;

UPDATE wp_posts SET post_content = replace(post_content, 'www.mydomain.com','www.newdomain.com') ;

UPDATE wp_comments SET comment_content = replace(comment_content, 'www.mydomain.com', 'www.newdomain.com') ;

UPDATE wp_comments SET comment_author_url = replace(comment_author_url, 'www.mydomain.com', 'www.newdomain.com') ;

以上代码中,www.mydomain.com 代表原来的域名,www.newdomain.com 代表新域名。域名一定要输入完整;如果你使用类似 blog.newdomain.com 这样的二级域名,也是可以的,只要输入完整域名就可以了。

然后点击右下角的【执行】按钮,就可以了。phpmyadmin会返回结果,告诉你每行命令修改了多少处地方。这样,我们就将WordPress的域名完美地切换到新的域名了。

与直接在WordPress的管理后台修改域名相比,今天介绍的这个办法有两个优点:

  1. 即便旧域名已经失效了,也可以更换新域名;因为整个操作过程中,根本不需要登陆WordPress的管理后台。

  2. 更换比较彻底,不光更换了网站的域名,连文章内部的链接,图片和音视频等媒体文件的地址、链接,以及评论中的链接等,都一起进行了更换。

因此,通过以上操作,可以比较完美地更换WordPress网站域名。现在,再使用新域名去访问你的WordPress网站试试吧。