I extracted motion acceleration with MPU6050 and removed gravity. Now, the problem is when I put the sensor in no-move status, I read nearly zero acceleration in z-axis but when I turn it 180 degree and then put it in the rest it shows nearly -2. There is a constant of 2 and I don't know how to remove it. I want the sensor to show me a zero acceleration when it is not moving.
You "removed gravity" from the Z axis by subtracting a constant. Obviously, this does not work if the Z axis no longer points "up".
If the sensor cannot be maintained in a particular orientation with respect to the gravity vector, then there is no simple way to remove gravity. You'll have to do a full 6-dimensional motion solution (3 axis accelerometer, 3-axis gyro) to determine position and attitude, and then derive your non-gravity accelerations from that.
Even then, your sensors will have long-term drift, so your solution will also need to have a means for compensating for that.