Ad Widget

Collapse

Zabbix Server doesn't Start on startup

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alexandrevvo
    Junior Member
    • Mar 2011
    • 2

    #1

    Zabbix Server doesn't Start on startup

    I'm having troubles in making the zabbix-server auto-start to work.

    Looking at the log and researching, I could see that the problem is: the initialization fails because the Mysql didn't have started already;

    Code:
    783:20110324:091203.388 Starting Zabbix Server. Zabbix 1.8.2 (revision 11211).
       783:20110324:091203.392 **** Enabled features ****
       783:20110324:091203.392 SNMP monitoring:       YES
       783:20110324:091203.392 IPMI monitoring:       YES
       783:20110324:091203.392 WEB monitoring:        YES
       783:20110324:091203.392 Jabber notifications:  YES
       783:20110324:091203.392 ODBC:                   NO
       783:20110324:091203.392 SSH2 support:           NO
       783:20110324:091203.392 IPv6 support:          YES
       783:20110324:091203.392 **************************
       783:20110324:091203.392 [Z3001] Connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
    I saw that in some cases, configuring the script os zabbix-server on /etc/init.d solved the problem. And I did the indicated:

    Code:
    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides:          zabbix-server
    # Required-Start:    $remote_fs $network
    # Required-Stop:     $remote_fs
    [U][B]# Should-Start: mysql
    # Should-Stop:  mysql[/B][/U]
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: Start zabbix-server daemon
    ### END INIT INFO
    But didn't work..
    The problem happens after reboot or power off.

    running the script manually works fine. (sudo /etc/init.d/zabbix-server);

    Any ideas???

    Thanks.

    ps.: Zabbix 1.8.2 on Ubuntu server 10.10
    Last edited by alexandrevvo; 24-03-2011, 19:58. Reason: missing OS
  • DSon
    Member
    • Sep 2009
    • 44

    #2
    Workaround..

    I had this problem, so I:

    - deleted the startup symbolic links (not the shutdown ones though) for zabbix server and agent
    - added two startup commands for zabbix-server and agent in /etc/rc.local

    Since the rc.local file is the last to be run in the boot up sequence, there should be time for the mysql service to get started.

    Hope this helps,
    Danny.

    Comment

    • Colttt
      Senior Member
      Zabbix Certified Specialist
      • Mar 2009
      • 878

      #3
      can you please send the output from this command:

      Code:
      ls /etc/rc*.d/
      and i would like to know which runlevel do you use..
      Debian-User

      Sorry for my bad english

      Comment

      • DSon
        Member
        • Sep 2009
        • 44

        #4
        Oops!

        Hi there, sorry for the late reply.

        I just realised something!

        The method I suggested (using rc.local) is primarily for versions up to and including 8.04.

        I noticed that you're using 10.10 - doesn't this make use of "upstart" scripts?

        If so, you need to do what I did, which was to search this forum for:

        ubuntu upstart script

        You should find all you need to know in that thread (there is only one that I could find).

        Hope this helps,
        Danny.

        Comment

        • alexandrevvo
          Junior Member
          • Mar 2011
          • 2

          #5
          Tks

          Thanks DSon..

          I think i solved using the rc.local, but I had to put a sleep 2 at the script before calling the service..
          Its not a good solution but worked..

          By the way I'll search for: ubuntu upstart script, and see how it will work..

          Thanks a lot for the replies...

          Anything new I'll post here..

          Comment

          • Tekkell
            Junior Member
            • Mar 2011
            • 15

            #6
            startup

            alexandrevvo,

            Make sure your MySQL is running before your zabbix_server starts.

            in my /etc/rc3.d MySQL starts at S64 but my zabbix_agent and zabbix_server start at S55

            This is after a clean install and all default. Zabbix wants the database to be running when it starts up, but as 55 is lower then 64 it does not and complains.
            My installation is on CentOS 5.6

            changing the startup sequence:

            # chkconfig mysqld off
            # vi /etc/init.d/mysqld

            find the line with chkconfig and change it to 50 50 (line:6)

            # chkconfig mysqld on

            at next reboot the database starts before the zabbix server.

            maybe your distribution is different, but the concept is the same

            rgrds,

            Wim
            Last edited by Tekkell; 13-04-2011, 17:49. Reason: spelling ;)

            Comment

            • efrain02
              Banned
              • Apr 2011
              • 81

              #7
              I have this problem too. The difference is that zabbix only is connected a few seconds and then automatically gets disconnected. Hope someone could help me with this problem.

              Comment

              • Tekkell
                Junior Member
                • Mar 2011
                • 15

                #8
                efrain02,

                Please be more specific. Logs?

                rgrds,

                Comment

                • efrain02
                  Banned
                  • Apr 2011
                  • 81

                  #9
                  This is my zabbix-server.log file:


                  Comment

                  • Tekkell
                    Junior Member
                    • Mar 2011
                    • 15

                    #10
                    efrain02,

                    First of all I think you should remove your zabbix pid-files in /tmp while your zabbix is stopped.
                    The bottom things are (temporary?) connection problems to devices you want to monitor.
                    I cannot see zabbix failing.

                    rgrds,

                    Comment

                    • efrain02
                      Banned
                      • Apr 2011
                      • 81

                      #11
                      Ok thanks . Now i don't have any pid-files. And yes, the bottom things are devices i want to monitor. Now my log file is like this:


                      In the blue rectangle area, it tells me to increase the cache size and i have already increased to 38M just to see what happens. But the screen shows the same. And i can't see any other error.

                      Comment

                      • Tekkell
                        Junior Member
                        • Mar 2011
                        • 15

                        #12
                        Please try the TrendCacheSize, that one is 4M.

                        http://www.zabbix.com/documentation/.../zabbix_server

                        rgrds,
                        Last edited by Tekkell; 19-04-2011, 22:20.

                        Comment

                        • g.vecchi
                          Member
                          • Dec 2010
                          • 44

                          #13
                          Here my /etc/init/zabbix-server.conf:

                          Code:
                          # zabbix-server - Start zabbix server
                          description     "Zabbix Server"
                          author          "Vecchi Giovanni"
                          
                          pre-start script
                          
                          	if [ ! -d /var/run/zabbix-server ]; then
                                  	mkdir -p /var/run/zabbix-server
                              		chown zabbix:zabbix /var/run/zabbix-server
                              		chmod 755 /var/run/zabbix-server
                          	fi
                          
                          	ZabbixConfig=/etc/zabbix/zabbix_server.conf
                          	DBUser=""
                          	DBPassword=""
                          	DBName=""
                          
                          
                          	if [ -f $ZabbixConfig ]
                          	then
                          		DBUser=`cat $ZabbixConfig | grep '^DBUser='`
                          		DBUser="${DBUser##*=}"
                          		DBPassword=`cat $ZabbixConfig | grep '^DBPassword='`
                          		DBPassword="${DBPassword##*=}"
                          		DBName=`cat $ZabbixConfig | grep '^DBName='`
                          		DBName="${DBName##*=}"
                          
                          		if [ -n "$DBUser" ] && [ -n "$DBPassword" ]
                          		then
                          
                          			while [ ! -S /var/run/mysqld/mysqld.sock ]
                          			do
                          				sleep 1
                          			done
                          
                          			i=0
                          
                          			while [ $i -le 5 ]
                          			do
                          			mysql -u$DBUser -p$DBPassword $DBName -e "SELECT \"1\"" &> /dev/null
                          			MYSQL_EXIT_CODE=$?
                          
                          				if [ $MYSQL_EXIT_CODE=0 ]
                          				then
                          			        	i=6
                          		        	else
                          			        	sleep 5
                          			        	i=`expr $i + 1`
                          		        	fi
                          			done
                              		fi
                            	fi
                          
                          end script
                          
                          start on (runlevel [2345] 
                          	  and started mysql)
                          stop on runlevel [016]
                          respawn
                          expect daemon
                          exec /usr/sbin/zabbix_server
                          it works on Ubuntu 10.04.4

                          Comment

                          Working...