Tag Archives: Permission denied

JAVA api Access HDFS Error: Permission denied in production environment

An error occurs when the Java API accesses the HDFS file system without specifying the access user

        //1. Create the object of hadoop configuration
//        Configuration conf = new Configuration();
        Configuration conf = new Configuration();
        conf.set("fs.defaultFS","hdfs://linux121:9000");
        //2. Create the object of hadoop FileSystem
//        FileSystem fileSystem = FileSystem.get(new URI("hdfs://linux121:9000"), conf, "root");
        FileSystem fileSystem = FileSystem.get(conf);
        //3. Create the files
        fileSystem.mkdirs(new Path("/tp_user"));
        //4. Close
        fileSystem.close();

The following error messages appear:

org.apache.hadoop.security.AccessControlException: Permission denied: user=QI, access=WRITE, inode="/":root:supergroup:drwxr-xr-x
	at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.check(FSPermissionChecker.java:350)
	at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkPermission(FSPermissionChecker.java:251)
	at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkPermission(FSPermissionChecker.java:189)
	at org.apache.hadoop.hdfs.server.namenode.FSDirectory.checkPermission(FSDirectory.java:1753)
	at org.apache.hadoop.hdfs.server.namenode.FSDirectory.checkPermission(FSDirectory.java:1737)
	at org.apache.hadoop.hdfs.server.namenode.FSDirectory.checkAncestorAccess(FSDirectory.java:1696)
	at org.apache.hadoop.hdfs.server.namenode.FSDirMkdirOp.mkdirs(FSDirMkdirOp.java:60)
	at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.mkdirs(FSNamesystem.java:2990)
	at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.mkdirs(NameNodeRpcServer.java:1096)
	at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.mkdirs(ClientNamenodeProtocolServerSideTranslatorPB

If the access name is not specified, the default is to use the current system user name for access, and an error will be reported if the permission is insufficient. The access permission of HDFS user is weak, which can not prevent bad people from doing bad things!!

In the case of production, there are three solutions:

Specify the user information to obtain the file system object and close the HDFS cluster permission verification

Turn off HDFS cluster permission verification

vim hdfs-site.xml
#Add the following properties
<property>
<name>dfs.permissions</name>
<value>true</value>
</property>

Based on the weak characteristics of HDFS permissions, we can completely give up HDFS permission verification. If we are in a production environment, we can consider using Kerberos, sentry and other security frameworks to manage the security of big data clusters. Therefore, we directly modify the root directory permission of HDFS to 777

hadoop fs -chmod -R 777 /

[Solved] SSH connect error: permission denied, please try again

Permission denied, please try again. Error is reported as follows

When using SSH to log in to ECS (elastic compute server) Linux server, if you are the root user, even if you enter the password correctly, the following error messages will appear.

Permission denied, please try again.

The ssh server rejected the password. Please try again.

However, non-root users can log in normally, and root users can log in normally through the management terminal.

The reason for the problem is that the server SSH service is configured with the policy of prohibiting root user login.

If this parameter is not configured, or if the parameter value is set to Yes (default), root user login is allowed. Root user login will be blocked only when the displayed setting is No.

This parameter only affects the user’s SSH login, and does not affect the user’s login to the system through management terminal and other methods.

service sshd restart
restart sshd

Then try again.

Obnoxious permission denied: how does ADB handle permission denied when accessing mobile directory

Programmer algorithm practice must read, common Java API skills to share>>>

Story background

There is no response in an app of mobile phone, I want to find the mobile phone anr log

But I only know that there is a tra * * file in a directory of Data directory, and there is a anr log in the file

I really forgot the details, so I want to go into data and check it with LS

The result is a nasty permission denied

A face muddled force, how to adjust, and then go to the morning search method

If you explore the process, you don’t have to talk nonsense, just talk about the solution

Solutions

1、 Get root permission from mobile phone

My mobile phone is Meizu. The method of root is very simple. Here is the method

2、 Su command to get the highest permission

After entering Su, there will be a pop-up window on the mobile phone

Permission — permission, done

3、 Do whatever you want

Then you can do what you want to do

You will find that the directory I want is anr and the file is traces.txt

Then ADB pull data/anr/traces. TXT > D:anr.log

OK

It seems that you can solve the problem without root, but I didn’t try it. If you are interested, you can try it

Android Error: open failed: EACCES (Permission denied)

When using Android to read SD card data, an error is reported. The reason is that after Android 6.0, in addition to adding read and write permissions in androidmanifest.xml, you also need to manually request permissions when using it.

1. Add read and write permissions to androidmanifest.xml:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

2. To manually request permission before reading or writing:

import android.support.v4.app.ActivityCompat;

private static final int REQUEST_EXTERNAL_STORAGE = 1;
private static String[] PERMISSIONS_STORAGE = {
    Manifest.permission.READ_EXTERNAL_STORAGE,
    Manifest.permission.WRITE_EXTERNAL_STORAGE
};

/**
 * Call this method before reading or writing to the sd card
 * Checks if the app has permission to write to device storage
 * If the app does not has permission then the user will be prompted to grant permissions
 */
public static void verifyStoragePermissions(Activity activity) {
    // Check if we have write permission
    int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    if (permission != PackageManager.PERMISSION_GRANTED) {
        // We don't have permission so prompt the user
        ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE);
    }
}

Note: activitycompat is the method in android-support-v4.jar.