Repository: ambari Updated Branches: refs/heads/trunk 72552aa65 -> 42ae84bbd
AMBARI-8832. Hive metastore fails on Ubuntu (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/42ae84bb Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/42ae84bb Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/42ae84bb Branch: refs/heads/trunk Commit: 42ae84bbd01a67f4f82582986eaaadcea79302ff Parents: 72552aa Author: Andrew Onishuk <[email protected]> Authored: Fri Dec 19 19:34:54 2014 +0200 Committer: Andrew Onishuk <[email protected]> Committed: Fri Dec 19 19:34:54 2014 +0200 ---------------------------------------------------------------------- .../0.12.0.2.0/package/files/addMysqlUser.sh | 5 ++- .../HIVE/0.12.0.2.0/package/scripts/mysql.py | 35 ++++++++++++++++++++ .../0.12.0.2.0/package/scripts/mysql_server.py | 10 +++--- .../0.12.0.2.0/package/scripts/mysql_service.py | 8 +---- .../0.12.0.2.0/package/scripts/mysql_users.py | 14 +++++--- .../stacks/2.0.6/HIVE/test_mysql_server.py | 30 +++++++++-------- 6 files changed, 73 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/42ae84bb/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/files/addMysqlUser.sh ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/files/addMysqlUser.sh b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/files/addMysqlUser.sh index 4e8b968..1c47caf 100644 --- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/files/addMysqlUser.sh +++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/files/addMysqlUser.sh @@ -25,7 +25,10 @@ mysqldbuser=$2 mysqldbpasswd=$3 userhost=$4 -sudo service $mysqldservice start +# The restart (not start) is required to pick up mysql configuration changes made by sed +# during install, in case mysql is already started. The changes are required by Hive later on. +sudo service $mysqldservice restart + echo "Adding user $mysqldbuser@% and removing users with empty name" sudo su mysql -s /bin/bash - -c "mysql -u root -e \"CREATE USER '$mysqldbuser'@'%' IDENTIFIED BY '$mysqldbpasswd';\"" sudo su mysql -s /bin/bash - -c "mysql -u root -e \"GRANT ALL PRIVILEGES ON *.* TO '$mysqldbuser'@'%';\"" http://git-wip-us.apache.org/repos/asf/ambari/blob/42ae84bb/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql.py new file mode 100644 index 0000000..5006b56 --- /dev/null +++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +""" +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +""" + +from resource_management import * +import mysql_users + +def mysql_configure(): + import params + + # required for running hive + replace_bind_address = ('sed','-i','s|^bind-address[ \t]*=.*|bind-address = 0.0.0.0|',params.mysql_configname) + Execute(replace_bind_address, + sudo = True, + ) + + # this also will start mysql-server + mysql_users.mysql_adduser() + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/42ae84bb/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql_server.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql_server.py index 91a699b..946a360 100644 --- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql_server.py +++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql_server.py @@ -19,9 +19,11 @@ limitations under the License. """ import sys +import mysql_users from resource_management import * from mysql_service import mysql_service +from mysql import mysql_configure class MysqlServer(Script): @@ -31,14 +33,14 @@ class MysqlServer(Script): self.configure(env) def clean(self, env): - import params, mysql_users + import params env.set_params(params) - mysql_users.mysql_deluser(params) + mysql_users.mysql_deluser() def configure(self, env): - import params, mysql_users + import params env.set_params(params) - mysql_users.mysql_adduser(params) + mysql_configure() def start(self, env, rolling_restart=False): import params http://git-wip-us.apache.org/repos/asf/ambari/blob/42ae84bb/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql_service.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql_service.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql_service.py index 2f0c6f6..f908c75 100644 --- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql_service.py +++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql_service.py @@ -35,13 +35,7 @@ def mysql_service(daemon_name=None, action='start'): sudo = True, ) elif action == 'start': - import params - # required for running hive - replace_bind_address = ('sed','-i','s|^bind-address[ \t]*=.*|bind-address = 0.0.0.0|',params.mysql_configname) - Execute(replace_bind_address, - sudo = True, - ) - + import params Execute(cmd, logoutput = True, not_if = status_cmd, http://git-wip-us.apache.org/repos/asf/ambari/blob/42ae84bb/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql_users.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql_users.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql_users.py index 9961c18..44fad0b 100644 --- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql_users.py +++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/mysql_users.py @@ -21,7 +21,9 @@ limitations under the License. from resource_management import * # Used to add hive access to the needed components -def mysql_adduser(params): +def mysql_adduser(): + import params + File(params.mysql_adduser_path, mode=0755, content=StaticFile('addMysqlUser.sh') @@ -38,11 +40,14 @@ def mysql_adduser(params): Execute(cmd, tries=3, try_sleep=5, - path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin' + path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin', + logoutput=True, ) # Removes hive access from components -def mysql_deluser(params): +def mysql_deluser(): + import params + File(params.mysql_deluser_path, mode=0755, content=StaticFile('removeMysqlUser.sh') @@ -60,6 +65,7 @@ def mysql_deluser(params): Execute(cmd, tries=3, try_sleep=5, - path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin' + path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin', + logoutput=True, ) http://git-wip-us.apache.org/repos/asf/ambari/blob/42ae84bb/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_mysql_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_mysql_server.py b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_mysql_server.py index 79c777b..0a89650 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_mysql_server.py +++ b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_mysql_server.py @@ -44,12 +44,6 @@ class TestMySqlServer(RMFTestCase): target = RMFTestCase.TARGET_COMMON_SERVICES ) - self.assertResourceCalled('Execute', ('sed', - '-i', - 's|^bind-address[ \t]*=.*|bind-address = 0.0.0.0|', - '/etc/my.cnf'), - sudo = True, - ) self.assertResourceCalled('Execute', ('service','mysql','start'), logoutput = True, not_if = 'service mysql status | grep running', @@ -93,12 +87,6 @@ class TestMySqlServer(RMFTestCase): target = RMFTestCase.TARGET_COMMON_SERVICES ) - self.assertResourceCalled('Execute', ('sed', - '-i', - 's|^bind-address[ \t]*=.*|bind-address = 0.0.0.0|', - '/etc/my.cnf'), - sudo = True, - ) self.assertResourceCalled('Execute', ('service','mysql','start'), logoutput = True, not_if = 'service mysql status | grep running', @@ -145,6 +133,12 @@ class TestMySqlServer(RMFTestCase): self.assertNoMoreResources() def assert_configure_default(self): + self.assertResourceCalled('Execute', ('sed', + '-i', + 's|^bind-address[ \t]*=.*|bind-address = 0.0.0.0|', + '/etc/my.cnf'), + sudo = True, + ) self.assertResourceCalled('File', '/tmp/addMysqlUser.sh', content = StaticFile('addMysqlUser.sh'), mode = 0755, @@ -153,9 +147,16 @@ class TestMySqlServer(RMFTestCase): path = ['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'], tries = 3, try_sleep = 5, + logoutput = True, ) - + def assert_configure_secured(self): + self.assertResourceCalled('Execute', ('sed', + '-i', + 's|^bind-address[ \t]*=.*|bind-address = 0.0.0.0|', + '/etc/my.cnf'), + sudo = True, + ) self.assertResourceCalled('File', '/tmp/addMysqlUser.sh', content = StaticFile('addMysqlUser.sh'), mode = 0755, @@ -164,6 +165,7 @@ class TestMySqlServer(RMFTestCase): path = ['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'], tries = 3, try_sleep = 5, + logoutput = True, ) def assert_clean_default(self): @@ -175,6 +177,7 @@ class TestMySqlServer(RMFTestCase): path = ['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'], tries = 3, try_sleep = 5, + logoutput = True, ) def assert_clean_secured(self): @@ -186,4 +189,5 @@ class TestMySqlServer(RMFTestCase): path = ['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'], tries = 3, try_sleep = 5, + logoutput = True, )
