注:此篇文章的部分内容摘抄自公司同事编写的技术文档,在此对他致以衷心的谢意!

Cacti、Nagios、Zabbix都是生产环境常用的监控软件,为了整合资源便于管理一般都将这三种监控软件整合到一台服务器中,下面是工作中总结的适合Cacti、Zabbix、Nagios的编译参数和基本配置方法,希望对大家有帮助。

1. mysql编译和安装配置(mysql-5.1.58)

  1. ./configure \ 
  2. --prefix=/usr/local/mysql-5.1.58 \ 
  3. --enable-assembler \ 
  4. --with-libwrap=/usr/lib/ \ 
  5. --with-charset=utf8 \ 
  6. --with-extra-charsets=gb2312,gbk,big5,latin1,utf8 \ 
  7. --with-mysqld-user=mysql \ 
  8. --without-debug \ 
  9. --with-big-tables \ 
  10. --enable-thread-safe-client \ 
  11. --with-client-ldflags=-all-static \ 
  12. --with-plugins=myisam,myisammrg,innodb_plugin 
  13.  
  14. make && make install
  15.  
  16. cd /usr/local; ln -s mysql-5.1.58 mysql
  17.  
  18. cd /src/mysql-5.1.58; /bin/cp -pfr support-files /usr/local/mysql/
    groupadd mysql; useradd mysql -g mysql
  19. mkdir -p /data/mysql/{data,ibdata,log}
  20. chown -R mysql:mysql /data/mysql
  21.  

2. mysql配置文件

  1. [client] 
  2. port            = 3306 
  3. socket          = /tmp/mysql.sock 
  4.  
  5. [mysqld] 
  6. port            = 3306 
  7. socket          = /tmp/mysql.sock 
  8. character-set-server=utf8 
  9. init_connect='set names utf8' 
  10. skip-name-resolve 
  11. basedir = /usr/local/mysql 
  12. datadir = /data/mysql/data 
  13. back_log = 50 
  14. max_connections = 600 
  15. max_connect_errors = 10 
  16. skip-external-locking 
  17. max_heap_table_size = 64M 
  18. sort_buffer_size = 8M 
  19. join_buffer_size = 8M 
  20. thread_cache_size = 8 
  21. thread_concurrency = 8 
  22. query_cache_size = 64M 
  23. query_cache_limit = 2M 
  24. ft_min_word_len = 4 
  25. default-storage-engine = InnoDB 
  26. thread_stack = 192K 
  27. transaction_isolation = REPEATABLE-READ 
  28. tmp_table_size = 64M 
  29. long_query_time = 5 
  30. log-error  
  31. slow_query_log 
  32. server-id = 1 
  33. key_buffer_size = 32M 
  34. read_buffer_size = 8M 
  35. read_rnd_buffer_size = 16M 
  36. bulk_insert_buffer_size = 64M 
  37. myisam_sort_buffer_size = 128M 
  38. myisam_max_sort_file_size = 10G 
  39. myisam_repair_threads = 1 
  40. myisam_recover 
  41. ignore-builtin-innodb 
  42. plugin-load=innodb=ha_innodb_plugin.so 
  43. plugin_dir=/usr/local/mysql/lib/mysql/plugin 
  44. innodb_file_format=barracuda 
  45. innodb_additional_mem_pool_size = 20M 
  46. innodb_buffer_pool_size = 1G 
  47. innodb_data_file_path = ibdata1:20M:autoextend 
  48. innodb_file_per_table = 1 
  49. innodb_data_home_dir = /data/mysql/ibdata 
  50. innodb_file_io_threads = 4 
  51. innodb_thread_concurrency = 16 
  52. innodb_flush_log_at_trx_commit = 0 
  53. innodb_log_buffer_size = 8M 
  54. innodb_log_file_size = 1024M 
  55. innodb_log_files_in_group = 2 
  56. innodb_log_group_home_dir = /data/mysql/ibdata 
  57. innodb_max_dirty_pages_pct = 90 
  58. innodb_flush_method=O_DSYNC 
  59. innodb_lock_wait_timeout = 120 
  60. innodb_open_files = 300 
  61.  
  62. [mysqldump] 
  63. quick 
  64. max_allowed_packet = 32M 
  65.  
  66. [mysql] 
  67. no-auto-rehash 
  68.  
  69. [myisamchk] 
  70. key_buffer_size = 512M 
  71. sort_buffer_size = 512M 
  72. read_buffer = 8M 
  73. write_buffer = 8M 
  74.  
  75. [mysqlhotcopy] 
  76. interactive-timeout 
  77. record_buffer = 16773120 
  78.  
  79. [mysqld_safe] 
  80. open-files-limit = 8192 

3. 初始化系统库配置启动脚本

  1. cd /usr/local/mysql; bin/mysql_install_db --user=mysql 
  2.  
  3. /bin/cp -rf /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
  4. chmod +x /etc/init.d/mysqld 
  5. chkconfig --add mysqld 
  6. chkconfig mysqld on 
  7. service mysqld start 

4. 设置环境变量

  1. echo "export MYSQL_HOME=/usr/local/mysql " >> /etc/profile; 
  2. echo "export PATH=$PATH:$MYSQL_HOME/bin" >> /etc/profile; 
  3. echo "export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/lib64:/usr/local/lib:$MYSQL_HOME/lib/mysql" >> /etc/profile 
  4. source /etc/profile 

5. 设置mysql的root密码

  1. /usr/local/mysql/bin/mysqladmin -u root password 'q1w2e3r4' 
  2. /usr/local/mysql/bin/mysqladmin -u root -h 127.0.0.1 password 'q1w2e3r4'