Change Default Password for Redis
-
The following steps use the new password of Redis as
f8K5ZT3aQXTbas an example. The Redis password must be modified in the actual configuration- To ensure compatibility, avoid using special characters such as "$", "&", "!" or "@" when customizing passwords. These characters may interfere with regular expression parsing. Please use hyphens "-" or underscores "_" instead
-
It is recommended to data backup in advance before operation.
-
The microservice version needs to be greater than v3.7.0 or above
-
Enter the sc container and log in to Redis
docker exec -it $(docker ps | grep sc | awk '{print $1}') bash -c 'redis-cli -a 123456' -
Modify Redis password
config set requirepass f8K5ZT3aQXTb -
Modify the docker-compose.yaml file and add environment variables and port mapping
Default path of docker-compose.yaml file: /data/hap/script/docker-compose.yaml
Add the environment variable
ENV_REDIS_PASSWORDunder the core service to specify the new password for RedisENV_REDIS_PASSWORD: "f8K5ZT3aQXTb"
Add a new port mapping under the sc service and map the 6379 port in the container (if external access is not required, you do not need to add port mapping)
- 6379:6379
docker-compose.yaml configuration file example
version: '3'
services:
core:
image: nocoly/core:7.4.2
environment:
ENV_ADDRESS_MAIN: "https://example.domain.com"
ENV_APP_VERSION: "7.4.2"
ENV_API_TOKEN: "****"
ENV_REDIS_PASSWORD: "f8K5ZT3aQXTb" #Add a new variable and change it to the actual password.
ports:
- 8880:8880
volumes:
- ../data:/data/hap/data
sc:
image: nocoly/sc:3.2.0
environment:
<<: *app-environment
ports:
- 3306:3306 #Added Redis port mapping. If external access to Redis is not required, there is no need to add this port mapping.
volumes:
- ./volume/data/:/data/
- ../data:/data/hap/data
-
Restart the microservice in the directory where the installation manager is located to take effect.
bash service.sh restartall