【原】MySQL 5.7新版本遇到的问题汇总

MySQL 5.7发布以后,近期也是第一次用,发现相比较之前的版本有很多改变,搞得之前很多做法已经并不适用了,在此记录一些遇到的问题,提醒一下朋友们。

一、安装MySQL后,默认用户root的密码不再“未设置”,不能使用:

#mysql -u root

这条命令登陆,必须加入-p参数,输入默认密码。

二、默认密码在mysqld.log文件中,可以使用命令:

# grep ‘temporary password’ /var/log/mysqld.log

查询默认密码,如果执行失败找不到mysqld.log文件,可使用:

find / -name ‘mysqld.log’

进行查找mysqld.log文件位置。

三、使用默认密码登陆以后,不能进行其他操作,需要更改默认密码方可继续操作,更改密码命令:

SQL>ALTER USER root@localhost IDENTIFIED BY ‘new_password’

注意:新密码必须包含大写小字母、数字、特殊字符,并且最少字符长度为8

附:

1、在MySQL 5.7之前的版本,在mysql.user表中,会存在`password`列;现在`password`列被更改为同表中的`authentication_string`列。

2、在mysql.user表中添加了`account_locked`列,创建了锁定用户的功能。

==========================

英文实在是我的硬伤,努力的途中。。。只看了一些与自己直接相关联的,话说从5.7.8开始,原生支持JSON,以后不用再以string方式存储JSON了,而是使用内部二进制存储,这个我还是比较关心的,,具体使用如果出什么问题再补充吧。

最后附上官方文档链接:

http://dev.mysql.com/doc/refman/5.7/en/mysql-nutshell.html

【转】linux下防DDOS工具

DDoS deflate是一款免费的用来防御和减轻DDoS攻击的脚本。它通过netstat监测跟踪创建大量网络连接的IP地址,在检测到某个结点超过预设的限 制时,该程序会通过APF或IPTABLES禁止或阻挡这些IP。.

DDoS deflate官方网站:http://deflate.medialayer.com/

如何确认是否受到DDOS攻击?

执行:

netstat -ntu | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n

执行后,将会显示服务器上所有的每个IP多少个连接数。每个IP几个、十几个或几十个连接数都还算比较正常,如果像上面成百上千肯定就不正常了

1、安装DDoS deflate

wget http://www.inetbase.com/scripts/ddos/install.sh //下载DDoS deflate

chmod 0700 install.sh //添加权限

./install.sh //执行

2、配置DDoS deflate

下面是DDoS deflate的默认配置位于/usr/local/ddos/ddos.conf ,内容如下:

##### Paths of the script and other files

PROGDIR=”/usr/local/ddos”

PROG=”/usr/local/ddos/ddos.sh”

IGNORE_IP_LIST=”/usr/local/ddos/ignore.ip.list” //IP地址白名单

CRON=”/etc/cron.d/ddos.cron” //定时执行程序

APF=”/etc/apf/apf”

IPT=”/sbin/iptables”

##### frequency in minutes for running the script

##### Caution: Every time this setting is changed, run the script with –cron

##### option so that the new frequency takes effect

FREQ=1 //检查时间间隔,默认1分钟

##### How many connections define a bad IP? Indicate that below.

NO_OF_CONNECTIONS=150 //最大连接数,超过这个数IP就会被屏蔽,一般默认即可

##### APF_BAN=1 (Make sure your APF version is atleast 0.96)

##### APF_BAN=0 (Uses iptables for banning ips instead of APF)

APF_BAN=1 //使用APF还是iptables。推荐使用iptables,将APF_BAN的值改为0即可。

##### KILL=0 (Bad IPs are’nt banned, good for interactive execution of script)

##### KILL=1 (Recommended setting)

KILL=1 //是否屏蔽IP,默认即可

##### An email is sent to the following address when an IP is banned.

##### Blank would suppress sending of mails

EMAIL_TO=”root” //当IP被屏蔽时给指定邮箱发送邮件,推荐使用,换成自己的邮箱即可

##### Number of seconds the banned ip should remain in blacklist.

BAN_PERIOD=600 //禁用IP时间,默认600秒,可根据情况调整

如果/usr/local/ddos/ddos.sh 统计不正确,可能是启用ipv6的缘故

# vi /usr/local/ddos/ddos.sh

117行的内容是这样的netstat -ntu | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -nr > $BAD_IP_LIST

如果服务器启用了IPv6的话,可能会导致统计的结果不准确,修改这一行可以修正这个问题。

需要修改成这样

netstat -ntu|awk ‘{print $5}’|cut -d : -f1|sed -n ‘/[0-9]/p’|sort|uniq -c|sort -nr& > $BAD_IP_LIST

或者

netstat -ntu | grep ‘:’ | awk ‘{print $5}’ | sed ‘s/::ffff://’ | cut -d: -f1 | sort | uniq -c | sort -nr > $BAD_IP_LIST

转自:http://netsecurity.51cto.com/art/201406/441851.htm

【转】通过squid做CND加速

适用: squid-2.7.stable9和squirm-1.0betaB

用来:将优酷,爱奇艺,乐视tv,搜狐视频,凤凰视频,56等等网站的CDN URL重写成内部URL,减少存储占用,增加命中率。

squirm安装:

wget http://squirm.foote.com.au/squirm−1.0betaB.tar.gz
mv squirm−1.0betaB.tar.gz /usr/local/src
cd /usr/local/src/
tar xvf squirm−1.0betaB.tar.gz
cd squirm−1.0betaB
cd regex
./configure
make clean
make
cp −p regex.o regex.h ../
cd ../
make
make install 

squirm.local文件内容:

[root<a href="http://home.51cto.com/index.php?s=/space/159108" target="_blank">@cache</a> ~]# more /usr/local/squirm/etc/squirm.local
# squirm.local.dist
#
# list your client's addresses here.
#
# i.e. the addresses for machines that do 'GET requests',
# but don't include any Squid neighbours

127.0.0
10.1.55
10.1.56

squirm.patterns文件内容:

[root@webcache ~]# more /usr/local/squirm/etc/squirm.patterns
# squirm.patterns.dist
#
# The ordering of lines is this file is critical
# Please see http://www.senet.com.au/squirm/ for examples
## Lines have the form:
#       regex|regexi pattern replacement [[^]accelerator_string[$]]
# or
#       abort filename_extension
#
#
# Examples of valid lines:
#
# regex  ^.*/n32e301\.exe$ http://www.mydomain/path_to/n32e301.exe
# regexi ^.*/n32e301\.exe$ http://www.mydomain/path_to/n32e301.exe
# regex  ^.*/n32e301\.exe$ http://www.mydomain/path_to/n32e301.exe n32e301.exe$
# abort .gif
# abort .html
#regex ^http:\/\/f\.youku\.com\/player\/getFlvPath http://video−srv\.youku\.com.SQUIDINTERNAL\/
#regex http:\/\/[0−9]{1,3}\.[0−9]{1,3}\.[0−9]{1,3}\.[0−9]{1,3}\/youku\/.*?/(.*?)\.flv$ http://v.youku.com.squid/$1.flv
#regex http://[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}/youku/.*/(.*−.*−.*−.*−.*) http://www.youku.com/$1

# tudou video cdn has change to youku,but keep it!
regex http://[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}[^&]*/f4v/.*id=tudou.itemid\=([0−9]*).* http://www.tudou.com.SQUIDTUDOUA/\1
regex http://[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}[^&]*/flv/.*id=tudou.itemid\=([0−9]*).* http://www.tudou.com.SQUIDTUDOUB/\1

#site:sohu tv status:OK date:20141024
regex http://[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}/sohu/[0−9]/[0−9]*/[0−9]*/(.*)\.mp4\?key=.* http://tv.sohu.com.SQUIDSOHUTV/\1.mp4

#site:iqiyi status:OK date:201403120956
regex http://[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}/videos/v/.*/(.*\.f4v)?  http://www.iqiyi.com.SQUIDIQIYI/\1

#site:youku part−tudou status:OK date:201403120956
regex http://[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}/youku/.*/(.*−.*−.*−.*−[^?]*)(.*) http://www.youku.com.SQUIDYOUKU/\1

#site:letv status:OK date:201403122047
regex http://[0−9]{1,3}\.[0−9]{1,3}\.[0−9]{1,3}\.[0−9]{1,3}/[0−9]*/[0−9]*/[0−9]*/letv−uts/[0−9]*/(.*_mp4)/(.*)\.ts\? http://www.letv.com.SQUIDLETVA/\1/\2.mp4
regex http://[0−9]{1,3}\.[0−9]{1,3}\.[0−9]{1,3}\.[0−9]{1,3}/[0−9]*/[0−9]*/[0−9]*/letv−uts/(.*)\.letv\?.*\&video_type=(…)\&.*\&rstart=(.*)\&rend=(.*)  http://www.letv.com.SQUIDLETVB/\1−\3−\4.\2

#site:v.qq.com status:OK date:201403122102
regex http://[0−9]{1,3}\.[0−9]{1,3}\.[0−9]{1,3}\.[0−9]{1,3}/[0−9]*/.*\.qq\.com/.*/[0−9]*/[0−9]*/(.*)\.mp4\? http://v.qq.com.SQUIDQQ/\1.mp4

#site:v.ifeng.com status:OK date:201403130838
regex http://[0−9]{1,3}\.[0−9]{1,3}\.[0−9]{1,3}\.[0−9]{1,3}/data[0−9]*/documentary/[0−9][0−9][0−9][0−9]/[0−9][0−9]/[0−9][0−9]/(.*)\.mp4 http://v.ifeng.com.SQ
UIDIFENG/\1.mp4

#site:56 status:OK date:201403130846
regex http://[0−9]{1,3}\.[0−9]{1,3}\.[0−9]{1,3}\.[0−9]{1,3}/.*\.56\.com/flvdownload/[0−9]*/[0−9]*/(.*)\.flv\?.* http://www.56.com.SQUID56/\1.flv

squid.conf相关配置:

#rewrite store url youku tudou souhu iqiyi

acl store_url url_regex −i ^http:\/\/[0−9]{1,3}\.[0−9]{1,3}\.[0−9]{1,3}\.[0−9]{1,3}\/.*(\.flv|\.m4v\?|\.f4v\?|\.mp4\?|\.ts\?|\.letv\?)
acl store_url_no_domain urlpath_regex −i ^\/(.*\/.*\.flv$)

storeurl_access allow store_url
storeurl_access allow store_url_no_domain
storeurl_access deny all

storeurl_rewrite_program /usr/local/squirm/bin/squirm
storeurl_rewrite_children 5

转自:http://bbs.51cto.com/thread-1098719-1.html