隨筆-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 閱讀(924) 評論(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掉。這樣省些空間和時間。

            回復  更多評論
            
          主站蜘蛛池模板: 香港| 芦山县| 大名县| 乌拉特前旗| 咸丰县| 齐河县| 北川| 大邑县| 枣强县| 兴城市| 安塞县| 西藏| 永嘉县| 菏泽市| 积石山| 贵定县| 安塞县| 和平区| 吉木乃县| 保康县| 静安区| 牙克石市| 彰化市| 达日县| 湄潭县| 乐陵市| 桃园县| 来安县| 黄大仙区| 茂名市| 香河县| 彭山县| 东辽县| 德阳市| 共和县| 西吉县| 庄浪县| 清徐县| 金秀| 时尚| 保定市|