Ubuntu 18.04 LTS安装NetBox v2.6.12
分类:运维技术日期:2020-01-14 - 23:59:13作者:老谢
NetBox是一款IP地址管理(IPAM)和数据中心基础结构管理(DCIM)工具,原本在用racktales,但是在某群看到有哥们发出NetBox的截图后,起码看起来比racktales的ui现代化一点,于是折腾一把试试看。
项目地址:https://github.com/netbox-community/netbox
官方文档:https://netbox.readthedocs.io/en/stable/
参考文档:https://computingforgeeks.com/how-to-install-netbox-on-centos-7-with-apache-and-supervisord/
- IP address management (IPAM) – IP networks and addresses, VRFs, and VLANs
- Equipment racks – Organized by group and site
- Devices – Types of devices and where they are installed
- Connections – Network, console, and power connections among devices
- Virtualization – Virtual machines and clusters
- Data circuits – Long-haul communications circuits and providers
- Secrets – Encrypted storage of sensitive credentials
安装PostgreSQL
apt-get update
apt-get install -y postgresql libpq-dev |
apt-get update
apt-get install -y postgresql libpq-dev
# sudo -u postgres psql
psql (9.4.5)
TYPE "help" FOR help.
postgres=# CREATE DATABASE netbox;
CREATE DATABASE
postgres=# CREATE USER netbox WITH PASSWORD 'J5brHrAXFLQSif0K';
CREATE ROLE
postgres=# GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
GRANT
postgres=# \q
psql -U netbox -W -h localhost netbox |
# sudo -u postgres psql
psql (9.4.5)
Type "help" for help.
postgres=# CREATE DATABASE netbox;
CREATE DATABASE
postgres=# CREATE USER netbox WITH PASSWORD 'J5brHrAXFLQSif0K';
CREATE ROLE
postgres=# GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
GRANT
postgres=# \q
psql -U netbox -W -h localhost netbox
如果成功,您将输入密码。键入\q退出。
安装NetBox
apt-get install -y python3 python3-pip python3-dev build-essential libxml2-dev libxslt1-dev libffi-dev graphviz libpq-dev libssl-dev redis-server zlib1g-dev
cd /opt
apt-get install -y git
git clone -b master https://github.com/netbox-community/netbox.git
cd netbox
pip3 install -r requirements.txt
cd /opt/netbox/netbox/netbox
cp configuration.example.py configuration.py
vi configuration.py #编辑数据库信息,host填安装netbox的主机ip
cd ..
sudo ./generate_secret_key.py |
apt-get install -y python3 python3-pip python3-dev build-essential libxml2-dev libxslt1-dev libffi-dev graphviz libpq-dev libssl-dev redis-server zlib1g-dev
cd /opt
apt-get install -y git
git clone -b master https://github.com/netbox-community/netbox.git
cd netbox
pip3 install -r requirements.txt
cd /opt/netbox/netbox/netbox
cp configuration.example.py configuration.py
vi configuration.py #编辑数据库信息,host填安装netbox的主机ip
cd ..
sudo ./generate_secret_key.py
root@li1324-152:/opt/netbox/netbox# ./generate_secret_key.py
#(owS3iQ40lzL_M$R9c^tj8+-p=yYkxXKh1PnDu75fG&ZvrqNH |
root@li1324-152:/opt/netbox/netbox# ./generate_secret_key.py
#(owS3iQ40lzL_M$R9c^tj8+-p=yYkxXKh1PnDu75fG&ZvrqNH
将密钥添加到配置文件的SECRET_KEY字段
cd /opt/netbox/netbox/netbox
vi configuration.py |
cd /opt/netbox/netbox/netbox
vi configuration.py
cd /opt/netbox/netbox/
python3 manage.py migrate
python3 manage.py createsuperuser #创建用户及密码
python3 manage.py loaddata initial_data #创建初始演示数据
python3 manage.py runserver 0.0.0.0:8000 --insecure #测试应用 |
cd /opt/netbox/netbox/
python3 manage.py migrate
python3 manage.py createsuperuser #创建用户及密码
python3 manage.py loaddata initial_data #创建初始演示数据
python3 manage.py runserver 0.0.0.0:8000 --insecure #测试应用
supervisor安装
pip3 install supervisor
echo_supervisord_conf > /etc/supervisord.conf
vim /etc/supervisord.conf
[include]
files = /etc/supervisord.conf.d/*.conf
mkdir /etc/supervisord.conf.d
cd /etc/supervisord.conf.d
vim netbox.conf
[program:netbox]
command=python3 /opt/netbox/netbox/manage.py runserver 0.0.0.0:8000 --insecure
autostart=true
autorestart=true
ln -s /usr/local/bin/supervisord /usr/bin/supervisord
ln -s /usr/local/bin/supervisorctl /usr/bin/supervisorctl
supervisorctl start netbox |
pip3 install supervisor
echo_supervisord_conf > /etc/supervisord.conf
vim /etc/supervisord.conf
[include]
files = /etc/supervisord.conf.d/*.conf
mkdir /etc/supervisord.conf.d
cd /etc/supervisord.conf.d
vim netbox.conf
[program:netbox]
command=python3 /opt/netbox/netbox/manage.py runserver 0.0.0.0:8000 --insecure
autostart=true
autorestart=true
ln -s /usr/local/bin/supervisord /usr/bin/supervisord
ln -s /usr/local/bin/supervisorctl /usr/bin/supervisorctl
supervisorctl start netbox
root@li1324-152:~# supervisorctl status
netbox RUNNING pid 15529, uptime 0:07:07
root@li1324-152:~# |
root@li1324-152:~# supervisorctl status
netbox RUNNING pid 15529, uptime 0:07:07
root@li1324-152:~#
直接通过supervisord运行netbox目前来看资源占用率也不高,懒得折腾gunicorn/uWsgi和nginx了,先研究研究netbox,好用再折腾运行环境吧:)
暂时没有评论!