Installation Deployment
1. Installation overview
This article introduces the installation process and precautions of Ivorysql on Linux platform. This article mainly demonstrates rpm package installation steps, and source code installation steps of the database under the Centos 7 environment.
1.1. Software and hardware requirements
1.2. Environment and configuration check
Before deploying the IvorySQL database, you need to check the system environment and configuration
1.2.1. View resources
The IvorySQL database supports CentOS 7. X, operating systems. For details, refer to [_software_and_hardware_requirements].
1.3. Get installation package
You can install the IvorySql database or RPM package through the source code.
1.3.1. Use source code to build IvorySQL database
1.Get the source code: Run the following command to clone the source code of the IvorySQL database to your build machine:
git clone https://github.com/IvorySQL/IvorySQL.git
Note: To clone code, you need to install and configure Git first. For details, refer to Git doc.
2.Install dependent packages: To compile IvorySQL from source code, you must ensure that prerequisite packages are available on the system. Execute the following command to install related packages:
sudo yum install -y bison-devel readline-devel zlib-devel openssl-devel wget
sudo yum groupinstall -y 'Development Tools'
Note: "Development Tools" includes gcc, make, flex, bison.
3.Self-compilation and installation: The source code obtained previously is in the folder IvorySQL. Next, we will enter this folder for operation.
Configuration: Root users execute the following commands to configure:
git checkout tags/Ivory_REL_1_8
./configure --prefix=/usr/local/ivorysql/ivorysql-1.8
Note: Because — prefix is not provided, it is installed in/usr/local/pgsql by default, so you need to specify the path
Note: We should remember the specified directory, because the system cannot find out where the compiled and installed programs are. More configure parameters can be viewed through "./configure — help". You can also view the PostgreSQL manual
Compile and install: After the configuration is completed, execute make to compile:
make
Perform a regression test before installing the newly compiled service (the following commands can be used):
make check
make all-check-world
Installation:
make install
1.3.2. Install the IvorySql database using the RPM package
-
Run the following command to download the IvorySQL installation package.
wget https://github.com/IvorySQL/IvorySQL/releases/download/Ivory_REL_1_8/ivorysql1-1.8-1.el7.x86_64.rpm
Note: The installation package in the example may not be the latest version. It is recommended that you download the latest installation package.
2.Run the following command to install IvorySQL.
yum install -y libicu libxslt python3 --Install dependencies first
rpm -ivh ivorysql1-1.8-1.el7.x86_64.rpm
1.4. Initialize database service
1.4.1. Initialize database
1.Create an operating system user: under the user root session, create a new user ivorysql:
/usr/sbin/groupadd ivorysql
/usr/sbin/useradd -g ivorysql ivorysql -c "IvorySQL1.8"
passwd ivorysql
2.Environment variable: switch to user ivorysql, modify the file "/home/ivorysql/. bash_profile", and configure the environment variable:
umask 022
export LD_LIBRARY_PATH=/opt/IvorySQL-1.8/lib:$LD_LIBRARY_PATH
export PATH=/opt/IvorySQL-1.8/bin:$PATH
export PGDATA=/home/ivorysql/data
Make the environment variable effective in the current ivorysql user session:
source .bash_profile
You can also log in again or open a new user ivorysql session.
3.Set the firewall: If the firewall is enabled, port 5333 needs to be opened:
firewall-cmd --zone=public --add-port=5333/tcp --permanent
firewall-cmd --reload
Note: The default port is 5333. If the port is not opened, the external client will fail to connect via IP.
4.Initialization: Under user ivorysql, simply execute initdb to complete initialization:
initdb
Note: The initdb operation is the same as PostgreSQL. It can be initialized according to the habits of PG.
5.Start database: use pg_ Ctl starts the database service:
pg_ctl start
View the status and start successfully:
pg_ctl status
1.5. Configure service
1.Client authentication: modify /home/ivorysql/data/pg_hba.conf, add the following:
host all all 0.0.0.0/0 trust
Note: This is trust, which means that you can log in without password.
Execute the following command to load the configuration:
pg_ctl reload
2.Basic parameters
Connect to the database through psql:
psql
Modify listening address
alter system set listen_addresses = '*';
Note: The default is listening at 127.0.0.1. The service cannot be connected outside the host.
3.Guard service
Create a service file:
touch /usr/lib/systemd/system/ivorysql.service
The editing contents are as follows:
[Unit]
Description=IvorySQL 1.8 database server
Documentation=https://www.ivorysql.org
Requires=network.target local-fs.target
After=network.target local-fs.target
[Service]
Type=forking
User=ivorysql
Group=ivorysql
Environment=PGDATA=/home/ivorysql/data
OOMScoreAdjust=-1000
ExecStart=/opt/IvorySQL-1.8/bin/pg_ctl start -D ${PGDATA}
ExecStop=/opt/IvorySQL-1.8/bin/pg_ctl stop -D ${PGDATA}
ExecReload=/opt/IvorySQL-1.8/bin/pg_ctl reload -D ${PGDATA}
A}
TimeoutSec=0
[Install]
WantedBy=multi-user.target
Note: There are many ways to write a service. Be careful when using it in a production environment. Please repeat the test several times.
Stop pg_ The database service started by ctl enables the systemd service and starts:
systemctl enable --now ivorysql.service
IvorSQL database service operation command:
systemctl start ivorysql.service
systemctl stop ivorysql.service
systemctl restart ivorysql.service
systemctl status ivorysql.service
systemctl reload ivorysql.service
1.6. Uninstall the IvorySQL database
1.6.1. Compile Uninstall
1.Backup data: we can protect the directory. It is better to stop the database service and make a backup.
systemctl stop ivorysql-1.service
2.Compile and uninstall: switch the root session to the source directory and execute the following commands respectively:
make uninstall
make clean
3.Delete residual directories and files:
systemctl disable ivorysql.servicemake --disable Service
mv /usr/lib/systemd/system/ivorysql.service /tmp/ --the service file can be moved to/tmp or deleted
rm -fr /opt/IvorySQL-1.8 --remove residual installation directory
Note: There are also user ivorysql and corresponding environment variables, which can be cleaned according to the situation. Please make sure to make a backup before processing. There are also installed dependent packages, which can be uninstalled according to the situation.