deeso / fleet-deployment

Apache License 2.0
15 stars 4 forks source link

setup.sh does not create or prepare the kolide database #3

Open TonyLeeVT opened 5 years ago

TonyLeeVT commented 5 years ago

Thanks again for the great work. After running setup.sh and then running "service fleet-service status", I see the following error:

May 08 18:24:21 ubuntu fleet-service[19893]: {"mysql":"could not connect to db: Error 1049: Unknown database 'kolide', sleeping 1s","ts":"2019-05-09T01:24:21.147892244Z"}

It appears that the kolide database is not created.

Something similar to the following should work in your script: mysql -uroot -p${MYSQL_PASS} -e "create database kolide"

Then after that, there will be another error: May 08 18:42:35 ubuntu fleet-service[20023]: Using config file: /opt/fleet//conf/fleet.yaml May 08 18:42:35 ubuntu fleet-service[20023]: ################################################################################ May 08 18:42:35 ubuntu fleet-service[20023]: # ERROR: May 08 18:42:35 ubuntu fleet-service[20023]: # Your Fleet database is not initialized. Fleet cannot start up. May 08 18:42:35 ubuntu fleet-service[20023]: # May 08 18:42:35 ubuntu fleet-service[20023]: # Run /usr/bin/fleet prepare db to initialize the database. May 08 18:42:35 ubuntu fleet-service[20023]: ################################################################################

Something similar to the following should work in your script: /usr/bin/fleet prepare db --mysql_address=127.0.0.1:3306 --mysql_database=kolide --mysql_username=root --mysql_password=${MYSQL_PASS}

TonyLeeVT commented 5 years ago

The suggested fixes above have been verified from a clean install. The end of the install.sh file now reads (new content in code blocks):

--SNIP--

create the system v service and run it at startup

sudo cp $ISERVICE $FSERVICE sudo chmod a+x $FSERVICE sudo update-rc.d $SERVICE defaults sudo update-rc.d $SERVICE enable

# create the kolide database within mysql
mysql -uroot -p${MYSQL_PASS} -e "create database kolide"

# prepare the kolide database
/usr/bin/fleet prepare db --mysql_address=127.0.0.1:3306 --mysql_database=kolide --mysql_username=root --mysql_password=${MYSQL_PASS}

$FSERVICE start