saltstack的深入-測試saltstack配置zabbix所需的mysql-server

來源:互聯網
上載者:User

標籤:mysql   saltstack   highstate   

saltstack的深入-測試saltstack配置zabbix所需的mysql-server

操作內容:一、基礎環境1、使用tvm-cobbler安裝一個tvm-zabbix虛擬機器來做實驗。2、網路:eth0:host-only(用於虛擬內網,手動固定IP,這樣從宿主機可以直接連接到這個vm)eth1:NAT(用於上外網,動態IP)[[email protected] ~]# cd /etc/sysconfig/network-scripts/[[email protected] network-scripts]# cat ifcfg-eth0DEVICE=eth0TYPE=EthernetONBOOT=yesNM_CONTROLLED=yesBOOTPROTO=noneIPADDR=192.168.56.200PREFIX=24GATEWAY=192.168.56.1DNS1=192.168.56.254[[email protected] network-scripts]# cat ifcfg-eth1DEVICE=eth1TYPE=EthernetONBOOT=yesNM_CONTROLLED=yesBOOTPROTO=dhcpDNS1=192.168.56.254[[email protected] ~]# df -hFilesystem      Size  Used Avail Use% Mounted on/dev/sda3        36G  1.8G   32G   6% /tmpfs           499M   12K  499M   1% /dev/shm/dev/sda1       194M   29M  155M  16% /boot/dev/sdb1        99G  188M   94G   1% /data使用網域名稱:[[email protected] ~]# cat /etc/dnsmasq.d/office.conf |grep zbx-maddress=/zbx-m.office.test/192.168.56.2003、repo我們在自己的office這個repo中已經增加了幾個rpm包:[[email protected] data]# yum search --disablerepo=\* --enablerepo=office perconaLoaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfile======================================================================================= N/S Matched: percona =======================================================================================Percona-Server-55-debuginfo.x86_64 : Debug information for package Percona-Server-55Percona-Server-client-55.x86_64 : Percona Server - ClientPercona-Server-devel-55.x86_64 : Percona Server - Development header files and librariesPercona-Server-server-55.x86_64 : Percona Server: a very fast and reliable SQL database serverPercona-Server-shared-55.x86_64 : Percona Server - Shared librariesPercona-Server-test-55.x86_64 : Percona Server - Test suitepercona-zabbix-templates.noarch : Percona Monitoring Plugins for Zabbix  Name and summary matches only, use "search all" for everything.二、配置1、sls檔案[[email protected] base]# cat mysql/server.sls    ## 安裝mysql-server,以及對應的zabbix監控相關檔案。# # via pc @ 2015/8/12Percona-Server:  pkg.installed:## for local-office.repo#    - fromrepo: office,base,repo    - name: zabbix-agent    - skip_verify: True    - refresh: True    - pkgs:## for percona-server#            - Percona-Server-55-debuginfo      - Percona-Server-client-55      - Percona-Server-devel-55      - Percona-Server-server-55      - Percona-Server-shared-55      - Percona-Server-test-55      - percona-zabbix-templates## for zabbix# Scripts are installed to /var/lib/zabbix/percona/scripts# Templates are installed to /var/lib/zabbix/percona/templates## /var/lib/zabbix/percona/scripts:# total 64# -rwxr-xr-x 1 root root  1251 Jul 21  2014 get_mysql_stats_wrapper.sh# -rwxr-xr-x 1 root root 58226 Jul 21  2014 ss_get_mysql_stats.php## /var/lib/zabbix/percona/templates:# total 284# -rw-r--r-- 1 root root  18866 Jul 21  2014 userparameter_percona_mysql.conf# -rw-r--r-- 1 root root 269258 Jul 21  2014 zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.4.xml#       - php      - php-mysql/etc/my.cnf:  file.managed:    - source: salt://conf.d/mysql/my.cnf    - mode: 644    - require:      - pkg: Percona-Server/data/mysql:  file.directory:    - user: mysql    - group: mysql    - mode: 755    - makedirs: True    - require:      - pkg: Percona-Serverrun-mysql:## Installing MySQL system tables# PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !# /usr/bin/mysqladmin -u root password ‘new-password‘  cmd.run:    - name: /usr/bin/mysql_install_db    - onlyif:      - d_mysql=$(grep ‘datadir‘ /etc/my.cnf |cut -d‘=‘ -f2);        d_mysql_install="${d_mysql}/mysql";        test ! -d ${d_mysql_install}  service.running:    - name: mysql    - enable: True    - require:      - pkg: Percona-Server## for zabbixpercona_zabbix_php:  file.managed:    - name: /etc/php.ini    - source: salt://conf.d/mysql/percona_zabbix_php.ini    - mode: 755    - require:      - pkg: Percona-Server## for zabbix# notice! password need to be protected in file: ss_get_mysql_stats.phpss_get_mysql_stats:  file.managed:    - name: /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php    - source: salt://conf.d/mysql/ss_get_mysql_stats.php    - mode: 770    - require:      - pkg: Percona-Server2、conf檔案[[email protected] base]# tree conf.d/mysql/conf.d/mysql/├── my.cnf├── percona_zabbix_php.ini└── ss_get_mysql_stats.php0 directories, 3 files[[email protected] base]# cat conf.d/mysql/my.cnf [mysqld]# GENERALdatadir=/data/mysqlsocket=/data/mysql/mysql.sockpid_file=/data/mysql/mysqld.piduser=mysqlport=3306#enforce_storage_engine=InnoDBdefault-storage-engine=InnoDBcharacter_set_server=utf8# InnoDBinnodb_buffer_pool_size=2Ginnodb_flush_method=O_DIRECTinnodb_file_per_table=1innodb_open_files=500innodb_log_buffer_size=128Minnodb_log_file_size=256Minnodb_stats_on_metadata=OFFinnodb_support_xa=OFFinnodb_thread_concurrency=0innodb_io_capacity=200# MyISAMkey_buffer_size=128M#BINLOGserver_id=10log_bin=/data/mysql/mysql-binbinlog_format=mixed#replicate-do-db=cdn#replicate-ignore-db=mysql#replicate-ignore-db=test#relay_log=/data/mysql/relay-log# LOGGINGlog_error=/data/mysql/mysql-error.logslow_query_log=ONlong_query_time=2slow_query_log_file=/data/mysql/mysql-slow##These two variables are only for Perconamax_slowlog_files=5max_slowlog_size=100Mexpire_logs_days=14# OTHERtmp_table_size=32Mmax_heap_table_size=32Mopen_files_limit=600000query_cache_type=0query_cache_size=0thread_cache_size=64table_definition_cache=500table_open_cache=1000max_allowed_packet=16Mmax_connections=800max_user_connections=400max_connect_errors=99999999skip_name_resolve[client]default_character_set=utf8socket=/data/mysql/mysql.sock其他2個檔案,主要是mysql相關的配置要調整:[[email protected] base]# grep ‘mysql.sock‘ conf.d/mysql/percona_zabbix_php.ini mysql.default_socket = /data/mysql/mysql.sockmysqli.default_socket = /data/mysql/mysql.sock[[email protected] base]# grep -E ‘^\$mysql_(u|p)‘ conf.d/mysql/ss_get_mysql_stats.php $mysql_user = ‘zabbix_ro‘;$mysql_pass = ‘xxx‘;$mysql_port = 3306;三、執行[[email protected] base]# salt ‘tvm-zabbix‘ state.sls mysql.server --output-file=‘/tmp/salt.log‘ 四、注意事項如果我們在另一個shell中,開啟了salt-minion的debug日誌,而同時,我們的salt-minion服務並未結束,此時有多個salt-minion:[[email protected] data]# salt-minion -l debug[[email protected] ~]# ps -ef |grep saltroot     31623     1  0 16:45 ?        00:00:01 /usr/bin/python2.6 /usr/bin/salt-minion -droot     31882  1205  0 17:04 pts/0    00:00:00 /usr/bin/python2.6 /usr/bin/salt-minion -l debugroot     31885 31882  1 17:04 pts/0    00:00:00 /usr/bin/python2.6 /usr/bin/salt-minion -l debugroot     32083 29908  0 17:05 pts/1    00:00:00 grep salt則,在salt-master上執行salt命令可能會出現如下的異常:[[email protected] base]# salt ‘tvm-zabbix‘ state.sls mysql.server --output-file=‘/tmp/salt.log‘ [[email protected] base]# cat /tmp/salt.log tvm-zabbix:    Data failed to compile:----------    The function "state.sls" is running as PID 32031 and was started at 2015, Aug 12 17:04:42.900197 with jid 20150812170442900197因此,建議的做法是,先關閉monit和salt-minion服務,然後再手動啟動debug模式的salt-minion服務:service monit stopservice salt-minion stopsalt-minion -l debugZYXW、參考1、老大提供的資料。


saltstack的深入-測試saltstack配置zabbix所需的mysql-server

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.