Take the backup of complete RANGER database before you perform any operation.
1). Delete all the services created in RANGER UI(HDFS,Knox, Hive).
2). Login to RANGER DB to get the missing user.
use ranger; select config from x_assets;
w.r.to. HDP 2.2 , x_assets holds all field with key and value pair which we give during repo/service creation in RANGER UI. This entry is stored as JSON.
2). Login to Ranger UI and create a dummy service(eg HDFS_TEST) with a username identified from step 2 and save and then delete the service. 2). Shutdown RANGER via Ambari 3). Login to ranger database(oracle/MySQL etc)
select * from x_db_version_h;
Look for the presence of version entries J1001,J10002,J10003
3).Take the backup of the x_db_version_h table as
create table x_db_version_h_backup as select * from x_db_version_h;
then delete the following entries.
delete from x_db_version_h where version='J10001';
delete from x_db_version_h where version='J10002';
delete from x_db_version_h where version='J10003';
4).Run the db_setup.py script
su - root cd /usr/hdp/2.4*/ranger-admin python db_setup.py -javapatch
This would re-apply all the deleted patches and download the policies.
5).Restart the RANGER make sure policies are visible now.