随笔-46  评论-54  文章-0  trackbacks-0

1、

1cd /data/
2tar -xzf mysql-5.0.37-linux-i686.tar.gz
3cd ./mysql-5.0.37-linux-i686
4cat ./INSTALL-BINARY
 参考以下说明:   
 1shell> groupadd mysql
 2shell> useradd -g mysql mysql
 3shell> cd /usr/local
 4shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf -
 5shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql
 6shell> cd mysql
 7shell> scripts/mysql_install_db --user=mysql
 8shell> chown -R root  .
 9shell> chown -R mysql data
10shell> chgrp -R mysql .
11shell> bin/mysqld_safe --user=mysql &
2、
1vi /etc/rc.local

1su - root -c 'cd /data/mysql-5.0.37-linux-i686/; ./bin/mysqld_safe --user=mysql &'


不懂怎么ln,就直接把30多G的数据库文件拷贝到data目录下,耗费了好多时间。

第二种替代方案,安装mysql到服务,不在/etc/rc.local中启动。

1cp /data/mysql-5.0.37-linux-i686/support-files/mysql.server /etc/init.d/mysql
2vi /etc/init.d/mysql
1basedir=/data/mysql-5.0.37-linux-i686
1chkconfig mysql on

用setup查看一下,然后重启,可以用

1service mysql stop
2service mysql start
测试一下。

2008-06-16 add...
但是不能正常配置/my.cnf,根据support-files/my-innodb-heavy-4G.cnf去掉注释后,逐行查找修改如下:

 1
 2[client]
 3port        = 3306
 4socket        = /tmp/mysql.sock
 5
 6[mysqld]
 7port        = 3306
 8socket        = /tmp/mysql.sock
 9default-character-set=gbk
10default-storage-engine=INNODB
11back_log = 50
12max_connections = 100
13max_connect_errors = 10
14table_cache = 2048
15max_allowed_packet = 16M
16binlog_cache_size = 1M
17max_heap_table_size = 64M
18sort_buffer_size = 8M
19join_buffer_size = 8M
20thread_cache_size = 8
21thread_concurrency = 8
22query_cache_size = 64M
23query_cache_limit = 2M
24ft_min_word_len = 4
25default_table_type = MYISAM
26thread_stack = 192K
27transaction_isolation = REPEATABLE-READ
28tmp_table_size = 64M
29#log-bin=mysql-bin
30#log_slow_queries
31#long_query_time = 2
32#log_long_format
33server-id = 1
34key_buffer_size = 32M
35read_buffer_size = 2M
36read_rnd_buffer_size = 16M
37bulk_insert_buffer_size = 64M
38myisam_sort_buffer_size = 128M
39myisam_max_sort_file_size = 10G
40myisam_max_extra_sort_file_size = 10G
41myisam_repair_threads = 1
42myisam_recover
43skip-bdb
44#innodb_additional_mem_pool_size = 16M
45#innodb_buffer_pool_size = 2G
46#innodb_data_file_path = ibdata1:10M:autoextend
47#innodb_file_io_threads = 4
48#innodb_thread_concurrency = 16
49#innodb_flush_log_at_trx_commit = 1
50#innodb_log_buffer_size = 8M
51#innodb_log_file_size = 256M
52#innodb_log_files_in_group = 3
53#innodb_max_dirty_pages_pct = 90
54#innodb_lock_wait_timeout = 120
55
56[mysqldump]
57quick
58max_allowed_packet = 16M
59
60[mysql]
61no-auto-rehash
62
63[isamchk]
64key_buffer = 512M
65sort_buffer_size = 512M
66read_buffer = 8M
67write_buffer = 8M
68
69[myisamchk]
70key_buffer = 512M
71sort_buffer_size = 512M
72read_buffer = 8M
73write_buffer = 8M
74
75[mysqlhotcopy]
76interactive-timeout
77[mysqld_safe]
78open-files-limit = 8192


这里要注意两个地方,一个就是log配置,一个就是innodb配置。
1、#log-bin=mysql-bin,注释后,不会再出现下面的错误,但不能查询

Starting MySQL/etc/init.d/mysql: line 151: kill: (****) - 没有那个进程
2、注释掉innodb后,就可以正常查询了。

 

 参考:
1、http://www.zftown.com/blog/?action=show&id=228
2
http://www.aslibra.com/blog/index.php?go=category_15
3、http://bbs.chinaunix.net/viewthread.php?tid=16141

2008-8-29 add...

Linux的data挂载点,空间奇怪消失。修改配置文件如下:

 1
 2[client]
 3port        = 3306
 4socket        = /tmp/mysql.sock
 5
 6[mysqld]
 7port        = 3306
 8socket        = /tmp/mysql.sock
 9default-character-set=gbk
10default-storage-engine=INNODB
11back_log = 50
12max_connections = 100
13max_connect_errors = 10
14table_cache = 2048
15max_allowed_packet = 16M
16binlog_cache_size = 1M
17max_heap_table_size = 64M
18sort_buffer_size = 8M
19join_buffer_size = 8M
20thread_cache_size = 8
21thread_concurrency = 8
22query_cache_size = 64M
23query_cache_limit = 2M
24ft_min_word_len = 4
25#default_table_type = MYISAM
26default_table_type = innodb
27thread_stack = 192K
28transaction_isolation = REPEATABLE-READ
29tmp_table_size = 64M
30log-bin=mysql-bin
31log_slow_queries
32long_query_time = 2
33log_long_format
34server-id = 1
35key_buffer_size = 32M
36read_buffer_size = 2M
37read_rnd_buffer_size = 16M
38bulk_insert_buffer_size = 64M
39myisam_sort_buffer_size = 128M
40myisam_max_sort_file_size = 10G
41myisam_max_extra_sort_file_size = 10G
42myisam_repair_threads = 1
43myisam_recover
44skip-bdb
45
46# Data files must be able to hold your data and indexes.
47# Make sure that you have enough free disk space.
48innodb_data_file_path = ibdata1:50M:autoextend
49
50# Set buffer pool size to 50-80% of your computer's memory
51innodb_buffer_pool_size = 2G
52innodb_additional_mem_pool_size = 16M
53
54# Set the log file size to about 25% of the buffer pool size
55
56#innodb_log_file_size = 256M
57#innodb_log_files_in_group = 3
58innodb_flush_log_at_trx_commit = 1
59
60innodb_file_io_threads = 4
61innodb_thread_concurrency = 16
62
63innodb_max_dirty_pages_pct = 90
64innodb_lock_wait_timeout = 120
65innodb_log_buffer_size = 8M
66
67[mysqldump]
68quick
69max_allowed_packet = 16M
70
71[mysql]
72no-auto-rehash
73
74[isamchk]
75key_buffer = 512M
76sort_buffer_size = 512M
77read_buffer = 8M
78write_buffer = 8M
79
80[myisamchk]
81key_buffer = 512M
82sort_buffer_size = 512M
83read_buffer = 8M
84write_buffer = 8M
85
86[mysqlhotcopy]
87interactive-timeout
88[mysqld_safe]
89open-files-limit = 8192


参考:
1、http://hi.baidu.com/ryanxxx/blog/item/719d54ed970dda4a78f055b1.html
2、http://hosting.skif.net/docs/mysql/server-administration.html
清理Mysql日志
3、http://hi.baidu.com/lipengbin/blog/item/6fc58d8fbf116efc503d92ae.html

另:周期清除mysql bin log
http://blog.chinaunix.net/u/21041/showart.php?id=687580

udb服务器down了,因为var目录满了.因为/var/log/mysql目录占用了40G的空间.

查看/etc/mysql/my.cnf ,发现

expire-logs-days  = 20

把expire-logs-days 设成3,然后在mysql命令行执行

PURGE MASTER LOGS TO 'mysql-bin.000930';

即可删除930之前的binlog

 

用这个语句可以清除3天前的binlog,

PURGE MASTER LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 3 DAY);

所以另外还有个方法定期删除binlog:

在contab设置:

0 1 * * *  `mysql -uroot -e 'PURGE MASTER LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 3 DAY);'`


posted on 2008-06-10 19:33 rox 阅读(912) 评论(1)  编辑  收藏 所属分类: Mysql

评论:
# re: 笨笨的mysql在linux下安装 2010-03-31 15:05 | rox
Mysql InnoDB 之 ibdata1 瘦身大法
http://hi.baidu.com/higkoo/blog/item/4d52f05241dab9050df3e3ce.html


Mysql InnoDB 之 ibdata1 瘦身大法2010年02月25日 星期四 12:57 昨天做一大数据量的测试后,发现中途报错,最后查明是由于磁盘空间不足所致。

发现Mysql的ibdata1单个文件就占80G,传说ibdata1是InnoDB的产物,而且只会增大不会减少。

这次被碰到不得不解决了,上网搜了一下解决方法。大体思路就是备份数据,然后删除数据库再还原数据库。

由于这台机上有N个项目的数据库,每敲一个命令都命人心惊胆战。生怕弄错命令后导致全盘数据丢失。可恨的是参数的那篇文件里备份的参数里少了‘存储过程’的备份。让我苦恼万分!如今记下修正后的瘦身大法:

# 备份数据库:

/usr/local/mysql/bin/mysqldump -uDBuser -pPassword --quick --force --routines --add-drop-database --all-databases --add-drop-table > /data/bkup/mysqldump.sql



# 停止数据库

service mysqld stop



# 删除这些大文件

rm /usr/local/mysql/var/ibdata1

rm /usr/local/mysql/var/ib_logfile*

:> /usr/local/mysql/var/mysql-bin.index



# 手动删除除Mysql之外所有数据库文件夹,然后启动数据库

service mysqld start



# 还原数据

/usr/local/mysql/bin/mysql -uroot -pkingsoft < /data/bkup/mysqldump.sql



主要是使用Mysqldump时的一些参数,建议在使用前看一个说明再操作。另外备份前可以先用MySQLAdministrator看一下当前数据库里哪些表占用空间大,把一些不必要的给truncate table掉。这样省些空间和时间。

  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: