Deploying services in linux

linux Installation nginx

First go to the official website to download the latest package
https://nginx.org/en/download.html

[the external chain picture transfer fails. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-s25f8bg-1613960297585)( https://i.loli.net/2020/12/21/wBZhgNriWHFj6zQ.png )]

Then put the package into the server

Unzip the installation package
tar -zxvf nginx-1.11.6.tar.gz
 upload nginx Dependent packages

[the external chain picture transfer fails. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-y1cjyhqi-1613960297587)( https://i.loli.net/2020/12/21/wsAfK9iFNmREVdk.png )]

cd to dependency package

Perform batch installation
rpm -i *.rpm --force --nodeps  //Enforce do not verify dependencies
 Execute the configuration command:
./configure

[the external chain image transfer fails. The source station may have anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-p9ak93nd-1613960297589)( https://i.loli.net/2020/12/21/dmQUMpFizctKbqR.png )]

Compile and install
make install
 Find installation path command:
whereis nginx
 Enter profile folder
cd /usr/local/nginx/conf
 Backup configuration files (backup is a good habit and can be omitted)
cp nginx.conf nginx.conf.back
 edit nginx.conf configuration file
vi nginx.conf
 get into nginx Startup directory
cd /usr/local/nginx/sbin/
restart nginx
./nginx -s reload
 query nginx process
ps aux|grep nginx
 Reload profile
./nginx -s reload
 Stop before start (recommended)
./nginx -s quit
./nginx
 Power on self start
vi /etc/rc.local
	Add statement
	/usr/local/nginx/sbin/nginx
	Set permissions
	chmod 755 /etc/rc.local

Installing redis on linux

Download package and dependency first. There are two main dependencies

Enter libs file first

Perform installation of all dependencies
rpm -i *.rpm
 Then unzip redis Installation package
tar -zxvf redis-5.0.0.tar.gz -C /usr/local/redis/
Enter the extracted folder
cd /usr/local/redis/redis-5.0.0
 Execute compilation
make
 After compiling, execute the installation to the specified path
make install PREFIX=/usr/local/redis
 Set service background to start replication conf reach bin in
cp /usr/local/redis/redis-5.0.0/redis.conf /usr/local/redis/bin
 modify conf file
vim redis.conf
 bar daemonize Set to yes: 
start-up redis service
cd /usr/local/redis/bin
./redis-server redis.conf
 Start client
./redis-cli
 close redis
./redis-cli shutdown

Offline installation of Oracle11G

Oracle 11G download address in liunx

Oracle Database 11g Release 2 (11.2.0.1.0) for Linux x86-64
http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_1of2.zip
http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_2of2.zip

Update unzip command

	 yum list | grep zip/unzip

     yum install zip

     yum install unzip 

Upload it to the / install package in liunx for decompression

 unzip linux.x64_11gR2_database_1of2.zip
 unzip linux.x64_11gR2_database_2of2.zip

Put the extracted files in the / software folder

mv database/ /software/

Close selinux

vim /etc/selinux/config
//Set SELINUX=disabled
setenforce 0

Turn off the firewall

systemctl restart firewalld.service
systemctl list-unit-files|grep firewalld.service
systemctl disable firewalld.service

Install the dependent package of oracle11G

yum install gcc make binutils gcc-c++ compat-libstdc++-33elfutils-libelf-devel elfutils-libelf-devel-static ksh libaio libaio-develnumactl-devel sysstat unixODBC unixODBC-devel pcre-devel –y

Add installation users and user groups

 groupadd oinstall
  groupadd dba
  useradd -g oinstall -G dba oracle
   passwd oracle
   id oracle

Modify kernel parameter configuration file

vim /etc/sysctl.conf
//Add at the end
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1073741824
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

Modify user's restriction file

vim /etc/security/limits.conf
//Add at the end
oracle           soft    nproc           2047
oracle           hard    nproc           16384
oracle           soft    nofile          1024
oracle           hard    nofile         65536
oracle           soft    stack           10240 

vim /etc/pam.d/login
//Add at the end
session required  /lib64/security/pam_limits.so
session required   pam_limits.so 

vim /etc/profile
//Add at the end
#oracle configuration
if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
      ulimit -p 16384
      ulimit -n 65536
  else
      ulimit -u 16384 -n 65536
  fi
fi

Create installation directory and set file permissions

 mkdir -p /data/oracle/product/11.2.0
 mkdir /data/oracle/oradata
 mkdir /data/oracle/inventory
 mkdir /data/oracle/fast_recovery_area
 chown -R oracle:oinstall /data/oracle
 chmod -R 775 /data/oracle

 mkdir /home/oracle/app
 mkdir /home/oracle/app/oracle
 mkdir /home/oracle/app/oradata
 mkdir /home/oracle/app/oraInventory
 mkdir /home/oracle/app/fast_recovery_area
 mkdir /home/oracle/app/oracle/product

Setting oracle user environment variables

 su -l oracle
 vim .bash_profile
 //Add the following at the end:
ORACLE_BASE=/data/oracle

ORACLE_HOME=$ORACLE_BASE/product/11.2.0

ORACLE_SID=orcl

PATH=$PATH:$ORACLE_HOME/bin

export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
//In execution
 source .bash_profile

Edit silent installation response file

//Copy the installation folder response to the home directory of the current oracle user:
 cp -R /software/database/response/ .

 cd response/

 vim db_install.rsp
//The options to be set are as follows:
oracle.install.option=INSTALL_DB_SWONLY

ORACLE_HOSTNAME=CentOS

UNIX_GROUP_NAME=oinstall

INVENTORY_LOCATION=/data/oracle/inventory

SELECTED_LANGUAGES=en,zh_CN

ORACLE_HOME=/data/oracle/product/11.2.0

ORACLE_BASE=/data/oracle

oracle.install.db.InstallEdition=EE

oracle.install.db.DBA_GROUP=dba

oracle.install.db.OPER_GROUP=dba

DECLINE_SECURITY_UPDATES=true

Install Oracle11g silently according to the response file

 cd /software/database/
 ./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq

Problems encountered

Checked the log

No error reports of error level were found

Execute / bin/sh

Finally, the installation succeeded

Execute the script as required.

Open the terminal, log in as root, and execute the script:

sh /data/oracle/inventory/orainstRoot.sh

sh /data/oracle/product/11.2.0/root.sh

Configure listening silently

//Log in to oracle again
su -l oracle
netca /silent /responseFile /home/oracle/response/netca.rsp 

 yum install net-tools

Create a new library silently and a corresponding instance at the same time

vim /home/oracle/response/dbca.rsp
//Modify the following parameters in the file:
[GENERAL]

# oracle version, cannot be changed
RESPONSEFILE_VERSION = "11.2.0"

# Description   : Type of operation
OPERATION_TYPE = "createDatabase"

[CREATEDATABASE]

# Description   : Global database name of the database
# Global database name = SID + host domain name
# The service name used when the third-party tool links the database
GDBNAME = "orcl.test"

# Description   : System identifier (SID) of the database
# Corresponding instance name
SID = "orcl"

# Description   : Name of the template
# Template file for database building
TEMPLATENAME = "General_Purpose.dbc"

# Description   : Password for SYS user
# SYS administrator password
SYSPASSWORD = "123456"

# Description   : Password for SYSTEM user
# SYSTEM administrator password
SYSTEMPASSWORD = "123456"

# Description   : Password for SYSMAN user
# SYSMAN administrator password
SYSMANPASSWORD = "123456"

# Description   : Password for DBSNMP user
# DBSNMP administrator password
DBSNMPPASSWORD = "123456"

# Description   : Location of the data file's
# Data file storage directory
DATAFILEDESTINATION =/data/oracle/oradata

# Description   : Location of the data file's
# Restore data storage directory
RECOVERYAREADESTINATION=/data/oracle/fast_recovery_area

# Description   : Character set of the database
# Character set, important!!! Generally, it cannot be changed after the database is built, so it should be determined clearly before the database is built.
# (CHARACTERSET = "AL32UTF8" NATIONALCHARACTERSET= "UTF8")
CHARACTERSET = "ZHS16GBK"

# Description   : total memory in MB to allocate to Oracle
# oracle memory 1638MB, physical memory 2G*80%
TOTALMEMORY = "1638" 
//Silent configuration:
dbca -silent -responseFile /home/oracle/response/dbca.rsp
//Check the instance process after building the database:
ps -ef | grep ora_ | grep -v grep
//View listening status:
 lsnrctl status
 //lsnrctl start 
 lsnrctl start  
 
 create user admin identified by 123456

grant connect,resource,dba to admin;

An inexplicable rebound appears, and then enter the password. It seems that it is successfully created in the end

Conduct instance check

View listening status:

Database creation completed.

For more information, check the log file: / data / Oracle / cfgtoollogs / DBCA / orcl / orcl log.

Login to view instance status:

sqlplus / as sysdba
SQL> select status from v$instance;

It seems to have been installed

Use oralce after startup

cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/
 sh root.sh 
 source /home/oracle/.bash_profile 
 lsnrctl status
 lsnrctl start
 su oracle
 source /home/oracle/.bash_profile 
 lsnrctl start
sqlplus / as sysdba
 startup
lsnrctl
sqlplus /nolog
conn /as sysdba;
 create user admin identified by 123456;
 grant connect,resource,dba to admin;

After successfully installing oracle, create a login account

1. Switch to oracle user

su -l oracle

2. Login with sysdba account:

sqlplus / as sysdba

3. Create user
Syntax: CREATE USER username IDENTIFIED BY password;

CREATE  USER admin IDENTIFIED BY admin;

4. Unlock / lock the newly created user
Syntax: ALTER USER username ACCOUNT UNLOCK/LOCK
//User unlock
```
alter user mmzsit account unlock;

    //User locked

alter user admin account lock;
//User unlock
alter user admin account unlock;

4,Grant the newly logged in user creation permission:
Syntax: CRANT CREATE SESSION TO user name

​```js
grant create session to admin;

5. Grant database administrator privileges to newly created users
Syntax: Crane DBA to user name;

grant dba to admin;

6. Switch to the newly created user login
Syntax: CONNECT username / password

connect admin/admin;

Install Oracle 11g Online

[the external chain picture transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-slvcv9rd-1613960297599)( https://i.loli.net/2020/12/31/fLZPHkolyRBjVqO.png )]

First put the package in / install/oracle11G

cd /install/oracle11G
unzip unzip linux_11gR2_database_1of2.zip 
unzip unzip linux_11gR2_database_1of2.zip 

Install oracle server software

yum install -y binutils*

yum install -y compat-libstdc*

yum install -y elfutils-libelf*

yum install -y gcc*

yum install -y glibc*

yum install -y ksh*

yum install -y libaio*

yum install -y libgcc*

yum install -y libstdc*

yum install -y make*

yum install -y sysstat*

Adjust kernel parameters and user restrictions

[root@localhost etc]# vim /etc/sysctl.conf 
//Add information
fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.shmall = 2097152

kernel.shmmax = 536870912

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048586

Edit / etc / security / limits Conf file to modify the restrictions of the operating system on oracle user resources. Add the following line to the file.

[root@localhost ~]# vim /etc/security/limits.conf
//Add to # End of file
oracle           soft    nproc   2047

oracle           hard    nproc   16384

oracle           soft    nofile  1024

oracle           hard    nofile  65536

oracle           hard    stack   10240

Turn on operating system asynchronous IO (AIO)

The package to be installed in point 2 above already contains libaio-0.3.106. Asynchronous I/O is enabled by default.

Check whether AIO is running in the operating system. The running command and display results are similar as follows:

$ cat /proc/slabinfo | grep kio

kioctx   51  120  320  12  1 : tunables  54  27  8 : slabdata  10  10  0

kiocb   30   30  256  15  1 : tunables 120  60  8 : slabdata  2   2  0

Note: if the database uses a file system and asynchronous IO is used, the initialization parameters of the database need to be modified

a. Set disk_asynch_io parameter value is TRUE (default value)

b. Set filesystemio_ The value of options parameter is ASYNCH

Install mongo offline

First put mongodb Linux x86_ 64-3.6.3. Tgz upload to server

tar -xvf mongodb-linux-x86_64-3.6.3.tgz
mv mongodb-linux-x86_64-3.6.3 mongodb
mkdir /data/mongodb

vi /usr/local/mongodb/mongodb.conf

port=27017 #port
dbpath= /data/mongodb  #Database file storage directory
logpath= /usr/local/mongodb/mongodb.log #Log file storage path
logappend=true #Write log by appending
fork=true #Run as a daemon to create a server process
maxConns=100 #Maximum simultaneous connections
noauth=false #Enable validation
journal=false #Each write will record an operation log (the written data can be reconstructed through journal).
bind_ip=0.0.0.0 #This allows external access

Create soft connection

ln -s /usr/local/mongodb/bin/mongod /usr/bin/mongod
ln -s /usr/local/mongodb/bin/mongo /usr/bin/mongo 

start-up

mongod --config /usr/local/mongodb/mongodb.conf
ps -aux|grep mong   

Power on self start

vim /etc/rc.local
mongod --config /usr/local/mongodb/mongodb.conf
chmod 777 /etc/rc.local

View version number

mongo --version

Enter the mongo command line

#Enter shell
mongo

#View version number
db.version()
show dbs
usr admin
#Set password to 123456
db.createUser({ user:'admin',pwd:'123456',roles:[ { role:'userAdminAnyDatabase', db: 'admin'},"readWriteAnyDatabase"]});
# Try to connect using the user information created above.
db.auth('admin', '123456')

visit

#### Create soft connection

```apl
ln -s /usr/local/mongodb/bin/mongod /usr/bin/mongod
ln -s /usr/local/mongodb/bin/mongo /usr/bin/mongo 

start-up

mongod --config /usr/local/mongodb/mongodb.conf
ps -aux|grep mong   

Power on self start

vim /etc/rc.local
mongod --config /usr/local/mongodb/mongodb.conf
chmod 777 /etc/rc.local

View version number

mongo --version

Enter the mongo command line

#Enter shell
mongo

#View version number
db.version()
show dbs
usr admin
#Set password to 123456
db.createUser({ user:'admin',pwd:'123456',roles:[ { role:'userAdminAnyDatabase', db: 'admin'},"readWriteAnyDatabase"]});
# Try to connect using the user information created above.
db.auth('admin', '123456')

Posted by foid025 on Sun, 17 Apr 2022 06:11:01 +0930