- 論壇徽章:
- 0
|
- [root@testbox-04 mysql]# cat /etc/issue
- CentOS release 5.2 (Final)
- Kernel \r on an \m
- [root@testbox-04 mysql]# uname -r
- 2.6.18-92.1.22.el5
- [root@testbox-04 mysql]# rpm -qa | grep mysql
- mysql-5.0.45-7.el5
- mysql-server-5.0.45-7.el5
- mysql-5.0.45-7.el5
- php-mysql-5.1.6-20.el5_2.1
- mysql-devel-5.0.45-7.el5
- mysql-devel-5.0.45-7.el5
- mysql-test-5.0.45-7.el5
- mysql-bench-5.0.45-7.el5
- [root@testbox-04 mysql]# sestatus -bv | head -n1
- SELinux status: enabled
- [root@testbox-04 mysql]# sestatus -bv | grep mysql
- allow_user_mysql_connect off
- mysqld_disable_trans on
復(fù)制代碼
my.cnf配置:
為了節(jié)省空間,打擾次序排序的
- [root@testbox-04 mysql]# grep -v "#" /etc/my.cnf | sort | uniq
- back_log = 50
- bind-address = 192.168.12.81
- binlog_cache_size = 1M
- bulk_insert_buffer_size = 64M
- [client]
- default_table_type = INNODB
- ft_min_word_len = 4
- innodb_additional_mem_pool_size = 16M
- innodb_buffer_pool_size = 2G
- innodb_data_file_path = ibdata1:500M:autoextend
- innodb_data_home_dir = /var/lib/mysql/ibdata
- innodb_file_io_threads = 4
- innodb_flush_log_at_trx_commit = 1
- innodb_lock_wait_timeout = 120
- innodb_log_buffer_size = 32M
- innodb_log_files_in_group = 3
- innodb_log_file_size = 500M
- innodb_log_group_home_dir=/var/lib/mysql/iblogs
- innodb_max_dirty_pages_pct = 90
- innodb_thread_concurrency = 16
- interactive-timeout
- [isamchk]
- join_buffer_size = 8M
- key_buffer = 512M
- key_buffer_size = 32M
- log_long_format
- max_allowed_packet = 16M
- max_connect_errors = 10
- max_connections = 100
- max_heap_table_size = 64M
- [myisamchk]
- myisam_max_extra_sort_file_size = 10G
- myisam_max_sort_file_size = 10G
- myisam_recover
- myisam_repair_threads = 1
- myisam_sort_buffer_size = 128M
- [mysql]
- [mysqld]
- [mysqld_safe]
- [mysqldump]
- [mysqlhotcopy]
- no-auto-rehash
- open-files-limit = 8192
- port = 3306
- query_cache_limit = 2M
- query_cache_size = 64M
- quick
- read_buffer = 8M
- read_buffer_size = 2M
- read_rnd_buffer_size = 16M
- server-id = 1
- socket = /tmp/mysql.sock
- sort_buffer_size = 512M
- sort_buffer_size = 8M
- table_cache = 2048
- thread_cache_size = 8
- thread_concurrency = 8
- thread_stack = 192K
- tmp_table_size = 64M
- transaction_isolation = REPEATABLE-READ
- write_buffer = 8M
復(fù)制代碼
錯誤日志1
- [root@testbox-04 ~]# tail -f /var/log/mysqld.log
- InnoDB: in this failed attempt. InnoDB only wrote those files full of
- InnoDB: zeros, but did not yet use them in any way. But be careful: do not
- InnoDB: remove old data files which contain your precious data!
- 090210 23:25:42 [ERROR] Default storage engine (InnoDB) is not available
- 090210 23:25:42 [ERROR] Aborting
- 090210 23:25:42 [Note] /usr/libexec/mysqld: Shutdown complete
- 090210 23:25:42 mysqld ended
復(fù)制代碼
解決錯誤1:
my.cnf 里面打開
innodb_data_home_dir = /var/lib/mysql/ibdata
錯誤日志2:
- 090210 23:26:59 mysqld started
- InnoDB: Error: auto-extending data file ./ibdata1 is of a different size
- InnoDB: 640 pages (rounded down to MB) than specified in the .cnf file:
- InnoDB: initial 32000 pages, max 0 (relevant if non-zero) pages!
- InnoDB: Could not open or create data files.
- InnoDB: If you tried to add new data files, and it failed here,
- InnoDB: you should now edit innodb_data_file_path in my.cnf back
- InnoDB: to what it was, and remove the new ibdata files InnoDB created
- InnoDB: in this failed attempt. InnoDB only wrote those files full of
- InnoDB: zeros, but did not yet use them in any way. But be careful: do not
- InnoDB: remove old data files which contain your precious data!
- 090210 23:27:00 [ERROR] Can't start server : Bind on unix socket: Permission denied
- 090210 23:27:00 [ERROR] Do you already have another mysqld server running on socket: /tmp/mysql.sock ?
- 090210 23:27:00 [ERROR] Aborting
復(fù)制代碼
解決錯誤日志2
sealert -a /var/log/audit/audit.log
查看到selinux 阻止 mysqld 讀取mysql.sock 文件,
Detailed Description:
SELinux has denied mysqld access to potentially mislabeled file(s) (mysql.sock).
This means that SELinux will not allow mysqld to use these files. It is common
for users to edit files in their home directory or tmp directories and then move
(mv) them to system directories. The problem is that the files end up with the
wrong file context which confined applications are not allowed to access.
Allowing Access:
If you want mysqld to access this files, you need to relabel them using
restorecon -v 'mysql.sock'. You might want to relabel the entire directory using
restorecon -R -v '<Unknown>'.
由于mysql無法啟動,無法產(chǎn)生mysql.sock
所以,暫時取消對mysqld監(jiān)控
setsebool mysqld_disable_trans 1
錯誤日志3
- 090210 23:29:42 mysqld started
- 090210 23:29:42 InnoDB: Operating system error number 2 in a file operation.
- InnoDB: The error means the system cannot find the path specified.
- InnoDB: If you are installing InnoDB, remember that you must create
- InnoDB: directories yourself, InnoDB does not create them.
- InnoDB: File name /var/lib/mysql/ibdata/ibdata1
- InnoDB: File operation call: 'create'.
- InnoDB: Cannot continue operation.
- 090210 23:29:42 mysqld ended
復(fù)制代碼
解決錯誤3:
rm -rf /var/lib/mysql/ibdata/*
rm -rf /var/lib/mysql/iblogs/*
錯誤日志4:
- 090210 23:52:21 mysqld started
- 090210 23:52:22 InnoDB: Started; log sequence number 0 43656
- 090210 23:52:23 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
- 090210 23:52:23 mysqld ended
復(fù)制代碼
解決方法4:
[root@testbox-04 /]# /usr/bin/mysql_install_db
Installing MySQL system tables...
OK
Filling help tables...
OK
錯誤日志5:
- 090211 00:00:34 mysqld started
- 090211 0:00:35 InnoDB: Started; log sequence number 0 43656
- /usr/libexec/mysqld: File './mysql-bin.000008' not found (Errcode: 13)
- 090211 0:00:35 [ERROR] Failed to open log (file './mysql-bin.000008', errno 13)
- 090211 0:00:35 [ERROR] Could not open log file
- 090211 0:00:35 [ERROR] Can't init tc log
- 090211 0:00:35 [ERROR] Aborting
復(fù)制代碼
解決錯誤5:
感覺到是讀取bin-log錯誤,為什么開啟會讀bin-log
而且,我的/var/lib/mysql下 mysql-bin.000008文件是存在的
先注釋掉my.cnf log-bin
錯誤日志6:
- 090211 00:23:19 mysqld started
- /usr/libexec/mysqld: File '/var/lib/mysql/testbox-04-slow.log' not found (Errcode: 13)
- 090211 0:23:19 [ERROR] Could not use /var/lib/mysql/testbox-04-slow.log for logging (error 13). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
- 090211 0:23:20 InnoDB: Started; log sequence number 0 43656
復(fù)制代碼
解決錯誤6:
#log_slow_queries
#long_query_time = 2
以上2行增加注釋;
錯誤日志7:
- 090211 00:02:51 mysqld started
- 090211 0:02:52 InnoDB: Started; log sequence number 0 43656
- 090211 0:02:52 [ERROR] /usr/libexec/mysqld: Can't find file: './mysql/host.frm' (errno: 13)
- 090211 0:02:52 [ERROR] /usr/libexec/mysqld: Can't find file: './mysql/host.frm' (errno: 13)
- 090211 0:02:52 [ERROR] Fatal error: Can't open and lock privilege tables: Can't find file: './mysql/host.frm' (errno: 13)
- 090211 00:02:52 mysqld ended
復(fù)制代碼
解決錯誤方法6:
/usr/bin/mysql_install_db --user=mysql
哈哈:起來了
[root@testbox-04 mysql]# service mysqld start
Starting MySQL: [ OK ]
[root@testbox-04 mysql]#
上面的前提是注釋掉了selinux對mysql的mysql.sock監(jiān)控
現(xiàn)在把監(jiān)控加進去,在做如下測試。
還是起不來,看這個樣子是selinux嚴格的權(quán)限禁止 原生目錄/var/lib/mysql下的sock文件產(chǎn)生
那更改/etc/my.cnf
- [root@testbox-04 mysql]# grep -v "#" /etc/my.cnf |grep -i sock
- socket = /var/lib/mysql/mysql.sock
- socket = /var/lib/mysql/mysql.sock
- 改到/var/lib/mysql下吧
- 重新加監(jiān)控進去
- [root@testbox-04 mysql]# setsebool mysqld_disable_trans 0
- [root@testbox-04 mysql]# ls -lZ |grep sock
- srwxrwxrwx mysql mysql user_u:object_r:mysqld_var_run_t mysql.sock
- 090211 00:42:48 mysqld started
- 090211 0:42:49 InnoDB: Started; log sequence number 0 43656
- 090211 0:42:49 [Note] /usr/libexec/mysqld: ready for connections.
- Version: '5.0.45' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution
復(fù)制代碼
以上雖然是小問題,可能大家都會遇到到,希望對大家有所幫助! |
|