Thứ Năm, 5 tháng 11, 2020

[Plesk] How to change default MySQL directory in Plesk Window

 Note: Custom data directory location for client's MySQL has been supported since Plesk 17.8 MU #41


To change database location follow next steps:

  1. Connect to the server using RDP as Administrator.

  2. Shut down MySQL service through Control Panel > Administrative Tools > Services > right-click MySQL57 > Stop.

    Note: if MysQL 5.6 is used, stop MySQL Server service instead.

  3. Copy "%plesk_dir%"\Databases\MySQL\data to the new location (e.g. D:\MySQL\data).

  4. Edit "datadir" option in the C:\"%plesk_dir%"\Plesk\Databases\MySQL\my.ini file in the following way:

    [MySQLD]
    port=3306
    ...
    datadir=D:\\MySQL\\Data
    ...

  5. Give "Full control" permission to the "NT SERVICE\MySQL57" group: right-click the destination folder > Properties > Security.

    Note: if MysQL 5.6 is used, Give "Full control" permission to the "NT SERVICE\MySQL56" group instead.

  6. Start "MySQL57" service Control Panel > Administrative Tools > Services > right-click MySQL57 > Start.

  7. To prevent "Plesk Reconfigurator" to change the path to the new folder location edit the C:\%plesk_dir%\etc\DiskSecurity.xml file in the following way:

    <!-- [PRODUCT_ROOT_D]\MySQL\bin -->
    ...
    <Entry AccounType="1" Domain="NT SERVICE" Account="MySQL57" Path="<D:\MySQL\Data>" AceFlags="FilesOnly" AccessMask="ReadAndExecute" EntryFlags="0x04" />
    ...

    Note: D:\MySQL\Data is the path to the new folder location and can be changed to any required one.

  8. To prevent the resetting of datadir value it is required to change the path in the MYSQL_DATA_D registry to the required one:
    1. 
    Click the Start button.
    2. Type regedit.exe and press the Enter button:


    3. In the opened Windows registry navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\PLESK\PSA Config\Config and find the MYSQL_DATA_D string which contains the actual database directory:

    Indexable text here
    4. Change this value to the required one:
    screenshot1.PNG

Thứ Tư, 4 tháng 11, 2020

[ASP.NET CORE] Bật Development environment để show chi tiết lỗi

 Thông báo lỗi có dạng

The Development environment shouldn't be enabled for deployed applications. It can result in displaying sensitive information from exceptions to end users. For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development and restarting the app.


Để set Development mode có thể set trong web.config thêm cụm tag <environmentVariables>


<system.webServer>
   <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath=".\Application.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false">
      <environmentVariables>
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
      </environmentVariables>
    </aspNetCore>
  </system.webServer>
</configuration>

Thứ Bảy, 20 tháng 6, 2020

[PLESK] Cancel a stuck task in Plesk

Canceling a stuck task in Plesk for Linux

  1. Connect to the Plesk server via SSH.
  2. # plesk db dump > /root/psa_dump.sql
  3. Find stuck process(es):
    # plesk db "SELECT id,type,status,finishTime FROM longtasks WHERE status <> 'done'"

    +----+-----------------------------+---------+---------------------+
    | id | type                        | status  | finishTime          |
    +----+-----------------------------+---------+---------------------+
    | 56 | ext-wp-toolkit-task\install | started | 0000-00-00 00:00:00 |
    +----+-----------------------------+---------+---------------------+
  4. Delete the task from the longtasks table using id from step 3:
    # plesk db "DELETE FROM longtasks WHERE id=56"
  5. Delete entries from the longtaskparams table using id from step 3:
    # plesk db "DELETE FROM longtaskparams WHERE task_id=56"
  6. Kill the stuck process:
    # pkill task-async-executor
    Note: In case tasks keep getting stuck after performing the above actions, clear the lock manager using the below commands:
    # service sw-engine stop
    # rm -rf /var/lock/lmlib/container_locks
    # rm -f /usr/local/psa/var/cache/*
    # service sw-engine start


Canceling a stuck task in Plesk for Windows Server

  1. Connect to the Plesk server via RDP.
  2. C:\> plesk db dump > C:\psa_dump.sql
  3. Find stuck process(es):
    C:\> plesk db "SELECT id,type,status,finishTime FROM longtasks WHERE status <> 'done'"

    +----+-----------------------------+---------+---------------------+
    | id | type                        | status  | finishTime          |
    +----+-----------------------------+---------+---------------------+
    | 56 | ext-wp-toolkit-task\install | started | 0000-00-00 00:00:00 |
    +----+-----------------------------+---------+---------------------+
  4. Delete the task from the longtasks table using id from step 4:
    C:\> plesk db "DELETE FROM longtasks WHERE id=56"
  5. Delete entries from the longtaskparams table using id from step 4:
    C:\> plesk db "DELETE FROM longtaskparams WHERE task_id=56"

Thứ Năm, 14 tháng 5, 2020

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters

C1 : mở regedit
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
chọn DWORD : LongPathsEnabled set value 1

C2: Mở Policy gpedit.msc
Computer Configuration > Administrative Templates > System > Filesystem
"Enable win32 long paths" --> Enable

IIS/WEB site
system.web/httpRuntime/maxURLLength : mặc định 260
-> set tăng lên

<system.web>
<httpRuntime maxUrlLength="500" />
</system.web>


Trên application manifest cần khai báo thêm longPathAware

<application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
        <ws2:longPathAware>true</ws2:longPathAware>
    </windowsSettings>
</application>

https://docs.microsoft.com/vi-vn/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN#maximum-path-length-limitation

Thứ Sáu, 8 tháng 5, 2020

[MSSQL] Kiểm tra mức sử dụng Memory của Database và Object

Kiểm tra mức sử dụng RAM của Database

-- Note: querying sys.dm_os_buffer_descriptors
-- requires the VIEW_SERVER_STATE permission.

DECLARE @total_buffer INT;

SELECT @total_buffer = cntr_value
FROM sys.dm_os_performance_counters 
WHERE RTRIM([object_name]) LIKE '%Buffer Manager'
AND counter_name = 'Database Pages';

;WITH src AS
(
SELECT 
database_id, db_buffer_pages = COUNT_BIG(*)
FROM sys.dm_os_buffer_descriptors
--WHERE database_id BETWEEN 5 AND 32766
GROUP BY database_id
)
SELECT
[db_name] = CASE [database_id] WHEN 32767 
THEN 'Resource DB' 
ELSE DB_NAME([database_id]) END,
db_buffer_pages,
db_buffer_MB = db_buffer_pages / 128,
db_buffer_percent = CONVERT(DECIMAL(6,3), 
db_buffer_pages * 100.0 / @total_buffer)
FROM src
ORDER BY db_buffer_MB DESC; 


Kiểm tra mức sử dụng RAM của Object trong Database

USE [database_name]
GO

;WITH src AS
(
SELECT
[Object] = o.name,
[Type] = o.type_desc,
[Index] = COALESCE(i.name, ''),
[Index_Type] = i.type_desc,
p.[object_id],
p.index_id,
au.allocation_unit_id
FROM
sys.partitions AS p
INNER JOIN
sys.allocation_units AS au
ON p.hobt_id = au.container_id
INNER JOIN
sys.objects AS o
ON p.[object_id] = o.[object_id]
INNER JOIN
sys.indexes AS i
ON o.[object_id] = i.[object_id]
AND p.index_id = i.index_id
WHERE
au.[type] IN (1,2,3)
AND o.is_ms_shipped = 0
)
SELECT
src.[Object],
src.[Type],
src.[Index],
src.Index_Type,
buffer_pages = COUNT_BIG(b.page_id),
buffer_mb = COUNT_BIG(b.page_id) / 128
FROM
src
INNER JOIN
sys.dm_os_buffer_descriptors AS b
ON src.allocation_unit_id = b.allocation_unit_id
WHERE
b.database_id = DB_ID()
GROUP BY
src.[Object],
src.[Type],
src.[Index],
src.Index_Type
ORDER BY
buffer_pages DESC;

Thứ Tư, 25 tháng 9, 2019

[MDaemon]Đồng bộ User từ Active Directory qua Email Server Mdaemon

Trên máy chủ Mdeamon chúng ta làm những thao tác sau:

1. Accounts -> account settings -> active directory-> monitoring: 
– tick check box: monitor active directory for user
– tick check box: use active directory domain names (nhập domain : tencongty)
2. Accounts -> account settings -> active directory-> options : 
– base entry DN: LDAP://server ip/OU=tenou,DC=tencongty,DC=com.
– bind DN: administrator (user administrator cua ad)
– password: pass admin ad
3. Accounts -> account settings -> active directory-> monitoring: click perform full AD scan now.

Khi bạn kết thúc, click perform full AD scan now thì trong tab system sẽ hiển thị quá trình nhận user của MDaemon từ AD.
Khi đã nhận xong user ta có thể kiểm tra trong phần Accounts-> accounts manager.
Thời gian đồng bộ giữa server MDaemon và AD được thiết lập trong phần : Accounts setting ->Active directory -> Query Active directory for new data every.

Chúc bạn thành công

Thứ Hai, 10 tháng 6, 2019

[ASP][IIS] - Blocked a frame with origin from accessing a cross-origin frame.

Blocked a frame with origin "http://hcmier.edu.vn" from accessing a cross-origin frame. 

Thường bị khi xài ckeditor. Lỗi này xảy ra khi truy cập trang admin có www mà khi mở ckeditor lại không có www.

VD: link admin là : http://www.hcmier.edu.vn/vn/wcms/UserLogin.asp
khi mở ckeditor thì chạy sang link http://hcmier.edu.vn thì sẽ lỗi


==> Cần login vào theo link không www  : http://hcmier.edu.vn/vn/wcms/UserLogin.asp

27U6374938