mongodb installation to configuration issues

First, all the problems

Xshell not connect

Type error: Could not connect to '192.168.122.1' (port 22): Connection failed.
The reason: IP address is not generated
solutions: Rebuild the ip address of the service network restart, -a view after the virtual machine inet IP in ifconfig

 

Xshell upload files to the server: rz

Xshell download files from the server: rz filename

 

Unzip the file 
tar -zxvf filename.tar.gz # extract to the current directory, retain the original file
tar -zxvf filename.tar.gz -C dir # dir extract to a directory, retain the original file
compressed tar czvf kernel.tgz linux-2.6.29

 

When the execution is not enough to create or delete user permissions centos

the root SU
chown -R & lt HK: HK / the dir
(LL / usr see the results, the increase in the permission / usr)

 

Due to the above operation results in under / usr root privileges instead of the user group, reported the following error

[hk@hk ~]$ sudo root passwd
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
[hk@hk ~]$ su root
Password: 
su: Authentication failure

Solution:
1, to switch to the root user permissions back, chown root: root / usr / -R & lt *
2, the root user performs
the chmod + U S / usr / bin / the sudo
the chmod + U S / usr / bin / su

vim command
to delete all content gg dG

Port number 27017 is occupied reported 48 errors

Failed to set up listener: SocketException: Address already in use

Solution:

lsof -i :27017 #pid
kill - 9 pid

Second, install and run

Install version MongoDB 4.0, the official website to download

cd /usr/local
tar -zxvf  mongodb-linux-x86_64-4.0.0.tgz
mkdir mongodb
mv mongodb-linux-x86_64-4.0.0/*  mongodb
rm -rf mongodb-linux-x86_64-4.0.0.tgz
rm -rf mongodb-linux-x86_64-4.0.0

cd mongodb
mkdir db
mkdir  logs
touch logs/mongodb.log
cd /usr/local/mongodb
touch mongodb.conf

Modify the startup file: vim mongodb.conf

port = 27017 # port 

bind_ip = 0.0.0.0 # default is 127.0.0.1 

dbpath = / usr / local / MongoDB / db # database storage 

logpath = / usr / local / mongodb / logs / mongodb.log # log file 

fork = true # set the background 

# auth = true # authentication open

Add mongodb environment variables : vim / etc / profile

export MONGODB_HOME=/usr/local/mongodb  
export PATH=$PATH:$MONGODB_HOME/bin

  

To save the modified reboot the system configuration , execute the command: source / etc / profile  

Run to start the database

/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/mongodb.conf

Boot from the start

vim /etc/rc.d/rc.local
/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/mongodb.conf

Firewall settings

vim /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 27017 -j ACCEPT
systemctl start iptables.service

 

Firewall setup error:

The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

Close firewalld:

STOP firewalld systemctl 
systemctl mask firewalld 
yum the install iptables-Services 

# open port 443 (the HTTPS) 
iptables -A --dport the INPUT -p TCP -j ACCEPT 443 
 
# stores the rule 
-Service iptables Save 
 
# open service 
systemctl the restart iptables.service 

systemctl enable iptables 

iptables restart systemctl 

Service iptables the Save

Access the database : Run mongo normal operation or a warning message will be reported in the bin directory

 

 Error Analysis:

WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.We suggest setting it to 'never'

WARNING: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted.

 

WARNING: You are running this process as the root user, which is not recommended.

1, / etc / rc.local file settings (transparent_hugepage) problems, according to the relevant specific online methods to try, or reported as a warning. Does not affect the use, temporarily did not go to the scrutiny.

2, the configuration file mongodb.conf auth certified open.

3, does not recommend the use of root user.

Guess you like

Origin www.cnblogs.com/hqczsh/p/12150634.html