版本控制系统Git的分支管理策略

git的分支管理策略,最流行的莫过于大神nvie提出的策略.

一个中心版本库(我们叫它origin)至少包括两个分支,即“主分支(master)”和“开发分支(develop)”.

要确保:团队成员从主分支(master)获得的都是处于可发布状态的代码,而从开发分支(develop)应该总能够获得最新开发进展的代码

master分支

未分类

develop分支

未分类

团队开发,其中浅蓝色代表master分支,黄色代表develop分支,其他代表团队成员研发需要创建的分支.

未分类

临时分支

Master和Develop。前者用于正式发布,后者用于日常开发。为了满足开发需要.还要有一些临时性分支,用于应对一些特定目的的版本开发。

临时性分支主要有三种:

  • 功能(feature)分支
  • 预发布(release)分支
  • 修补bug(hotfixs)分支

这三种分支都属于临时性需要,使用完以后,应该删除,使得代码库的常设分支始终只有Master和Develop。

公司项目代码服务器中通常保存项目的Master和Develop,其他分支都在开发成员本地或者其私有远程仓库.

创建一个功能分支

当要开发一个新功能时,从开发分支分出一个功能分支:

$ git checkout -b myfeature develop #创建并切换到myfeature分支

将完成的功能分支合并回开发分支.完成功能可能被合并到开发分支,一定会添加它们至即将发布版本:

git checkout develop #切换到develop分支

git merge --no-ff myfeature #以no-ff方式将其合并到develop分支

git branch -d myfeature #删除临时分支

git push origin develop #将本地develop分支推送到远程develop分支中

–no-ff标签会使合并时总会创建一个新的提交对象(前面文章已经介绍了),即使这个合并本来可以使用快速合并。这避免了丢失功能分支的历史信息和团队共同添加到功能分支的所有提交。对比一下

未分类

在第二种情况下,你不可能从Git提交对象历史中看到实现的功能,你不得不手动地读取所有的日志消息。并且还原所有功能(即一组提交)是非常头疼大;如果使用了–no-ff标记那会变的很容易。

它会创建更大的提交对象,不过受益会更大!

预发布分支

预发布分支,它是指发布正式版本之前(即合并到Master分支之前),我们可能需要有一个预发布的版本进行测试。

预发布分支是从Develop分支上面分出来的,预发布结束以后,必须合并进Develop和Master分支。它的命名,可以采用release-xxx的形式。

流程:

git checkout -b release-1.2 develop #以develop为基础,创建一个预发布分支

git checkout master #切回master分支

git merge --no-ff release-1.2 #以no-ff方式合并到master

git tag -a 1.2 # 对合并生成的新节点,做一个标签


git checkout develop #切换到develop分支

git merge --no-ff release-1.2 #合并到develop分支中

git branch -d release-1.2 #删除预发布分支

修补bug分支

最后一种是修补bug分支。软件正式发布以后,难免会出现bug。这时就需要创建一个分支,进行bug修补。

修补bug分支是从Master分支上面分出来的。修补结束以后,再合并进Master和Develop分支。它的命名,可以采用hotfix-xxx的形式。

未分类

流程:

git checkout -b hotfix-0.1 master #以master分支为基础创建hotfix-0.1分支

git checkout master #切回master分支

git merge --no-ff hotfix-0.1 #将其合并到master

git tag -a 0.1.1 #为master分支打标签

git checkout develop #切回develop分支

git merge --no-ff hotfix-0.1# 将其合并到develop

git branch -d hotfix-0.1 #删除临时分支

最终一个开发流程如下所示:

未分类

配置ssh连接多个Git服务器

背景:在工作中,都会有一个工作的Git帐号(公司Gitlab),而空闲时间做的个人东西又想放进Github里面,这时候就需要配置两个帐号和服务器。假设之前已经配置好了工作的帐号,打开git bash:

1、创建个人的SSH key

#新建SSH key:  
$ cd ~/.ssh     # 切换到C:UsersAdministrator.ssh  
ssh-keygen -t rsa -C "[email protected]"  # 新建工作的SSH key  
# 设置名称为id_rsa_hason(名字随意)  
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa): id_rsa_hason  

2、添加新密钥到SSH agent:

因为默认只读取id_rsa,为了让SSH识别新的私钥,需将其添加到SSH agent中:

ssh-add ~/.ssh/id_rsa_hason  

注意:如果出现Could not open a connection to your authentication agent,参考底部详情

3、修改config文件

若~/.ssh/目录下不存在config文件,则新建一个,内容写上:

# 该配置用于工作  
# Host 服务器别名  
Host 192.168.2.36  
# HostName 服务器ip地址或机器名  
HostName 192.168.2.36  
# User连接服务器的用户名  
User huanghs  
# IdentityFile 密匙文件的具体路径  
IdentityFile C:/Users/P/.ssh/id_rsa  


# 该配置用于个人 github 上  
# Host 服务器别名  
Host github.com  
# HostName 服务器ip地址或机器名  
HostName github.com  
# User连接服务器的用户名  
User hasonHuang  
# IdentityFile 密匙文件的具体路径  
IdentityFile C:/Users/P/.ssh/id_rsa_hason

4、添加新密钥到Github

把~/.ssh/id_rsa_hason.pub的内容添加到Github的SSH keys中

5、测试

使用ssh -T git@Host进行测试,其中Host指上面配置的服务器别名

ssh -T [email protected]  

未分类

6、大功告成!

常见问题:

出现Could not open a connection to your authentication agent

3种解决方法:

  • 先输入ssh-agent bash,然后再输入ssh-add ~/.ssh/id_rsa_hason;

  • 先输入eval $(ssh-agent),然后输入ssh-add ~/.ssh/id_rsa_hason;

  • 使用Git GUI生成密钥,密钥会自动被加进ssh-agent中;

CentOS 7.2安装配置zabbix 3.0 LTS

1、zabbix简介

  
zabbix(音同 zæbix)是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
  
zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
  
zabbix由2部分构成,zabbix server与可选组件zabbix agent。
  
zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。

更多详细信息请访问zabbix官网:https://www.zabbix.com/

2、zabbix版本选择

企业使用建议选择zabbix的LTS版本(Long Time Support),尝鲜的可以选择官方的最新版本。

3、zabbix安装

本篇随笔基于CentOS 7.2编写。适用于CentOS 7所有版本及RedHat系列。
  
官方yum源:http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
  
阿里云yum源:https://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
  
安装官方的yum源

[root@zabbix-server ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
Retrieving http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.PutPhp: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-3.2-1.el7         ################################# [100%]
[root@zabbix-server ~]#

  
查看都安装了什么

[root@zabbix-server ~]# rpm -ql zabbix-release
/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
/etc/yum.repos.d/zabbix.repo
/usr/share/doc/zabbix-release-3.0
/usr/share/doc/zabbix-release-3.0/GPL
[root@zabbix-server ~]#

  
安装zabbix及其他必须的软件

[root@zabbix-server ~]# yum install -y zabbix-server-mysql zabbix-web-mysql

  
由于CentOS 7比较特殊,MySQL已经没了,只能安装mariadb:

[root@zabbix-server ~]# yum install -y mariadb-server

启动并设置开机自启动数据库

[root@zabbix-server bin]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@zabbix-server bin]# systemctl start mariadb.service
[root@zabbix-server bin]#

  
初始化数据库

[root@zabbix-server ~]# find / -type f -name "mysql_secure_installation"
/usr/bin/mysql_secure_installation    #mariadb数据库自带的初始化脚本
[root@zabbix-server ~]#
[root@zabbix-server bin]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:    #123456
Re-enter new password:    #123456
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
[root@zabbix-server bin]#

  
创建zabbix数据库

[root@zabbix-server ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 10
Server version: 5.5.52-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.01 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> q
Bye
[root@zabbix-server ~]#

  
导入zabbix库的数据

[root@zabbix-server ~]# ll /usr/share/doc/zabbix-server-mysql-3.2.7/create.sql.gz
-rw-r--r-- 1 root root 1161488 Jul 19 00:09 /usr/share/doc/zabbix-server-mysql-3.2.7/create.sql.gz
[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql-3.2.7/create.sql.gz|mysql -uzabbix -p zabbix
Enter password:
[root@zabbix-server ~]# mysql -uzabbix -p123456 -e "use zabbix;show tables;"
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
| application_discovery      |
| application_prototype      |
| application_template       |
| applications               |
| auditlog                   |
| auditlog_details           |
| autoreg_host               |
| conditions                 |
| config                     |
| corr_condition             |
| corr_condition_group       |
| corr_condition_tag         |
| corr_condition_tagpair     |
| corr_condition_tagvalue    |
| corr_operation             |
| correlation                |
| dbversion                  |
| dchecks                    |
| dhosts                     |
| drules                     |
| dservices                  |
| escalations                |
| event_recovery             |
| event_tag                  |
| events                     |
| expressions                |
| functions                  |
| globalmacro                |
| globalvars                 |
| graph_discovery            |
| graph_theme                |
| graphs                     |
| graphs_items               |
| group_discovery            |
| group_prototype            |
| groups                     |
| history                    |
| history_log                |
| history_str                |
| history_text               |
| history_uint               |
| host_discovery             |
| host_inventory             |
| hostmacro                  |
| hosts                      |
| hosts_groups               |
| hosts_templates            |
| housekeeper                |
| httpstep                   |
| httpstepitem               |
| httptest                   |
| httptestitem               |
| icon_map                   |
| icon_mapping               |
| ids                        |
| images                     |
| interface                  |
| interface_discovery        |
| item_application_prototype |
| item_condition             |
| item_discovery             |
| items                      |
| items_applications         |
| maintenances               |
| maintenances_groups        |
| maintenances_hosts         |
| maintenances_windows       |
| mappings                   |
| media                      |
| media_type                 |
| opcommand                  |
| opcommand_grp              |
| opcommand_hst              |
| opconditions               |
| operations                 |
| opgroup                    |
| opinventory                |
| opmessage                  |
| opmessage_grp              |
| opmessage_usr              |
| optemplate                 |
| problem                    |
| problem_tag                |
| profiles                   |
| proxy_autoreg_host         |
| proxy_dhistory             |
| proxy_history              |
| regexps                    |
| rights                     |
| screen_user                |
| screen_usrgrp              |
| screens                    |
| screens_items              |
| scripts                    |
| service_alarms             |
| services                   |
| services_links             |
| services_times             |
| sessions                   |
| slides                     |
| slideshow_user             |
| slideshow_usrgrp           |
| slideshows                 |
| sysmap_element_url         |
| sysmap_url                 |
| sysmap_user                |
| sysmap_usrgrp              |
| sysmaps                    |
| sysmaps_elements           |
| sysmaps_link_triggers      |
| sysmaps_links              |
| task                       |
| task_close_problem         |
| timeperiods                |
| trends                     |
| trends_uint                |
| trigger_depends            |
| trigger_discovery          |
| trigger_tag                |
| triggers                   |
| users                      |
| users_groups               |
| usrgrp                     |
| valuemaps                  |
+----------------------------+
[root@zabbix-server ~]#

修改zabbix-server配置文件

[root@zabbix-server ~]# vim /etc/zabbix/zabbix_server.conf
# This is a configuration file for Zabbix server daemon
# To get more information about Zabbix, visit http://www.zabbix.com
############ GENERAL PARAMETERS #################
### Option: ListenPort
#       Listen port for trapper.
#
# Mandatory: no
# Range: 1024-32767
# Default:
# ListenPort=10051
### Option: SourceIP
#       Source IP address for outgoing connections.
#
# Mandatory: no
# Default:
# SourceIP=
### Option: LogType
#       Specifies where log messages are written to:
#               system  - syslog
#               file    - file specified with LogFile parameter
#               console - standard output
#
# Mandatory: no
# Default:
# LogType=file
### Option: LogFile
#       Log file name for LogType 'file' parameter.
#
# Mandatory: no
# Default:
# LogFile=
LogFile=/var/log/zabbix/zabbix_server.log
### Option: LogFileSize
#       Maximum size of log file in MB.
#       0 - disable automatic log rotation.
/DBHost
#       1 - critical information
#       2 - error information
#       3 - warnings
#       4 - for debugging (produces lots of information)
#       5 - extended debugging (produces even more information)
#
# Mandatory: no
# Range: 0-5
# Default:
# DebugLevel=3
### Option: PidFile
#       Name of PID file.
#
# Mandatory: no
# Default:
# PidFile=/tmp/zabbix_server.pid
PidFile=/var/run/zabbix/zabbix_server.pid
### Option: DBHost
#       Database host name.
#       If set to localhost, socket is used for MySQL.
#       If set to empty string, socket is used for PostgreSQL.
#
# Mandatory: no
# Default:
# DBHost=localhost
### Option: DBName
#       Database name.
#       For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored.
#
# Mandatory: yes
# Default:
# DBName=
DBName=zabbix
### Option: DBSchema
#       Schema name. Used for IBM DB2 and PostgreSQL.
#
# Mandatory: no
# Default:
# DBSchema=
### Option: DBUser
#       Database user. Ignored for SQLite.
#
# Mandatory: no
# Default:
# DBUser=
DBUser=zabbix
### Option: DBPassword
#       Database password. Ignored for SQLite.
#       Comment this line if no password is used.
#
# Mandatory: no
# Default:
# DBPassword=
DBPassword=123456
### Option: DBSocket
#       Path to MySQL socket.
#
# Mandatory: no
# Default:
# DBSocket=/tmp/mysql.sock
### Option: DBPort
"/etc/zabbix/zabbix_server.conf" 642L, 14894C written                                                  
[root@zabbix-server ~]#

  
启动zabbix-server服务

[root@zabbix-server ~]# systemctl start zabbix-server
[root@zabbix-server ~]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@zabbix-server ~]#

设置正确的时区

[root@zabbix-server conf.d]# vim /etc/httpd/conf.d/zabbix.conf
#
# Zabbix monitoring system php web frontend
#
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
    Options FollowSymLinks
    AllowOverride None
    Require all granted
    <IfModule mod_php5.c>
        php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        php_value always_populate_raw_post_data -1
        php_value date.timezone Asia/Shanghai
    </IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
    Require all denied
</Directory>
<Directory "/usr/share/zabbix/app">
    Require all denied
</Directory>
<Directory "/usr/share/zabbix/include">
    Require all denied
</Directory>
<Directory "/usr/share/zabbix/local">
    Require all denied
</Directory>
~                                                                                                                        
~                                                                                                                        
~                                                                                                                        
~                                                                                                                        
~                                                                                                                        
"zabbix.conf" 37L, 831C written                                                                        
[root@zabbix-server conf.d]#

启动httpd

[root@zabbix-server conf.d]# systemctl start httpd
[root@zabbix-server conf.d]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@zabbix-server conf.d]#

浏览器访问:http://10.0.0.11/zabbix

未分类  

web界面会自动检查所有的条件是否满足,未满足的会提示。
  
未分类

配置数据库连接
  
未分类

默认不需要修改,只需要自己随便设置一个name就可以了。

未分类

所有的设置信息全部显示,可以查看校验是否有误

未分类

成功界面,显示成功安装zabbix,并告知配置文件及路径

未分类

登录界面,默认用户名Admin,默认密码zabbix。

未分类

登陆之后,进入zabbix监控页

未分类

zabbix3.0之后,默认支持中文显示,修改成中文步骤如下

未分类

中文显示界面如下

未分类

zabbix-agent客户端安装

[root@zabbix-server~]# yum install -y zabbix-get zabbix-agent    #其中zabbix-agent负责数据收集,zabbix-get是一个server端模拟数据收集的命令,常用语部署自定义监控前的测试工具

  
启动zabbix-agent

[root@zabbix-server conf.d]# systemctl start zabbix-agent.service
[root@zabbix-server conf.d]# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.

  
检查

[root@zabbix-server conf.d]# netstat -lnutp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      4398/mysqld         
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1465/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1774/master         
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      5293/zabbix_agentd  
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      4538/zabbix_server  
tcp6       0      0 :::80                   :::*                    LISTEN      4685/httpd          
tcp6       0      0 :::22                   :::*                    LISTEN      1465/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      1774/master         
tcp6       0      0 :::10050                :::*                    LISTEN      5293/zabbix_agentd  
tcp6       0      0 :::10051                :::*                    LISTEN      4538/zabbix_server  
udp        0      0 127.0.0.1:323           0.0.0.0:*                           3293/chronyd        
udp6       0      0 ::1:323                 :::*                                3293/chronyd        
[root@zabbix-server conf.d]#

zabbix监控Memcached状态

一、安装 memcached

# yum -y installlibevent libevent-devel

#wget http://memcached.org/files/memcached-1.5.0.tar.gz

#tar -zxvf memcached-1.5.0.tar.gz

#cd memcached-1.5.0/

#./configure --with-libevent=/usr/

# make && make install

二、监控端配置

#启动memcached

#/usr/local/bin/memcached -d -m 128 -l 192.168.1.207 -p 11211 -u root



#配置zabbix-agent

# vi/etc/zabbix/zabbix_agentd.conf

PidFile=/var/run/zabbix/zabbix_agentd.pid

LogFile=/var/log/zabbix/zabbix_agentd.log

LogFileSize=0

Server=192.168.1.208

Hostname=192.168.1.207

Include=/etc/zabbix/zabbix_agentd.d/*.conf

UnsafeUserParameters=1



# vi/etc/zabbix/zabbix_agentd.d/userparameter_memcached.conf

UserParameter=memcached_stats[*],(echostats; sleep 1) | telnet 192.168.1.207 $1 2>&1 | awk '/STAT $2 / {print$NF}'



# systemctl start zabbix-agent



# Server端手动测试

#zabbix_get -s 192.168.1.207 -p 10050 -k'memcached_stats[11211,accepting_conns]'

三、WEB端配置

上传模板

模板下载地址:
http://download.csdn.net/detail/m0_37313242/9920278

未分类

Xtrabackup全量备份/增量备份脚本

未分类

一、全量备份脚本

1、全量备份脚本

#!/bin/bash
#Description:xtrabackup complete
#Author:created by michael
#2017-08-07 v0.1
#
USER=root
PASSWD=123456
BACKUP_DIR=/backup/mysql/complete
DATE=$(date +"%F_%T")
[[ -d $BACKUP_DIR ]] || mkdir $DATE_DIR
innobackupex --user=$USER --password=$PASSWD $BACKUP_DIR &> /tmp/mysql/"$DATE".txt
egrep ".* Backup created in directory.*" /tmp/mysql/"$DATE".txt >> $BACKUP_DIR/complete.info
rm -rf /tmp/mysql/"$DATE".txt

2、启动crond以及开机自启动crond

systemctl start crond
systemctl enable crond

3、授予执行权限

chmod 755 /root/script/backup_complete.sh

4、每周六的凌晨4点整定时执行全量备份

[root@michaelos complete]# crontab -e
crontab: installing new crontab
[root@michaelos complete]# crontab -l
0 4 * * 6 /root/script/backup_complete.sh

二、增量备份脚本

1、增量备份脚本

[root@michaelos script]# cat backup_increment.sh 
#!/bin/bash 
#Description: mysql backup incremention
#Author:michael
#2017-08-07 v0.1
#
USER=root
PASSWORD=123456
BACKUP_DIR=/backup/mysql/increment
DATE=$(date +"%F_$T")
BASE_DIR=$(tail -1 /backup/mysql/complete/complete.info | cut -d' -f2)
[[ -d $BACKUP_DIR ]] || mkdir $BACKUP_DIR
innobackupex --user=$USER --password=$PASSWORD --incremental $BACKUP_DIR --incremental-basedir=$BASE_DIR &> /tmp/mysql/"$DATE".txt
egrep ".*Backup created in directory.*" /tmp/mysql/"$DATE".txt >> $BACKUP_DIR/backup.info
rm -rf /tmp/mysql/"$DATE".txt

2、授予执行权限

chmod 755 backup_increment.sh

3、每周二、四、日的凌晨2点执行增量备份

[root@michaelos script]# crontab -l
0 4 * * 6 /root/script/backup_complete.sh
0 2 * * 2,4,7 /root/script/backup_increment.sh

迁移wordpress并更换域名方法

迁移WordPress

第一步,打包原数据库和网站整站源码。

第二步,源码上传到新服务器上,数据库新建后恢复。

第三步,将域名解析到新服务器上。

第四步,删除新服务器上WordPress文件夹目录里的wp-config.php文件

第五部,通过域名打开网站,会提示从新安装WordPress,按照步骤填入新数据库信息,完成,你的数据是不是完整迁移啦!

WordPress更改域名教程

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

第二步,将新域名做好解析和绑定操作。解析新域名,就是将域名指向服务器的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网站试试吧。

centos7.3下配置LAMP部署WordPress博客

在同一台主机上搭建,首先需要安装的软件包Apache 、MariaDB 、PHP

未分类

一、安装LAMP 这里我们采用yum的方式

yum install httpd mariadb-server php php-mysql -y

未分类

二、创建虚拟主机

1、虚拟主机配置文件

未分类

2、创建所需的目录

mkdir /var/www/wordpress

三.在虚拟主机主目录/var/www/wordpress下新建index.php文件

<?php
        phpinfo();
 ?>

四、启动httpd服务

systemctl start httpd

五、测试

未分类

六、解压 wordpress 4.7并把解压的wordpress复制到/var/www/wordpress

未分类

七、通过浏览器访问wordpress

主意:

注意:配置DNS服务器解析www.test.com 为192.168.23.144 或者 修改windows 下的C:WindowsSysteme32driversetchosts文件
192.168.23.144 www.test.com

未分类

未分类

八、修改wordpress 配置文件复制cp wp-config-sample.php模板文件为 wp-config.php,然后编辑

vim /var/www/wordpress/wordpress/wp-config.php

未分类

未分类

未分类

上一篇 vim shell 练习作业题

WordPress最大上传文件大小限制修改

在为有的客户搭建 WordPress 网站时,有时会遇到因为所在的服务器限制了上传文件大小而无法上传较大的附件,WordPress的媒体文件上传可以看到,大多数都是2MB或者8MB。如果是图片的话可能会还够用,但是如果是音频和视频文件就不一定够用了,今天要分享的方法就是增大文件上传限制的大小。不过如果你的主机商有特别严格的限制,本文的方法就不确定可以实现了。一般的主机商都可以实现。

未分类

方法一:

在functions.php中添加如下代码,这样上传限制就是64M

@ini_set( 'upload_max_size' , '64M' );
@ini_set( 'post_max_size', '64M');
@ini_set( 'max_execution_time', '300' );

方法二:

新建一个php.ini文件,在你的主机空间的根目录新建一个php.ini文件,里面使用如下代码。

upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300

方法三:

在网站根目录的 .htaccess 文件中添加如下代码。

php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300

WordPress忘记密码找回的方法

WordPress的管理员登录密码忘记了是经常有的事情就归纳总结了四种找回Wordpress登录密码的方式。

一、最简单的找回Wordpress密码:后台用邮件直接找回

1、忘记了Wordpress登录密码,直接使用Wordpress登录后台的“找回密码”,输入你的管理员邮箱,就会收到重置密码的邮件了,点击重置链接,设置新的密码即可。

2、不过,使用后台直接找回密码有两个前提:一是你当初安装Wordpress时填写的是自己的邮箱,二是你的主机可以发送重置密码的邮件,二者缺一,则会导致找回密码失败。

未分类

二、最直接的重置Wordpress密码:PhpMyAdmin修改MD5

1、进入到主机的PhpMyAdmin管理界面

2、进入到PhpMyAdmin后,点击wp_users这个表。

3、再点击修改用户参数。(注意:user_login是登录名,默认的是admin,如果你这之前改过用户名,则显示的是其它的)。

4、在这里将user_pass值改成:5d41402abc4b2a76b9719d911017c592,执行,保存。这里是密码是MD5加密后的数值,可以在网上搜索MD5加密后填入。这里的数据为hello。

5、完成后,你就可以使用密码:hello 来登录你的Wordpress了,登录到Wordpress后台后要记得马上修改密码。

三、最快捷的修改Wordpress密码:执行SQL命令

1、进入到PhpMyAdmin的SQL执行命令页面,执行以下命令:

update wp_users set user_pass=md5("123456") where user_login='admin';

2、123456是你的Wordpress新密码,admin是管理员账号。执行完了命令后,你就可以用新的密码来登录Wordpress了。

四、最方便的设置Wordpress新密码:用PHP文件重置密码

这是要下载一个php文件上传到博客主目录,然后打开。根据要求填写就好!

未分类

下载地址:
http://pan.baidu.com/s/1pL7HalX

ESXi ubuntu无需重启动态增加硬盘

ESXi Ubuntu动态增加硬盘无需重启

通过增加新的磁盘来扩充根分区而不用重启系统:

第一步是打开您的虚拟机客户端的设置页面,点击 ‘增加’ 按纽,然后继续下一步操作。

未分类

选择新磁盘所需要的配置信息,如下图所示的,选择新磁盘的大小和它的类型。

未分类

然后进入服务端重复如下的命令来扫描您的磁盘设备,以使新磁盘在系统中可见。

for i in `ls /sys/class/scsi_host/*/scan`;do echo "- - -" > $i;done

列出您的 SCSI 设备的名称并设置值:

for i in `ls /sys/class/scsi_device/*/device/rescan`;do echo 1 > $i;done

fdisk -l

未分类

一旦新增的磁盘可见,就可以运行下面的命令来创建新的分区;

fdisk /dev/sdb --->n-->1-->2048-->p-->w
mkfs -t ext4 /dev/sdb
mkdir /data
mount -t ext4 /dev/sdb /data(挂载)

得到到/dev/sdb这个分区的UUID使用命令:blkid /dev/sdb

cat << EOF >> /etc/fstab
UUID="f7dbec85-ec1e-4291-bf91-73587dc81855"/data ext4 defaults 0 0
EOF