总是错误,mysql实战难点的拍卖

mysql实战难题的管理

#clients
[client]
#password    = your_password
port        = 3306
socket        = /var/run/mysql/mysql.sock
#default-character-set=utf8

总是错误:E中华VRO奥迪Q7 2000 (HY000): Can’t connect to local MySQL server
through socket ‘/var/lib/mysql/mysql.sock’ (2)

mysql数据库在设置后或许会并发时差难题,即timestamp保存的岁月与近年来岁月相差17个小时,那个时候须求修改mysql的配置文件,具体如下:

 

# Here follows entries for some specific programs

化解:作者的是遗失了my-default.cnf 文件

$ cd /etc

笔录专门的学问中采纳mysql的疑难杂症及化解。

# The MySQL server
[mysqld]
max_connections=500
default-character-set=utf8
#skip-character-set-client-handshake
port        = 3306
socket        = /var/run/mysql/mysql.sock
skip-locking
key_buffer = 16M
max_allowed_packet = 20M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log-slow-queries=/var/log/slowquery.log
long_query_time=1
wait_timeout = 120
max_connections = 200
max_user_connections = 100

新建my-default.cnf,增添一下剧情:

$ sudo vim my.cnf

   www.2cto.com  

# Don’t listen on a TCP/IP port at all. This can be a security
enhancement,
# if all processes that need to connect to mysqld run on the same
host.
# All interaction with mysqld must be made via Unix sockets or named
pipes.
# Note that using this option without enabling named pipes on Windows
# (via the “enable-named-pipe” option) will render mysqld useless!
#
#skip-networking

# Example MySQL config file for medium systems. 

粘贴如下一些,保存后重启mysql服务,恢复生机平常

1 pipe broken or connection broken

# Replication Master Server (default)
# binary logging is required for replication
log-bin
expire_logs_days=7
log-error
binlog-ignore-db=mysql
binlog-ignore-db=test

(***文本):

        使用pol的mysql
client端的总是莫名断开,一般都以由server端主动断开连接引发,必要查一下连接池中的maxIdle与mysql的wait_timeout,前者一定要小,不然connection会被server主动断开。

# required unique id between 1 and 2^32 – 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id    = 1

# This is for a system with little memory (32M – 64M) where MySQL
plays 

# Example MySQL config file for medium systems. 

 

# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose
between
# two methods :
#

# an important part, or systems up to 128M where MySQL is used together
with 

2 域名下的slave机的负载均衡

# 1) Use the CHANGE MASTER TO command (fully described in our manual)

#    the syntax is:
#
#    CHANGE MASTER TO MASTER_HOST=<host>,
MASTER_PORT=<port>,
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
#    where you replace <host>, <user>, <password> by
quoted strings and
#    <port> by the master’s port number (3306 by default).
#
#    Example:
#
#    CHANGE MASTER TO MASTER_HOST=’125.564.12.1′, MASTER_PORT=3306,
#    MASTER_USER=’joe’, MASTER_PASSWORD=’secret’;
#
# OR
#
# 2) Set the variables below. However, in case you choose this method,
then
#    start replication for the first time (even unsuccessfully, for
example
#    if you mistyped the password in master-password and the slave
fails to
#    connect), the slave will create a master.info file, and any
later
#    change in this file to the variables’ values below will be ignored
and
#    overridden by the content of the master.info file, unless you
shutdown
#    the slave server, delete master.info and restart the slaver
server.
#    For that reason, you may want to leave the lines below untouched
#    (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 – 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
#
# The replication master for this slave – required
#master-host     =   <hostname>
#
# The username the slave will use for authentication when connecting
# to the master – required
#master-user     =   <username>
#
# The password the slave will authenticate with when connecting to
# the master – required
#master-password =   <password>
#
# The port the master is listening on.
# optional – defaults to 3306
#master-port     =  <port>
#
# binary logging – not required for slaves, but recommended
#log-bin

# Point the following paths to different dedicated disks
#tmpdir        = /tmp/
#log-update     = /path-to-dedicated-directory/hostname

# Uncomment the following if you are using BDB tables
#bdb_cache_size = 4M
#bdb_max_lock = 10000

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /var/lib/mysql/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql/
#innodb_log_arch_dir = /var/lib/mysql/
# You can set .._buffer_pool_size up to 50 – 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[isamchk]
key_buffer = 20M
sort_总是错误,mysql实战难点的拍卖。buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

# other programs (such as a web server) 

# This is for a system with little memory (32M – 64M) where MySQL
plays 

当下免费的三番五次池如c3p0、dbcp的线程池使用方法都以lifo,要是你刚刚用域名来保管三个ip下的mysql
slave实例,你也许会意识各样slave的连天、负载很不平衡。

# an important part, or systems up to 128M where MySQL is used together
with 

 

# MySQL programs look for option files in a set of 

# other programs (such as a web server) 

化解:1)小心调度idleTime、min/max
poolsize;2)扩张一层proxy,来代劳对那个线程池的connection管理。不过如此要求精晓各样connection的ip,driver未有,有三个措施通过sql来获得:select
@@hostname 查到server的host,那样协作lookup
server,ip也得到手了;其余也得以一直依照host来治本,不用ip,正是不太直观;3)自个儿写一个driver,不过须求时日和认证的经过~~~

# locations which depend on the deployment platform. 

 

# You can copy this option file to one of those 

# MySQL programs look for option files in a set of 

3 对于唯一键删除+insert的复合操作(unbind + bind)

# locations. For information about these locations, see: 

# locations which depend on the deployment platform. 

科学普及于:业务绑定期,借使已经bind了此外二个唯一键,须求先unbind,然后再bind。那是replace
into的一展身手的地点。

#  

# You can copy this option file to one of those 

 

# locations. For information about these locations, see: 

有几点要专注:1)假如有多少个唯一键(包蕴primary
key),假诺新插入的row中与多个唯一键一样,mysql会先删除多条,然后插入这一条;2)replace
into无法获得在此以前这行的原始值,比方replace into xxx on duplicate key
update set a=a+1 相当于: set a=default(a)+1;3)table中务须求有unique
key,不然一定于insert;

# In this file, you can use all long options that a program supports. 

#  

mysql的处清理计算法:1)try insert;2)if false,del with uniqu/primary
key;3)try insert again

# If you want to know which options a program supports, run the
program 

 

# with the “–help” option. 

# In this file, you can use all long options that a program supports. 

记录工作中利用mysql的疑难杂症及减轻。 www.2cto.com 1 pipe broken or
connection broken 使用pol的mysql client端的延续莫名断开,一…

# The following options will be passed to all MySQL clients 

# If you want to know which options a program supports, run the
program 

[client]

# with the “–help” option. 

default-character-set=utf8

# The following options will be passed to all MySQL clients 

#password = your_password 

[client]

port = 3306 

default-character-set=utf8

socket = /tmp/mysql.sock 

#password = your_password 

# Here follows entries for some specific programs 

port = 3306 

# The MySQL server 

socket = /tmp/mysql.sock 

[mysqld]

# Here follows entries for some specific programs 

character-set-server=utf8

# The MySQL server 

init_connect=’SET NAMES utf8

[mysqld]

port = 3306 

port = 3306 

socket = /tmp/mysql.sock 

socket = /tmp/mysql.sock 

skip-external-locking 

skip-external-locking 

key_buffer_size = 16M 

key_buffer_size = 16M 

max_allowed_packet = 1M 

max_allowed_packet = 1M 

table_open_cache = 64 

table_open_cache = 64 

sort_buffer_size = 512K 

sort_buffer_size = 512K 

net_buffer_length = 8K 

net_buffer_length = 8K 

read_buffer_size = 256K 

read_buffer_size = 256K 

read_rnd_buffer_size = 512K 

read_rnd_buffer_size = 512K 

myisam_sort_buffer_size = 8M 

myisam_sort_buffer_size = 8M 

character-set-server=utf8 

character-set-server=utf8 

init_connect=’SET NAMES utf8′ 

init_connect=’SET NAMES utf8′ 

# Don’t listen on a TCP/IP port at all. This can be a security
enhancement, 

default-time_zone = ‘+8:00’

# if all processes that need to connect to mysqld run on the same
host. 

# Don’t listen on a TCP/IP port at all. This can be a security
enhancement, 

# All interaction with mysqld must be made via Unix sockets or named
pipes. 

# if all processes that need to connect to mysqld run on the same
host. 

# Note that using this option without enabling named pipes on Windows 

# All interaction with mysqld must be made via Unix sockets or named
pipes. 

# (via the “enable-named-pipe” option) will render mysqld useless! 

# Note that using this option without enabling named pipes on Windows 

# (via the “enable-named-pipe” option) will render mysqld useless! 

#skip-networking

# Replication Master Server (default) 

#skip-networking

# binary logging is required for replication 

# Replication Master Server (default) 

log-bin=mysql-bin

# binary logging is required for replication 

# binary logging format – mixed recommended 

log-bin=mysql-bin

binlog_format=mixed

# binary logging format – mixed recommended 

# required unique id between 1 and 2^32 – 1 

binlog_format=mixed

# defaults to 1 if master-host is not set 

# required unique id between 1 and 2^32 – 1 

# but will not function as a master if omitted 

# defaults to 1 if master-host is not set 

server-id = 1

# but will not function as a master if omitted 

# Replication Slave (comment out master section to use this) 

server-id = 1

# Replication Slave (comment out master section to use this) 

# To configure this host as a replication slave, you can choose
between 

# two methods : 

# To configure this host as a replication slave, you can choose
between 

# two methods : 

# 1) Use the CHANGE MASTER TO command (fully described in our manual)
– 

# the syntax is: 

# 1) Use the CHANGE MASTER TO command (fully described in our manual)
– 

# the syntax is: 

# CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=, 

# MASTER_USER=, MASTER_PASSWORD= ; 

# CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=, 

# MASTER_USER=, MASTER_PASSWORD= ; 

# where you replace , , by quoted strings and 

# by the master’s port number (3306 by default). 

# where you replace , , by quoted strings and 

# by the master’s port number (3306 by default). 

# Example: 

# Example: 

# CHANGE MASTER TO MASTER_HOST=’125.564.12.1′, MASTER_PORT=3306, 

# MASTER_USER=’joe’, MASTER_PASSWORD=’secret’; 

# CHANGE MASTER TO MASTER_HOST=’125.564.12.1′, MASTER_PORT=3306, 

# MASTER_USER=’joe’, MASTER_PASSWORD=’secret’; 

# OR 

# OR 

# 2) Set the variables below. However, in case you choose this method,
then 

# start replication for the first time (even unsuccessfully, for
example 

# 2) Set the variables below. However, in case you choose this method,
then 

# if you mistyped the password in master-password and the slave fails
to 

# start replication for the first time (even unsuccessfully, for
example 

# connect), the slave will create a master.info file, and any later 

# if you mistyped the password in master-password and the slave fails
to 

# change in this file to the variables’ values below will be ignored
and 

# connect), the slave will create a master.info file, and any later 

# overridden by the content of the master.info file, unless you
shutdown 

# change in this file to the variables’ values below will be ignored
and 

# the slave server, delete master.info and restart the slaver server. 

# overridden by the content of the master.info file, unless you
shutdown 

# For that reason, you may want to leave the lines below untouched 

# the slave server, delete master.info and restart the slaver server. 

# (commented) and instead use CHANGE MASTER TO (see above) 

# For that reason, you may want to leave the lines below untouched 

# (commented) and instead use CHANGE MASTER TO (see above) 

# required unique id between 2 and 2^32 – 1 

# (and different from the master) 

# required unique id between 2 and 2^32 – 1 

# defaults to 2 if master-host is set 

# (and different from the master) 

# but will not function as a slave if omitted 

# defaults to 2 if master-host is set 

#server-id = 2 

# but will not function as a slave if omitted 

#server-id = 2 

# The replication master for this slave – required 

#master-host =  

# The replication master for this slave – required 

#master-host =  

# The username the slave will use for authentication when connecting 

# to the master – required 

# The username the slave will use for authentication when connecting 

#master-user =  

# to the master – required 

#master-user =  

# The password the slave will authenticate with when connecting to 

# the master – required 

# The password the slave will authenticate with when connecting to 

#master-password =  

# the master – required 

#master-password =  

# The port the master is listening on. 

# optional – defaults to 3306 

# The port the master is listening on. 

#master-port =  

# optional – defaults to 3306 

#master-port =  

# binary logging – not required for slaves, but recommended 

#log-bin=mysql-bin

# binary logging – not required for slaves, but recommended 

# Uncomment the following if you are using InnoDB tables 

#log-bin=mysql-bin

#innodb_data_home_dir = /usr/local/mysql/data 

# Uncomment the following if you are using InnoDB tables 

#innodb_data_file_path = ibdata1:10M:autoextend 

#innodb_data_home_dir = /usr/local/mysql/data 

#innodb_log_group_home_dir = /usr/local/mysql/data 

#innodb_data_file_path = ibdata1:10M:autoextend 

# You can set .._buffer_pool_size up to 50 – 80 % 

#innodb_log_group_home_dir = /usr/local/mysql/data 

# of RAM but beware of setting memory usage too high 

# You can set .._buffer_pool_size up to 50 – 80 % 

#innodb_buffer_pool_size = 16M 

# of RAM but beware of setting memory usage too high 

#innodb_additional_mem_pool_size = 2M 

#innodb_buffer_pool_size = 16M 

# Set .._log_file_size to 25 % of buffer pool size 

#innodb_additional_mem_pool_size = 2M 

#innodb_log_file_size = 5M 

# Set .._log_file_size to 25 % of buffer pool size 

#innodb_log_buffer_size = 8M 

#innodb_log_file_size = 5M 

#innodb_flush_log_at_trx_commit = 1 

#innodb_log_buffer_size = 8M 

#innodb_lock_wait_timeout = 50

#innodb_flush_log_at_997755.com澳门葡京,trx_commit = 1 

[mysqldump] 

#innodb_lock_wait_timeout = 50

quick 

[mysqldump] 

max_allowed_packet = 16M

quick 

[mysql] 

max_allowed_packet = 16M

no-auto-rehash 

[mysql] 

# Remove the next comment character if you are not familiar with SQL 

no-auto-rehash 

#safe-updates 

# Remove the next comment character if you are not familiar with SQL 

default-character-set=utf8

#safe-updates 

[myisamchk] 

default-character-set=utf8

key_buffer_size = 20M 

[myisamchk] 

sort_buffer_size = 20M 

key_buffer_size = 20M 

read_buffer = 2M 

sort_buffer_size = 20M 

write_buffer = 2M

read_buffer = 2M 

[mysqlhotcopy] 

write_buffer = 2M

interactive-timeout

[mysqlhotcopy] 

然后:cp /usr/local/mysql/support-files/my-default.cnf
/usr/local/mysql/my.cnf

interactive-timeout

ln -s /usr/local/mysql/my.cnf /etc/my.cnf #增添到/etc目录的软连接

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*
*
Website