To set up the NICOS server on your local machine, follow these steps.
Install the necessary Python packages (it's recommended to use a virtual environment):
pip install -r requirements.txt
Create a directory for storing NICOS data:
mkdir /opt/nicos-data
Note: This may require sudo rights. Ensure the directory has the correct ownership.
Link the configuration file for your chosen instrument:
ln -s nicos_ess/<instrument>/nicos.conf .
A good starting instrument is ymir
, which is a test instrument.
Start the NICOS cache server:
./bin/nicos-cache
To configure what cache database to use, see section Configure Cache Database.
In a separate terminal, start the NICOS poller:
./bin/nicos-poller
If required, start the NICOS collector in another terminal:
./bin/nicos-collector
Finally, in another terminal, start the NICOS daemon:
./bin/nicos-daemon
Install the necessary packages for the NICOS GUI:
pip install -r requirements-gui.txt
Start the NICOS client with your selected instrument's configuration:
./bin/nicos-gui -c nicos_ess/<instrument>/guiconfig.py
If you prefer QT6, use the following command (not required on macOS with silicon architecture):
NICOS_QT=6 ./bin/nicos-gui -c nicos_ess/<instrument>/guiconfig.py
NICOS supports different cache databases. You can use MemoryCacheDatabase
, FlatfileCacheDatabase
, or RedisCacheDatabase
. For local development, MemoryCacheDatabase
or FlatfileCacheDatabase
are easiest to set up.
Edit the cache.py
setup file to choose your cache database:
vim nicos_ess/<instrument>/setups/special/cache.py
No changes needed if you are using the default MemoryCacheDatabase
:
DB=device(
"nicos.services.cache.server.MemoryCacheDatabase",
loglevel="info",
)
To use FlatfileCacheDatabase
, update the setup file as follows:
DB=device(
"nicos.services.cache.server.FlatfileCacheDatabase",
storepath="/opt/nicos-data/cache",
loglevel="info",
)
For Redis-based caching, RedisCacheDatabase
, configure as follows:
DB=device(
"nicos.services.cache.server.RedisCacheDatabase",
loglevel="info",
)
In the case of RedisCacheDatabase
, you need to set up Redis and RedisTimeSeries. See section Redis Setup for instructions.
To set up your environment for development, install the additional required packages:
pip install -r requirements-dev.txt
Install the pre-commit hook to ensure code quality:
pre-commit install
This section guides you through installing Redis, an in-memory data store, and RedisTimeSeries, a module for time-series data processing. The RedisTimeSeries module is mandatory.
The instructions are for Linux systems (tested on ubuntu 22.04 and CentOS 7). For other operating systems, refer to the Redis and RedisTimeSeries documentation.
Download and extract the Redis package:
wget http://download.redis.io/releases/redis-6.2.14.tar.gz
tar xzf redis-6.2.14.tar.gz
cd redis-6.2.14
Compile the Redis source code:
make
Optional but recommended: Run tests to ensure Redis is functioning correctly.
make test
Install Redis on your system:
sudo make install
Create a directory for the Redis configuration file:
sudo mkdir /etc/redis
Copy the default configuration file:
sudo cp redis.conf /etc/redis/redis.conf
Open the configuration file to apply necessary settings:
sudo vim /etc/redis/redis.conf
IMPORTANT: Ensure Redis is bound to localhost for security:
bind 127.0.0.1 ::1
protected-mode yes
supervised systemd
dir /var/lib/redis
Create a service file to manage Redis with systemd:
sudo vim /etc/systemd/system/redis.service
Paste the following configuration, replacing nicos
with your username (on the nicosservers, it's nicos
):
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
User=nicos
Group=nicos
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
[Install]
WantedBy=multi-user.target
Create and set permissions for the Redis data directory:
sudo mkdir /var/lib/redis
sudo chown nicos:nicos /var/lib/redis
sudo chmod 770 /var/lib/redis
Enable and start the Redis service:
sudo systemctl enable redis
sudo systemctl start redis
Optionally, check the status to ensure Redis is running smoothly:
sudo systemctl status redis
Find the Redis CLI tool:
sudo find / -name redis-cli
Add Redis binaries to your system PATH:
vim ~/.bashrc
export PATH=$PATH:/usr/local/bin
source ~/.bashrc
Test that Redis is installed and running correctly:
redis-cli ping
Clone the RedisTimeSeries repository:
git clone --recursive https://github.com/RedisTimeSeries/RedisTimeSeries.git
cd RedisTimeSeries
Set up the environment and build the module:
./sbin/setup
bash -l
make
Copy the RedisTimeSeries module to the appropriate directory:
cp RedisTimeSeries/bin/linux-x64-release/redistimeseries.so /etc/redis/redistimeseries.so
To load the RedisTimeSeries module, add this line to redis.conf
:
loadmodule /etc/redis/redistimeseries.so
Restart Redis to apply changes:
sudo systemctl restart redis
Check that the RedisTimeSeries module is loaded correctly:
redis-cli MODULE LIST