Start by tracking down where the excess usage is being stored. If you have no idea, start from the mountpoint for /dev/sda1:
1
mount | grep sda1
Use the du command. If /dev/sda1 is mounted on / (“root”):
1
du --max-depth=1 --human-readable/|sort --human-numeric-sort
This will list the first level of directories contained in the specified path, in order from smallest to largest. You can increase the depth past 1 to get details of the subdirectories, or change the path to specify a single directory. You can also use the short flags.
For instance, if your username is ubuntu and you want to inspect your home directory:
$lsof| more COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME init 1 root cwd DIR 253,0 4096 2 / init 1 root rtd DIR 253,0 4096 2 / init 1 root txt REG 253,0 150352 1310795 /sbin/init init 1 root mem REG 253,0 65928 5505054 /lib64/libnss_files-2.12.so init 1 root mem REG 253,0 1918016 5521405 /lib64/libc-2.12.so init 1 root mem REG 253,0 93224 5521440 /lib64/libgcc_s-4.4.6-20120305.so.1 init 1 root mem REG 253,0 47064 5521407 /lib64/librt-2.12.so init 1 root mem REG 253,0 145720 5521406 /lib64/libpthread-2.12.so ...
说明:
lsof输出各列信息的意义如下:
COMMAND:进程的名称
PID:进程标识符
PPID:父进程标识符(需要指定-R参数)
USER:进程所有者
PGID:进程所属组
FD:文件描述符,应用程序通过文件描述符识别该文件。如cwd、txt等:
(1)cwd:表示current work dirctory,即:应用程序的当前工作目录,这是该应用程序启动的目录,除非它本身对这个目录进行更改 (2)txt :该类型的文件是程序代码,如应用程序二进制文件本身或共享库,如上列表中显示的 /sbin/init 程序 (3)lnn:library references (AIX); (4)er:FD information error (see NAME column); (5)jld:jail directory (FreeBSD); (6)ltx:shared library text (code and data); (7)mxx :hex memory-mapped type number xx. (8)m86:DOS Merge mapped file; (9)mem:memory-mapped file; (10)mmap:memory-mapped device; (11)pd:parent directory; (12)rtd:root directory; (13)tr:kernel trace file (OpenBSD); (14)v86 VP/ix mapped file; (15)0:表示标准输入 (16)1:表示标准输出 (17)2:表示标准错误 一般在标准输出、标准错误、标准输入后还跟着文件状态模式:r、w、u等 (1)u:表示该文件被打开并处于读取/写入模式 (2)r:表示该文件被打开并处于只读模式 (3)w:表示该文件被打开并处于 (4)空格:表示该文件的状态模式为unknow,且没有锁定 (5)-:表示该文件的状态模式为unknow,且被锁定 同时在文件状态模式后面,还跟着相关的锁 (1)N:for a Solaris NFS lock of unknown type; (2)r:for read lock on part of the file; (3)R:for a read lock on the entire file; (4)w:for a write lock on part of the file;(文件的部分写锁) (5)W:for a write lock on the entire file;(整个文件的写锁) (6)u:for a read and write lock of any length; (7)U:for a lock of unknown type; (8)x:for an SCO OpenServer Xenix lock on part of the file; (9)X:for an SCO OpenServer Xenix lock on the entire file; (10)space:if there is no lock.
set lines 256; set trimout on; set tab off; set pagesize 100; set colsep " | "; COLUMN column_name FORMAT model;
switch PDB
1
altersessionset container = PDB_NAME;
Conn to CDB from PDB
1
ALTER SESSION SETCONTAINER=cdb$root;
Open PDB
1 2
alter pluggable database PDB_NAME open; alter pluggable databaseallopen;
Auto Open PDB when CDB restart
Create trigger at CDB
1 2 3 4 5 6
CREATETRIGGER open_all_pdbs AFTER STARTUP ONDATABASE BEGIN EXECUTEIMMEDIATE ‘ALTER PLUGGABLE DATABASEALLOPEN’; END ; /
Create unlimited bigfile tablespace
1
CREATE BIGFILE TABLESPACE "NSNPR_DATA" DATAFILE 'D:/datafiles/NSNPR/NSNPR_tvc_index.dbf' SIZE 100M REUSE AUTOEXTEND ON NEXT 3G MAXSIZE UNLIMITED LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;
createuser NSNPR IDENTIFIED BY XXXXX defaulttablespace NSNPR_DATA temporarytablespaceTEMP profile DEFAULT; -- Grant/Revoke role privileges grantconnectto NSNPR; grant resource to NSNPR; -- Grant/Revoke system privileges grantcreatedatabase link to NSNPR; grantcreatepublicdatabase link to NSNPR; grantcreatetableto NSNPR; grantcreateviewto NSNPR; grant query rewrite to NSNPR; grantselectanydictionaryto NSNPR; grantselectanytableto NSNPR; grant unlimited tablespaceto NSNPR; grantconnectto NSNPR; grant resource to NSNPR; grant DATAPUMP_IMP_FULL_DATABASE to NSNPR; grant dba to NSNPR; grantcreateanyindexto NSNPR;
/** * This example demonstrates creating a new table for a repository. The steps * are: * <ol> * <li>Establish connection with the MDM server</li> * <li>Create a repository session for the targeted repository</li> * <li>Authenticate the session</li> * <li>Create the new table</li> * <li>Destroy the session</li> * </ol> * Commands used:<br> * <code>CreateRepositorySessionCommand</code><br> * <code>AuthenticateRepositorySessionCommand</code><br> * <code>GetTableListCommand</code><br> * <code>GetRepositoryRegionListCommand</code><br> * <code>CreateTableCommand</code><br> * <code>DestroySessionCommand</code><br> * <br> * <a href="CreateTable.java">Source code for CreateTable.java</a> */ public class CreateTable { privateCreateTable() { } /** * Creates a multi-lingual string based on the list of regions. * @param regionPropertiesList the list of regions * @param baseString the base string * @return a multi-lingual string */ private static MultilingualString createMultilingualString(RegionProperties[] regionPropertiesList, String baseString) { MultilingualString mlString = newMultilingualString(); for (int i = 0; i < regionPropertiesList.length; i++) { Locale locale = regionPropertiesList[i].getLocale(); String regionCode = regionPropertiesList[i].getRegionCode(); String string = baseString + "_" + locale.getLanguage() + "_" + locale.getCountry(); RegionalString regionalString = newRegionalString(string, regionCode); mlString.set(regionalString); } return mlString; } /** * Creates a flat lookup table. * @param regionPropertiesList the list of regions * @return a flat table */ private static TableProperties createFlatTable(RegionProperties[] regionPropertiesList) { MultilingualString tableName = createMultilingualString(regionPropertiesList, "NewTable" + System.currentTimeMillis());
public static void main(String[] args) { // create connection pool to a MDM server String serverName = "LOCALHOST"; ConnectionPool connections = null; try { connections = ConnectionPoolFactory.getInstance(serverName); } catch (ConnectionException e) { e.printStackTrace(); return; }
// specify the repository to use // alternatively, a repository identifier can be obtain from the GetMountedRepositoryListCommand String repositoryName = "TestRepos"; String dbmsName = "LOCALHOST"; RepositoryIdentifier reposId = newRepositoryIdentifier(repositoryName, dbmsName, DBMSType.MS_SQL); // create a repository session CreateRepositorySessionCommand sessionCommand = newCreateRepositorySessionCommand(connections); sessionCommand.setRepositoryIdentifier(reposId ); try { sessionCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; } String sessionId = sessionCommand.getRepositorySession(); // authenticate the repository session String userName = "Admin"; String userPassword = ""; AuthenticateRepositorySessionCommand authCommand = newAuthenticateRepositorySessionCommand(connections); authCommand.setSession(sessionId); authCommand.setUserName(userName); authCommand.setUserPassword(userPassword); try { authCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; } // retrieve the list of tables // this is useful for resolving conflicting table name the new table might create GetTableListCommand tableListCommand = newGetTableListCommand(connections); tableListCommand.setSession(sessionId); try { tableListCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; } // get change stamp // this is required when we make any kind of changes to the repository int changeStamp = tableListCommand.getChangeStamp();
// retrieve the available regions (languages) for the repository // we need this to set up the table name for each region GetRepositoryRegionListCommand getReposRegionListCommand = newGetRepositoryRegionListCommand(connections); getReposRegionListCommand.setRepositoryIdentifier(reposId); try { getReposRegionListCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; } RegionProperties[] regionPropertiesList = getReposRegionListCommand.getRegions();
// set up the table to create TableProperties newTable = createFlatTable(regionPropertiesList); // create the table on repository CreateTableCommand createTableCommand = newCreateTableCommand(connections); createTableCommand.setSession(sessionId); createTableCommand.setTable(newTable); createTableCommand.setInChangeStamp(changeStamp); try { createTableCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; } // finally destroy the session DestroySessionCommand destroySessionCommand = newDestroySessionCommand(connections); destroySessionCommand.setSession(sessionId); try { destroySessionCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; } } }
/** * This example demonstrates creating a new field in the main table. The steps * are: * <ol> * <li>Establishes connection with server</li> * <li>Creates a session for the targeted repository</li> * <li>Authenticates the session</li> * <li>Selects the main table</li> * <li>Creates the new field</li> * <li>Destroys the session</li> * </ol> * Commands used:<br> * <code>CreateRepositorySessionCommand</code><br> * <code>AuthenticateRepositorySessionCommand</code><br> * <code>GetTableListCommand</code><br> * <code>GetFieldListCommand</code><br> * <code>GetRepositoryRegionListCommand</code><br> * <code>CreateFieldCommand</code><br> * <code>DestroySessionCommand</code><br> * <br> * <a href="CreateField.java">Source code for CreateField.java</a> * */ public class CreateField { privateCreateField() { } /** * Creates a multi-lingual string based on the list of regions. * @param regionPropertiesList the list of regions * @param baseString the base string * @return a multi-lingual string */ private static MultilingualString createMultilingualString(RegionProperties[] regionPropertiesList, String baseString) { MultilingualString mlString = newMultilingualString(); for (int i = 0; i < regionPropertiesList.length; i++) { Locale locale = regionPropertiesList[i].getLocale(); String regionCode = regionPropertiesList[i].getRegionCode(); String string = baseString + "_" + locale.getLanguage() + "_" + locale.getCountry(); RegionalString regionalString = newRegionalString(string, regionCode); mlString.set(regionalString); } return mlString; } /** * Creates a fixed-width field. * @param tableId the table from which the field will be create in * @param regionPropertiesList the list of regions * @return the new fixed-width field */ private static FixedWidthTextFieldProperties createFixedWidthField(TableId tableId, RegionProperties[] regionPropertiesList) { MultilingualString fieldName = createMultilingualString(regionPropertiesList, "NewField" + System.currentTimeMillis());
FixedWidthTextFieldProperties field = newFixedWidthTextFieldProperties(); field.setTableId(tableId); field.setName(fieldName); field.setCode("NewCode" + System.currentTimeMillis()); field.setKeywordType(FieldKeywordType.NORMAL); field.setMultiLingual(true); field.setModifyOnce(true); field.setRequired(true); field.setSortType(FieldSortType.CASE_SENSITIVE); field.setWidth(60); field.setDescription(""); return field; } public static void main(String[] args) { // create connection pool to a MDM server String serverName = "LOCALHOST"; ConnectionPool connections = null; try { connections = ConnectionPoolFactory.getInstance(serverName); } catch (ConnectionException e) { e.printStackTrace(); return; }
// specify the repository to use // alternatively, a repository identifier can be obtain from the GetMountedRepositoryListCommand String repositoryName = "TestRepos"; String dbmsName = "LOCALHOST"; RepositoryIdentifier reposId = newRepositoryIdentifier(repositoryName, dbmsName, DBMSType.MS_SQL); // create a repository session CreateRepositorySessionCommand sessionCommand = newCreateRepositorySessionCommand(connections); sessionCommand.setRepositoryIdentifier(reposId ); try { sessionCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; } String sessionId = sessionCommand.getRepositorySession(); // authenticate the repository session String userName = "Admin"; String userPassword = ""; AuthenticateRepositorySessionCommand authCommand = newAuthenticateRepositorySessionCommand(connections); authCommand.setSession(sessionId); authCommand.setUserName(userName); authCommand.setUserPassword(userPassword); try { authCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; }
// retrieve the list of tables and pick the main table for creating a new field GetTableListCommand tableListCommand = newGetTableListCommand(connections); tableListCommand.setSession(sessionId); try { tableListCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; }
TableProperties mainTable = null; TableProperties[] tables = tableListCommand.getTables(); for (int i = 0; i < tables.length; i++) { if (tables[i].getType() == TableProperties.MAIN) mainTable = tables[i]; } // retrieve the list of fields from the main table // this is useful for resolving conflicting field names the new field might create GetFieldListCommand getFieldListCommand = newGetFieldListCommand(connections); getFieldListCommand.setSession(sessionId); getFieldListCommand.setTableId(mainTable.getId()); try { getFieldListCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; } // get the change stamp // this is required when we make any kind of changes to the repository int changeStamp = getFieldListCommand.getChangeStamp(); // retrieve the available regions (languages) for the repository // we need this to set up the field name for each region GetRepositoryRegionListCommand getReposRegionListCommand = newGetRepositoryRegionListCommand(connections); getReposRegionListCommand.setRepositoryIdentifier(reposId); try { getReposRegionListCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; } RegionProperties[] regionPropertiesList = getReposRegionListCommand.getRegions();
// set up the field to create FieldProperties newField = createFixedWidthField(mainTable.getId(), regionPropertiesList); // create the new field CreateFieldCommand createFieldCommand = newCreateFieldCommand(connections); createFieldCommand.setSession(sessionId); createFieldCommand.setField(newField); createFieldCommand.setInChangeStamp(changeStamp); try { createFieldCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; } // finally destroy the session DestroySessionCommand destroySessionCommand = newDestroySessionCommand(connections); destroySessionCommand.setSession(sessionId); try { destroySessionCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; } } }
/** * This example demonstrates modifying a new field in the main table. The steps * are: * <ol> * <li>Establishes connection with MDM server</li> * <li>Creates a session for the targeted repository</li> * <li>Authenticates the session</li> * <li>Selects the main table</li> * <li>Creates the new field</li> * <li>Modifies the new field</li> * <li>Destroys the session</li> * </ol> * Commands used:<br> * <code>CreateRepositorySessionCommand</code><br> * <code>AuthenticateRepositorySessionCommand</code><br> * <code>GetTableListCommand</code><br> * <code>GetFieldListCommand</code><br> * <code>GetRepositoryRegionListCommand</code><br> * <code>CreateFieldCommand</code><br> * <code>ModifyFieldCommand</code><br> * <code>DestroySessionCommand</code><br> * <br> * <a href="ModifyField.java">Source code for ModifyField.java</a> */ public class ModifyField { privateModifyField() { } /** * Creates a multi-lingual string based on the list of regions. * @param regionPropertiesList the list of regions * @param baseString the base string * @return a multi-lingual string */ private static MultilingualString createMultilingualString(RegionProperties[] regionPropertiesList, String baseString) { MultilingualString mlString = newMultilingualString(); for (int i = 0; i < regionPropertiesList.length; i++) { Locale locale = regionPropertiesList[i].getLocale(); String regionCode = regionPropertiesList[i].getRegionCode(); String string = baseString + "_" + locale.getLanguage() + "_" + locale.getCountry(); RegionalString regionalString = newRegionalString(string, regionCode); mlString.set(regionalString); } return mlString; } /** * Creates a fixed-width field. * @param tableId the table from which the field will be create in * @param regionPropertiesList the list of regions * @return the new fixed-width field */ private static FixedWidthTextFieldProperties createFixedWidthField(TableId tableId, RegionProperties[] regionPropertiesList) { MultilingualString fieldName = createMultilingualString(regionPropertiesList, "NewField" + System.currentTimeMillis());
FixedWidthTextFieldProperties field = newFixedWidthTextFieldProperties(); field.setTableId(tableId); field.setName(fieldName); field.setKeywordType(FieldKeywordType.NORMAL); field.setMultiLingual(true); field.setModifyOnce(true); field.setRequired(true); field.setSortType(FieldSortType.CASE_SENSITIVE); field.setWidth(60); return field; } public static void main(String[] args) { // create connection pool to a MDM server String tag = "LOCALHOST"; ConnectionPool connections = null; try { connections = ConnectionPoolFactory.getInstance(tag); } catch (ConnectionException e) { e.printStackTrace(); return; }
// specify the repository to use // alternatively, a repository identifier can be obtain from the GetMountedRepositoryListCommand String repositoryName = "TestRepos"; String dbmsName = "LOCALHOST"; RepositoryIdentifier reposId = newRepositoryIdentifier(repositoryName, dbmsName, DBMSType.MS_SQL); // create a repository session CreateRepositorySessionCommand sessionCommand = newCreateRepositorySessionCommand(connections); sessionCommand.setRepositoryIdentifier(reposId ); try { sessionCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; } String sessionId = sessionCommand.getRepositorySession(); // authenticate the repository session String userName = "Admin"; String userPassword = ""; AuthenticateRepositorySessionCommand authCommand = newAuthenticateRepositorySessionCommand(connections); authCommand.setSession(sessionId); authCommand.setUserName(userName); authCommand.setUserPassword(userPassword); try { authCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; }
// retrieve the list of tables and pick the main table for creating a new field GetTableListCommand tableListCommand = newGetTableListCommand(connections); tableListCommand.setSession(sessionId); try { tableListCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; }
TableProperties mainTable = null; TableProperties[] tables = tableListCommand.getTables(); for (int i = 0; i < tables.length; i++) { if (tables[i].getType() == TableProperties.MAIN) mainTable = tables[i]; } // retrieve the list of fields from the main table // this is useful for resolving conflicting field names the new field might create GetFieldListCommand getFieldListCommand = newGetFieldListCommand(connections); getFieldListCommand.setSession(sessionId); getFieldListCommand.setTableId(mainTable.getId()); try { getFieldListCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; } // get the change stamp // this is required when we make any kind of changes to the repository int changeStamp = getFieldListCommand.getChangeStamp(); // retrieve the available regions (languages) for the repository // we need this to set up the field name for each region GetRepositoryRegionListCommand getReposRegionListCommand = newGetRepositoryRegionListCommand(connections); getReposRegionListCommand.setRepositoryIdentifier(reposId); try { getReposRegionListCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; } RegionProperties[] regionPropertiesList = getReposRegionListCommand.getRegions();
// set up the field to create FieldProperties newField = createFixedWidthField(mainTable.getId(), regionPropertiesList); // create the new field CreateFieldCommand createFieldCommand = newCreateFieldCommand(connections); createFieldCommand.setSession(sessionId); createFieldCommand.setField(newField); createFieldCommand.setInChangeStamp(changeStamp); try { createFieldCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; } // a new change stamp is required. changeStamp = createFieldCommand.getOutChangeStamp(); // setup the field for modification FixedWidthTextFieldProperties modifiedField = (FixedWidthTextFieldProperties) newField; modifiedField.setWidth(100); modifiedField.setRequired(false); // modify the field ModifyFieldCommand modifyFieldCommand = newModifyFieldCommand(connections); modifyFieldCommand.setSession(sessionId); modifyFieldCommand.setInChangeStamp(changeStamp); modifyFieldCommand.setField(modifiedField); try { modifyFieldCommand.execute(); } catch (CommandException e) { e.printStackTrace(); return; }
if (crFailed != null && crFailed.length > 0) { logger.info("modifyRecords: No. of records failed:" + crFailed.length); for (int i = 0; i < crFailed.length; i++) { int j = crFailed[i]; logger.info("modifyRecords: failed messages:" + modifyRecordsCommand.getResult().getFailedRecordMessage(j)); } }
//Get Succeded Records int crSuccess[] = modifyRecordsCommand.getResult().getSucceededRecords(); if (crSuccess != null && crSuccess.length > 0) logger.info("modifyRecords: No. of records succeeded:" + crSuccess.length);
Note: Be careful when using the –relocate option. If you mistype the argument, you might end up creating nonsensical URLs within your working copy that render the whole workspace unusable and tricky to fix. It’s also important to understand exactly when one should or shouldn’t use –relocate. Here’s the rule of thumb:
If the working copy needs to reflect a new directory within the repository, use just svn switch.
If the working copy still reflects the same repository directory, but the location of the repository itself has changed, use svn switch with the –relocate option.